>
> However I think you would be _much_ better off passing
> the DOM that the svgGenerator builds directly to the Transcoder
> (TranscoderInput will take a document). To get the
> document you want to do something like:
>
>
> // The following populates the document root with the
> // generated SVG content.
> Element root = document.getDocumentElement();
> svgGenerator.getRoot(root);
I've tried this (see below), but I keep getting a ClassCastException :(
java.lang.ClassCastException
at org.apache.batik.dom.svg.SVGOMDocument.getRootElement(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown
Source)
at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown
Source)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown
Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown
Source)
at
trs.visualisation.persistence.ExportVisualisation.transcode(ExportVisualisat
ion.java:323)
at
trs.visualisation.persistence.ExportVisualisation.exportToJPG(ExportVisualis
ation.java:151)
What am I doing wrong now?
Thanks in advance,
Brecht
private static void transcode(Visualisation vis, File file, ImageTranscoder
t, Dimension dim) throws IOException {
logger.debug("");
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
Document document = domImpl.createDocument(null, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
ctx.setComment("Generated by Trs-visualisation");
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
svgGenerator.setSVGCanvasSize(dim);
vis.render(svgGenerator, new Double(dim.getWidth()).intValue(), new
Double(dim.getHeight()).intValue(), null);
Element root = document.getDocumentElement();
svgGenerator.getRoot(root);
TranscoderInput input = new TranscoderInput(document);
OutputStream ostream = null;
try {
ostream = new FileOutputStream(file);
} catch (FileNotFoundException e3) {
logger.error(e3);
}
TranscoderOutput output = new TranscoderOutput(ostream);
try {
t.transcode(input, output);
} catch (TranscoderException e1) {
logger.error(e1);
}
ostream.flush();
ostream.close();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]