public Shape modelToView(int pos,Shape a,Position.Bias b) throws BadLocationException {
  boolean isBackward=(b == Position.Bias.Backward);
  int testPos=(isBackward) ? Math.max(0,pos - 1) : pos;
  if (isBackward && testPos < getStartOffset()) {
    return null;
  }
  int vIndex=getViewIndexAtPosition(testPos);
  if ((vIndex != -1) && (vIndex < getViewCount())) {
    View v=getView(vIndex);
    if (v != null && testPos >= v.getStartOffset() && testPos < v.getEndOffset()) {
      Shape childShape=getChildAllocation(vIndex,a);
      if (childShape == null) {
        return null;
      }
      Shape retShape=v.modelToView(pos,childShape,b);
      if (retShape == null && v.getEndOffset() == pos) {
        if (++vIndex < getViewCount()) {
          v=getView(vIndex);
          retShape=v.modelToView(pos,getChildAllocation(vIndex,a),b);
        }
      }
      return retShape;
    }
  }
  throw new BadLocationException("Position not represented by view",pos);
}

public Shape modelToView ( int pos , Shape a , Position . Bias b ) throws BadLocationException { boolean isBackward = ( b == Position . Bias . Backward ) ; int testPos = ( isBackward ) ? Math . max ( 0 , pos - 1 ) : pos ; if ( isBackward && testPos < getStartOffset ( ) ) { return null ; } int vIndex = getViewIndexAtPosition ( testPos ) ; if ( ( vIndex != - 1 ) && ( vIndex < getViewCount ( ) ) ) { View v = getView ( vIndex ) ; if ( v != null && testPos >= v . getStartOffset ( ) && testPos < v . getEndOffset ( ) ) { Shape childShape = getChildAllocation ( vIndex , a ) ; if ( childShape == null ) { return null ; } Shape retShape = v . modelToView ( pos , childShape , b ) ; if ( retShape == null && v . getEndOffset ( ) == pos ) { if ( ++ vIndex < getViewCount ( ) ) { v = getView ( vIndex ) ; retShape = v . modelToView ( pos , getChildAllocation ( vIndex , a ) , b ) ; } } return retShape ; } } throw new BadLocationException ( "Position not represented by view" , pos ) ; }
provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it .
