protected void doAttributes ( AttributedCharacterIterator iter ) { underline = false ; Set set = iter . getAttributes ( ) . keySet ( ) ; for ( Iterator iterator = set . iterator ( ) ; iterator . hasNext ( ) ; ) { AttributedCharacterIterator . Attribute attribute = ( AttributedCharacterIterator . Attribute ) iterator . next ( ) ; if ( ! ( attribute instanceof TextAttribute ) ) { continue ; } TextAttribute textattribute = ( TextAttribute ) attribute ; if ( textattribute . equals ( TextAttribute . FONT ) ) { Font font = ( Font ) iter . getAttributes ( ) . get ( textattribute ) ; setFont ( font ) ; } else if ( textattribute . equals ( TextAttribute . UNDERLINE ) ) { if ( TextAttribute . UNDERLINE_ON . equals ( iter . getAttributes ( ) . get ( textattribute ) ) ) { underline = true ; } } else if ( textattribute . equals ( TextAttribute . SIZE ) ) { Object obj = iter . getAttributes ( ) . get ( textattribute ) ; if ( obj instanceof Integer ) { int i = ( ( Integer ) obj ) . intValue ( ) ; setFont ( getFont ( ) . deriveFont ( getFont ( ) . getStyle ( ) , i ) ) ; } else if ( obj instanceof Float ) { float f = ( ( Float ) obj ) . floatValue ( ) ; setFont ( getFont ( ) . deriveFont ( getFont ( ) . getStyle ( ) , f ) ) ; } } else if ( textattribute . equals ( TextAttribute . FOREGROUND ) ) { setColor ( ( Color ) iter . getAttributes ( ) . get ( textattribute ) ) ; } else if ( textattribute . equals ( TextAttribute . FAMILY ) ) { Font font = getFont ( ) ; Map fontAttributes = font . getAttributes ( ) ; fontAttributes . put ( TextAttribute . FAMILY , iter . getAttributes ( ) . get ( textattribute ) ) ; setFont ( font . deriveFont ( fontAttributes ) ) ; } else if ( textattribute . equals ( TextAttribute . POSTURE ) ) { Font font = getFont ( ) ; Map fontAttributes = font . getAttributes ( ) ; fontAttributes . put ( TextAttribute . POSTURE , iter . getAttributes ( ) . get ( textattribute ) ) ; setFont ( font . deriveFont ( fontAttributes ) ) ; } else if ( textattribute . equals ( TextAttribute . WEIGHT ) ) { Font font = getFont ( ) ; Map fontAttributes = font . getAttributes ( ) ; fontAttributes . put ( TextAttribute . WEIGHT , iter . getAttributes ( ) . get ( textattribute ) ) ; setFont ( font . deriveFont ( fontAttributes ) ) ; } } }
This routine goes through the attributes and sets the font before calling the actual string drawing routine