public int viewToModel(float fx,float fy,Shape a,Position.Bias[] bias){
  bias[0]=Position.Bias.Forward;
  Rectangle alloc=a.getBounds();
  RSyntaxDocument doc=(RSyntaxDocument)getDocument();
  int x=(int)fx;
  int y=(int)fy;
  if (y < alloc.y) {
    return getStartOffset();
  }
 else   if (y > alloc.y + alloc.height) {
    return getEndOffset() - 1;
  }
 else {
    Element map=doc.getDefaultRootElement();
    int lineIndex=Math.abs((y - alloc.y) / lineHeight);
    if (lineIndex >= map.getElementCount())     return getEndOffset() - 1;
    Element line=map.getElement(lineIndex);
    if (x < alloc.x)     return line.getStartOffset();
 else     if (x > alloc.x + alloc.width)     return line.getEndOffset() - 1;
 else {
      int p0=line.getStartOffset();
      Token tokenList=doc.getTokenListForLine(lineIndex);
      tabBase=alloc.x;
      int offs=tokenList.getListOffset((RSyntaxTextArea)getContainer(),this,tabBase,x);
      return offs != -1 ? offs : p0;
    }
  }
}

public int viewToModel ( float fx , float fy , Shape a , Position . Bias [ ] bias ) { bias [ 0 ] = Position . Bias . Forward ; Rectangle alloc = a . getBounds ( ) ; RSyntaxDocument doc = ( RSyntaxDocument ) getDocument ( ) ; int x = ( int ) fx ; int y = ( int ) fy ; if ( y < alloc . y ) { return getStartOffset ( ) ; } else if ( y > alloc . y + alloc . height ) { return getEndOffset ( ) - 1 ; } else { Element map = doc . getDefaultRootElement ( ) ; int lineIndex = Math . abs ( ( y - alloc . y ) / lineHeight ) ; if ( lineIndex >= map . getElementCount ( ) ) return getEndOffset ( ) - 1 ; Element line = map . getElement ( lineIndex ) ; if ( x < alloc . x ) return line . getStartOffset ( ) ; else if ( x > alloc . x + alloc . width ) return line . getEndOffset ( ) - 1 ; else { int p0 = line . getStartOffset ( ) ; Token tokenList = doc . getTokenListForLine ( lineIndex ) ; tabBase = alloc . x ; int offs = tokenList . getListOffset ( ( RSyntaxTextArea ) getContainer ( ) , this , tabBase , x ) ; return offs != - 1 ? offs : p0 ; } } }
provides a mapping from the view coordinate space to the logical coordinate space of the model .
