return end;
return end - 1;
    public int viewToModel(float x, float y, Shape a, Bias[] b)    {      Segment s = getLineBuffer();      Rectangle rect = a.getBounds();      int currLineStart = getStartOffset();            // Although calling modelToView with the last possible offset will      // cause a BadLocationException in CompositeView it is allowed      // to return that offset in viewToModel.      int end = getEndOffset();            int lineHeight = metrics.getHeight();      if (y < rect.y)        return currLineStart;      if (y > rect.y + rect.height)        return end;            // Note: rect.x and rect.width do not represent the width of painted      // text but the area where text *may* be painted. This means the width      // is most of the time identical to the component's width.      while (currLineStart != end)        {          int currLineEnd = calculateBreakPosition(currLineStart, end);          // If we're at the right y-position that means we're on the right          // logical line and we should look for the character          if (y >= rect.y && y < rect.y + lineHeight)            {              try                {                  getDocument().getText(currLineStart, currLineEnd - currLineStart, s);                }              catch (BadLocationException ble)                {                  // Shouldn't happen                }                            int offset = Utilities.getTabbedTextOffset(s, metrics, rect.x,                                                       (int) x,                                                       WrappedPlainView.this,                                                       currLineStart);              // If the calculated offset is the end of the line (in the              // document (= start of the next line) return the preceding              // offset instead. This makes sure that clicking right besides              // the last character in a line positions the cursor after the              // last character and not in the beginning of the next line.              return (offset == currLineEnd) ? offset - 1 : offset;            }          // Increment rect.y so we're checking the next logical line          rect.y += lineHeight;                    // Increment currLineStart to the model position of the start          // of the next logical line.            currLineStart = currLineEnd;        }            return end;    }    