question: private double drawLabel ( Graphics2D graphics , String text , Font font , double x , double baseY , double maxWidth ) { FontMetrics fontMetrics = graphics . getFontMetrics ( font ) ; Rectangle2D label = fontMetrics . getStringBounds ( text , graphics ) ; double offset = label . getWidth ( ) / 2.0d ; double y = baseY + label . getHeight ( ) ; if ( offset > ( maxWidth / 2.0d ) ) { label . setRect ( x - ( maxWidth / 2.0d ) , y - label . getHeight ( ) , maxWidth , label . getHeight ( ) ) ; graphics . setClip ( label ) ; graphics . drawString ( text , ( float ) ( x - ( maxWidth / 2.0d ) ) , ( float ) y ) ; graphics . setClip ( null ) ; } else { graphics . drawString ( text , ( float ) ( x - offset ) , ( float ) y ) ; } return label . getHeight ( ) ; }
target:  Draws a textual label at the x/y position, clipping the end of the text to fit within the maxwidth value.