Container c = getContainer();  int li = getLeftInset(); int ti = getTopInset();  Rectangle alloc = new Rectangle(li, ti, getWidth()-getRightInset()-li, getHeight()-getBottomInset()-ti);   if (alloc.isEmpty()) return 0;  updateMetrics();
Segment s = new Segment();
  protected int calculateBreakPosition(int p0, int p1)  {    Container c = getContainer();        int li = getLeftInset();    int ti = getTopInset();        Rectangle alloc = new Rectangle(li, ti,                                    getWidth()-getRightInset()-li,                                    getHeight()-getBottomInset()-ti);    // Mimic a behavior observed in the RI.    if (alloc.isEmpty())      return 0;        updateMetrics();        try      {        getDocument().getText(p0, p1 - p0, getLineBuffer());      }    catch (BadLocationException ble)      {        // this shouldn't happen        throw new InternalError("Invalid offsets p0: " + p0 + " - p1: " + p1);      }    if (wordWrap)      return p0 + Utilities.getBreakLocation(lineBuffer, metrics, alloc.x,                                          alloc.x + alloc.width, this, 0);    else      return p0 + Utilities.getTabbedTextOffset(lineBuffer, metrics, alloc.x,                                             alloc.x + alloc.width, this, 0,                                             true);  }