private static void applyShapeStyle ( Element element , ShapeStyle style ) { // First check the presence of the fill and stroke elements: NodeList < Element > fills = element . getElementsByTagName ( "fill" ) ; if ( fills . getLength ( ) == 0 ) { Element stroke = Dom . createElementNS ( Dom . NS_VML , "stroke" ) ; element . appendChild ( stroke ) ; Element fill = Dom . createElementNS ( Dom . NS_VML , "fill" ) ; element . appendChild ( fill ) ; fills = element . getElementsByTagName ( "fill" ) ; } // Then if fill-color then filled=true: if ( style . getFillColor ( ) != null ) { element . setAttribute ( "filled" , "true" ) ; fills . getItem ( 0 ) . setAttribute ( "color" , style . getFillColor ( ) ) ; fills . getItem ( 0 ) . setAttribute ( "opacity" , Float . toString ( style . getFillOpacity ( ) ) ) ; } else { element . setAttribute ( "filled" , "false" ) ; } // Then if stroke-color then stroke=true: if ( style . getStrokeColor ( ) != null ) { element . setAttribute ( "stroked" , "true" ) ; NodeList < Element > strokes = element . getElementsByTagName ( "stroke" ) ; strokes . getItem ( 0 ) . setAttribute ( "color" , style . getStrokeColor ( ) ) ; strokes . getItem ( 0 ) . setAttribute ( "opacity" , Float . toString ( style . getStrokeOpacity ( ) ) ) ; element . setAttribute ( "strokeweight" , Float . toString ( style . getStrokeWidth ( ) ) ) ; } else { element . setAttribute ( "stroked" , "false" ) ; } }
When applying ShapeStyles we create child elements for fill and stroke . According to Microsoft this is the proper way to go .