public Shape modelToView(int pos,Shape a,Position.Bias b) throws BadLocationException {
  Rectangle alloc=a.getBounds();
  alloc.height=metrics.getHeight();
  alloc.width=1;
  int p0=getStartOffset();
  if (pos < p0 || pos > getEndOffset()) {
    throw new BadLocationException("Position out of range",pos);
  }
  int testP=(b == Position.Bias.Forward) ? pos : Math.max(p0,pos - 1);
  int line=0;
  int[] lineEnds=getLineEnds();
  if (lineEnds != null) {
    line=findLine(testP - p0);
    if (line > 0) {
      p0+=lineEnds[line - 1];
    }
    alloc.y+=alloc.height * line;
  }
  if (pos > p0) {
    Segment segment=SegmentCache.getSharedSegment();
    loadText(segment,p0,pos);
    alloc.x+=Utilities.getTabbedTextWidth(segment,metrics,alloc.x,WrappedPlainView.this,p0);
    SegmentCache.releaseSharedSegment(segment);
  }
  return alloc;
}

public Shape modelToView ( int pos , Shape a , Position . Bias b ) throws BadLocationException { Rectangle alloc = a . getBounds ( ) ; alloc . height = metrics . getHeight ( ) ; alloc . width = 1 ; int p0 = getStartOffset ( ) ; if ( pos < p0 || pos > getEndOffset ( ) ) { throw new BadLocationException ( "Position out of range" , pos ) ; } int testP = ( b == Position . Bias . Forward ) ? pos : Math . max ( p0 , pos - 1 ) ; int line = 0 ; int [ ] lineEnds = getLineEnds ( ) ; if ( lineEnds != null ) { line = findLine ( testP - p0 ) ; if ( line > 0 ) { p0 += lineEnds [ line - 1 ] ; } alloc . y += alloc . height * line ; } if ( pos > p0 ) { Segment segment = SegmentCache . getSharedSegment ( ) ; loadText ( segment , p0 , pos ) ; alloc . x += Utilities . getTabbedTextWidth ( segment , metrics , alloc . x , WrappedPlainView . this , p0 ) ; SegmentCache . releaseSharedSegment ( segment ) ; } return alloc ; }
provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it .
