{
PluginMgr.getInstance().removeInstance(modeler);
return null;
}
WorkspaceDrawingView view = new WorkspaceDrawingView(modeler);
view.setDrawing(modeler.getDrawing());
view.setScaleFactor(scaleFactor);
ImageExporter imageExporter = null;
try
{
// Generate SVG content
DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
SVGDocument svgDocument = (SVGDocument) domImpl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
// Second, create an instance of the generator.
// The generator will use the domFactory to create the various SVG elements.
SVGGraphics2D generator = new SVGGraphics2D(svgDocument);
int width = view.getWidth();
int height = view.getHeight();
if (width != 0 && height != 0)
{
width = CommonUtil.rnd(width * scaleFactor);
height = CommonUtil.rnd(height * scaleFactor);
generator.setSVGCanvasSize(new Dimension(width, height));
}
generator.scale(scaleFactor, scaleFactor);
// Turn on antialiasing
generator.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
generator.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
generator.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
generator.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
generator.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// Draw the image
view.drawShadow(generator);
view.drawDrawing(generator);
view.drawHandles(generator);
// Populate the document root with the generated SVG content.
generator.getRoot(svgDocument.getDocumentElement());
// Create the image
imageExporter = new ImageExporter(svgDocument, generator.getSVGCanvasSize());
}
finally
{
// Cleanup
view.unregister();
PluginMgr.getInstance().removeInstance(modeler);
}
return imageExporter;
}