public int viewToModel(float fx,float fy,Shape a,Position.Bias[] bias){
  bias[0]=Position.Bias.Forward;
  Rectangle alloc=(Rectangle)a;
  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 {
    alloc.height=metrics.getHeight();
    int line=(alloc.height > 0 ? (y - alloc.y) / alloc.height : lineCount - 1);
    if (line >= lineCount) {
      return getEndOffset() - 1;
    }
 else {
      int p0=getStartOffset();
      int p1;
      if (lineCount == 1) {
        p1=getEndOffset();
      }
 else {
        int[] lineEnds=getLineEnds();
        p1=p0 + lineEnds[line];
        if (line > 0) {
          p0+=lineEnds[line - 1];
        }
      }
      if (x < alloc.x) {
        return p0;
      }
 else       if (x > alloc.x + alloc.width) {
        return p1 - 1;
      }
 else {
        Segment segment=SegmentCache.getSharedSegment();
        loadText(segment,p0,p1);
        int n=Utilities.getTabbedTextOffset(segment,metrics,alloc.x,x,WrappedPlainView.this,p0);
        SegmentCache.releaseSharedSegment(segment);
        return Math.min(p0 + n,p1 - 1);
      }
    }
  }
}

public int viewToModel ( float fx , float fy , Shape a , Position . Bias [ ] bias ) { bias [ 0 ] = Position . Bias . Forward ; Rectangle alloc = ( Rectangle ) a ; 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 { alloc . height = metrics . getHeight ( ) ; int line = ( alloc . height > 0 ? ( y - alloc . y ) / alloc . height : lineCount - 1 ) ; if ( line >= lineCount ) { return getEndOffset ( ) - 1 ; } else { int p0 = getStartOffset ( ) ; int p1 ; if ( lineCount == 1 ) { p1 = getEndOffset ( ) ; } else { int [ ] lineEnds = getLineEnds ( ) ; p1 = p0 + lineEnds [ line ] ; if ( line > 0 ) { p0 += lineEnds [ line - 1 ] ; } } if ( x < alloc . x ) { return p0 ; } else if ( x > alloc . x + alloc . width ) { return p1 - 1 ; } else { Segment segment = SegmentCache . getSharedSegment ( ) ; loadText ( segment , p0 , p1 ) ; int n = Utilities . getTabbedTextOffset ( segment , metrics , alloc . x , x , WrappedPlainView . this , p0 ) ; SegmentCache . releaseSharedSegment ( segment ) ; return Math . min ( p0 + n , p1 - 1 ) ; } } } }
provides a mapping from the view coordinate space to the logical coordinate space of the model .
