public static void addLightGradient ( SVGPlot svgp ) { Element gradient = svgp . getIdElement ( LIGHT_GRADIENT_ID ) ; if ( gradient == null ) { gradient = svgp . svgElement ( SVGConstants . SVG_LINEAR_GRADIENT_TAG ) ; gradient . setAttribute ( SVGConstants . SVG_ID_ATTRIBUTE , LIGHT_GRADIENT_ID ) ; gradient . setAttribute ( SVGConstants . SVG_X1_ATTRIBUTE , "0" ) ; gradient . setAttribute ( SVGConstants . SVG_Y1_ATTRIBUTE , "0" ) ; gradient . setAttribute ( SVGConstants . SVG_X2_ATTRIBUTE , "0" ) ; gradient . setAttribute ( SVGConstants . SVG_Y2_ATTRIBUTE , "1" ) ; Element stop0 = svgp . svgElement ( SVGConstants . SVG_STOP_TAG ) ; stop0 . setAttribute ( SVGConstants . SVG_STOP_COLOR_ATTRIBUTE , "white" ) ; stop0 . setAttribute ( SVGConstants . SVG_STOP_OPACITY_ATTRIBUTE , "1" ) ; stop0 . setAttribute ( SVGConstants . SVG_OFFSET_ATTRIBUTE , "0" ) ; gradient . appendChild ( stop0 ) ; Element stop04 = svgp . svgElement ( SVGConstants . SVG_STOP_TAG ) ; stop04 . setAttribute ( SVGConstants . SVG_STOP_COLOR_ATTRIBUTE , "white" ) ; stop04 . setAttribute ( SVGConstants . SVG_STOP_OPACITY_ATTRIBUTE , "0" ) ; stop04 . setAttribute ( SVGConstants . SVG_OFFSET_ATTRIBUTE , ".4" ) ; gradient . appendChild ( stop04 ) ; Element stop06 = svgp . svgElement ( SVGConstants . SVG_STOP_TAG ) ; stop06 . setAttribute ( SVGConstants . SVG_STOP_COLOR_ATTRIBUTE , "black" ) ; stop06 . setAttribute ( SVGConstants . SVG_STOP_OPACITY_ATTRIBUTE , "0" ) ; stop06 . setAttribute ( SVGConstants . SVG_OFFSET_ATTRIBUTE , ".6" ) ; gradient . appendChild ( stop06 ) ; Element stop1 = svgp . svgElement ( SVGConstants . SVG_STOP_TAG ) ; stop1 . setAttribute ( SVGConstants . SVG_STOP_COLOR_ATTRIBUTE , "black" ) ; stop1 . setAttribute ( SVGConstants . SVG_STOP_OPACITY_ATTRIBUTE , ".5" ) ; stop1 . setAttribute ( SVGConstants . SVG_OFFSET_ATTRIBUTE , "1" ) ; gradient . appendChild ( stop1 ) ; svgp . getDefs ( ) . appendChild ( gradient ) ; svgp . putIdElement ( LIGHT_GRADIENT_ID , gradient ) ; } }
Static method to prepare a SVG document for light gradient effects .