public static SVGGraphics2D createSvgGraphics ( final Dimension size ) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; Document document = db . getDOMImplementation ( ) . createDocument ( null , "svg" , null ) ; SVGGeneratorContext ctx = SVGGeneratorContext . createDefault ( document ) ; ctx . setStyleHandler ( new OpacityAdjustingStyleHandler ( ) ) ; ctx . setComment ( "Generated by GeoTools2 with Batik SVG Generator" ) ; SVGGraphics2D g2d = new SVGGraphics2D ( ctx , true ) ; g2d . setSVGCanvasSize ( size ) ; return g2d ; }
Create a SVG graphic with the give dimensions .