public int viewToModel(float x,float y,Shape a,Position.Bias[] bias){
  Rectangle alloc=getInsideAllocation(a);
  if (isBefore((int)x,(int)y,alloc)) {
    int retValue=-1;
    try {
      retValue=getNextVisualPositionFrom(-1,Position.Bias.Forward,a,EAST,bias);
    }
 catch (    BadLocationException ble) {
    }
catch (    IllegalArgumentException iae) {
    }
    if (retValue == -1) {
      retValue=getStartOffset();
      bias[0]=Position.Bias.Forward;
    }
    return retValue;
  }
 else   if (isAfter((int)x,(int)y,alloc)) {
    int retValue=-1;
    try {
      retValue=getNextVisualPositionFrom(-1,Position.Bias.Forward,a,WEST,bias);
    }
 catch (    BadLocationException ble) {
    }
catch (    IllegalArgumentException iae) {
    }
    if (retValue == -1) {
      retValue=getEndOffset() - 1;
      bias[0]=Position.Bias.Forward;
    }
    return retValue;
  }
 else {
    View v=getViewAtPoint((int)x,(int)y,alloc);
    if (v != null) {
      return v.viewToModel(x,y,alloc,bias);
    }
  }
  return -1;
}

public int viewToModel ( float x , float y , Shape a , Position . Bias [ ] bias ) { Rectangle alloc = getInsideAllocation ( a ) ; if ( isBefore ( ( int ) x , ( int ) y , alloc ) ) { int retValue = - 1 ; try { retValue = getNextVisualPositionFrom ( - 1 , Position . Bias . Forward , a , EAST , bias ) ; } catch ( BadLocationException ble ) { } catch ( IllegalArgumentException iae ) { } if ( retValue == - 1 ) { retValue = getStartOffset ( ) ; bias [ 0 ] = Position . Bias . Forward ; } return retValue ; } else if ( isAfter ( ( int ) x , ( int ) y , alloc ) ) { int retValue = - 1 ; try { retValue = getNextVisualPositionFrom ( - 1 , Position . Bias . Forward , a , WEST , bias ) ; } catch ( BadLocationException ble ) { } catch ( IllegalArgumentException iae ) { } if ( retValue == - 1 ) { retValue = getEndOffset ( ) - 1 ; bias [ 0 ] = Position . Bias . Forward ; } return retValue ; } else { View v = getViewAtPoint ( ( int ) x , ( int ) y , alloc ) ; if ( v != null ) { return v . viewToModel ( x , y , alloc , bias ) ; } } return - 1 ; }
provides a mapping from the view coordinate space to the logical coordinate space of the model .
