Hello all,
I'm sorry for asking this question once more, but I'm really having trouble
rotating an existing SVG document.
The purpose is to load an SVG file, rotate it about the centerpoint and then
transcode it.
I got the process sort of working except for the rotation.
Here's the code (questions below)
private final SVGDocument svgDocument;
// Load the SVG file.
SAXSVGDocumentFactory factory = new
SAXSVGDocumentFactory(SAXParser.class.getCanonicalName());
svgDocument = (SVGDocument) factory.createDocument(url.toString());
SVGGraphics2D engine = new SVGGraphics2D(svgDocument);
// 90ยบ rotation
engine.rotate(Math.Pi / 2);
Element root = svgDocument.getDocumentElement();
root.appendChild(engine.getRoot());
// Transcode.
PNGTranscoder trans = new PNGTranscoder();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
trans.transcode(new TranscoderInput(svgDocument), new
TranscoderOutput(outputStream));
My questions are:
1) If I invoke a engine.stream() I get an empty document. It
just contains (roughly) <SVG><G/></SVG> (plus a defs element and some styling
attributes).
2) To proper rotate the document I'd need to translat it to the
origin. Thing is, how may I obtain the dimensions and height of the canvas? I
tried engine.getDimension() but it returns null.
Additionally, the output of this bit of code is the original file transcoded to
PNG. Which means that the original svgDocument was not changed (with or without
rotation).
Any help would be greatly appreciated.
Best retards,
Tiago Matias