private static IRenderingElement recolor ( IRenderingElement element , Color color ) { if ( element instanceof ElementGroup ) { ElementGroup orgGroup = ( ElementGroup ) element ; ElementGroup newGroup = new ElementGroup ( ) ; for ( IRenderingElement child : orgGroup ) { newGroup . add ( recolor ( child , color ) ) ; } return newGroup ; } else if ( element instanceof LineElement ) { LineElement lineElement = ( LineElement ) element ; return new LineElement ( lineElement . firstPointX , lineElement . firstPointY , lineElement . secondPointX , lineElement . secondPointY , lineElement . width , color ) ; } else if ( element instanceof GeneralPath ) { return ( ( GeneralPath ) element ) . recolor ( color ) ; } throw new IllegalArgumentException ( "Cannot highlight rendering element, " + element . getClass ( ) ) ; }
Recolor a rendering element after it has been generated . Since rendering elements are immutable the input element remains unmodified .