DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
doc = domImpl.createDocument(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SVG_TAG, null);
} else doc = output.getDocument();
// Render GVT tree into document.
SVGGraphics2D svgGenerator = new SVGGraphics2D(
SVGGeneratorContext.createDefault(doc),
((Boolean) hints.get(KEY_TEXT_AS_SHAPES)).booleanValue());
// Get size of canvas to render into.
Dimension d = new Dimension();
d.setSize(width, height);
svgGenerator.setSVGCanvasSize(d);
// Paint the GVT tree into the SVG generator.
this.root.paint(svgGenerator);
// Output the resulting document to the output transcoder.
try {
OutputStream os = output.getOutputStream();
if (os != null) {
svgGenerator.stream(svgGenerator.getRoot(), new OutputStreamWriter(os), false, false);
return;
}
// Writer
Writer wr = output.getWriter();
if (wr != null) {
svgGenerator.stream(svgGenerator.getRoot(), wr, false, false);
return;
}
// URI
String outputuri = output.getURI();
if ( outputuri != null ){
try{
URL url = new URL(outputuri);
URLConnection urlCnx = url.openConnection();
os = urlCnx.getOutputStream();
svgGenerator.stream(svgGenerator.getRoot(), new OutputStreamWriter(os), false, false);
return;
} catch (MalformedURLException e){
handler.fatalError(new TranscoderException(e));
} catch (IOException e){
handler.fatalError(new TranscoderException(e));