use of org.apache.batik.transcoder.svg2svg.SVGTranscoder in project gephi by gephi.
the class SVGExporter method execute.
@Override
public boolean execute() {
PreviewController controller = Lookup.getDefault().lookup(PreviewController.class);
controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0);
controller.refreshPreview(workspace);
PreviewProperties props = controller.getModel(workspace).getProperties();
props.putValue(SVGTarget.SCALE_STROKES, scaleStrokes);
props.putValue(PreviewProperty.MARGIN, new Float((float) margin));
target = (SVGTarget) controller.getRenderTarget(RenderTarget.SVG_TARGET, workspace);
if (target instanceof LongTask) {
((LongTask) target).setProgressTicket(progress);
}
try {
controller.render(target, workspace);
// creates SVG-to-SVG transcoder
SVGTranscoder t = new SVGTranscoder();
t.addTranscodingHint(SVGTranscoder.KEY_XML_DECLARATION, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
// sets transcoder input and output
TranscoderInput input = new TranscoderInput(target.getDocument());
// performs transcoding
try {
TranscoderOutput output = new TranscoderOutput(writer);
t.transcode(input, output);
} finally {
writer.close();
props.removeSimpleValue(PreviewProperty.MARGIN);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
Progress.finish(progress);
return !cancel;
}
Aggregations