List of usage examples for org.jfree.graphics2d.svg SVGGraphics2D create
@Override
public Graphics create()
From source file:fr.amap.commons.javafx.chart.ChartViewer.java
/** * A handler for the export to SVG option in the context menu. *///from w w w .j av a2 s. c o m private void handleExportToSVG() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to SVG"); fileChooser.setSelectedExtensionFilter( new FileChooser.ExtensionFilter("Scalable Vector Graphics (SVG)", "svg")); File file = fileChooser.showSaveDialog(stage); if (file != null) { CanvasPositionsAndSize canvasPositionAndSize = getCanvasPositionAndSize(); SVGGraphics2D sVGGraphics2D = new SVGGraphics2D((int) canvasPositionAndSize.totalWidth, (int) canvasPositionAndSize.totalHeight); Graphics2D graphics2D = (Graphics2D) sVGGraphics2D.create(); int index = 0; for (ChartCanvas canvas : chartCanvasList) { ((Drawable) canvas.chart).draw(graphics2D, canvasPositionAndSize.positionsAndSizes.get(index)); index++; } try { SVGUtils.writeToSVG(file, sVGGraphics2D.getSVGElement()); } catch (IOException ex) { Logger.getLogger(ChartViewer.class.getName()).log(Level.SEVERE, null, ex); } } }