protected Label layoutText ( Graphics2D gfx , Font font , String text ) { Label label = _logic . createLabel ( text ) ; label . setFont ( font ) ; // layout in one line Rectangle vbounds = _target . getViewBounds ( ) ; label . setTargetWidth ( vbounds . width - PAD * 2 ) ; label . layout ( gfx ) ; Dimension d = label . getSize ( ) ; // if the label is wide enough, try to split the text into multiple // lines if ( d . width > MINIMUM_SPLIT_WIDTH ) { int targetheight = getGoldenLabelHeight ( d ) ; if ( targetheight > 1 ) { label . setTargetHeight ( targetheight * d . height ) ; label . layout ( gfx ) ; } } return label ; }
Get a label formatted as close to the golden ratio as possible for the specified text and given the standard padding we use on all bubbles .