public void paint(GlyphView v,Graphics g,Shape a,int p0,int p1){
  if (g instanceof Graphics2D) {
    Rectangle2D alloc=a.getBounds2D();
    Graphics2D g2d=(Graphics2D)g;
    float y=(float)alloc.getY() + layout.getAscent() + layout.getLeading();
    float x=(float)alloc.getX();
    if (p0 > v.getStartOffset() || p1 < v.getEndOffset()) {
      try {
        Shape s=v.modelToView(p0,Position.Bias.Forward,p1,Position.Bias.Backward,a);
        Shape savedClip=g.getClip();
        g2d.clip(s);
        layout.draw(g2d,x,y);
        g.setClip(savedClip);
      }
 catch (      BadLocationException e) {
      }
    }
 else {
      layout.draw(g2d,x,y);
    }
  }
}

public void paint ( GlyphView v , Graphics g , Shape a , int p0 , int p1 ) { if ( g instanceof Graphics2D ) { Rectangle2D alloc = a . getBounds2D ( ) ; Graphics2D g2d = ( Graphics2D ) g ; float y = ( float ) alloc . getY ( ) + layout . getAscent ( ) + layout . getLeading ( ) ; float x = ( float ) alloc . getX ( ) ; if ( p0 > v . getStartOffset ( ) || p1 < v . getEndOffset ( ) ) { try { Shape s = v . modelToView ( p0 , Position . Bias . Forward , p1 , Position . Bias . Backward , a ) ; Shape savedClip = g . getClip ( ) ; g2d . clip ( s ) ; layout . draw ( g2d , x , y ) ; g . setClip ( savedClip ) ; } catch ( BadLocationException e ) { } } else { layout . draw ( g2d , x , y ) ; } } }
paint the glyphs for the given view . this is implemented to only render if the graphics is of type graphics2d which is required by textlayout ( and this should be the case if running on the jdk ) .
