use of org.apache.batik.svggen.SVGGeneratorContext.GraphicContextDefaults in project freeplane by freeplane.
the class ExportVectorGraphic method fillSVGGraphics2D.
/**
*/
protected SVGGraphics2D fillSVGGraphics2D(final MapView view) {
// work around svg/pdf-Export problems when exporting with Gtk or Nimbus L&Fs
final String previousLnF = UIManager.getLookAndFeel().getClass().getName();
setLnF(view, UIManager.getCrossPlatformLookAndFeelClassName());
try {
final DOMImplementation impl = GenericDOMImplementation.getDOMImplementation();
final String namespaceURI = SVGConstants.SVG_NAMESPACE_URI;
final Document domFactory = impl.createDocument(namespaceURI, "svg", null);
final SVGGeneratorContext ctx = createGeneratorContext(domFactory);
final GraphicContextDefaults defaults = new GraphicContextDefaults();
defaults.setFont(new Font("Arial", Font.PLAIN, 12));
ctx.setGraphicContextDefaults(defaults);
ctx.setExtensionHandler(new GradientExtensionHandler());
ctx.setPrecision(12);
final SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
view.preparePrinting();
final Rectangle innerBounds = view.getInnerBounds();
g2d.setSVGCanvasSize(new Dimension(innerBounds.width, innerBounds.height));
g2d.translate(-innerBounds.x, -innerBounds.y);
view.print(g2d);
view.endPrinting();
return g2d;
} finally {
setLnF(view, previousLnF);
}
}
Aggregations