EPS, PDF, SVG;
}
public static void saveVectorGraphic(Chart chart, String fileName, VectorGraphicsFormat vectorGraphicsFormat) throws IOException {
VectorGraphics2D g = null;
switch (vectorGraphicsFormat) {
case EPS:
g = new EPSGraphics2D(0.0, 0.0, chart.getWidth(), chart.getHeight());
break;
case PDF:
g = new PDFGraphics2D(0.0, 0.0, chart.getWidth(), chart.getHeight());
break;
case SVG:
g = new SVGGraphics2D(0.0, 0.0, chart.getWidth(), chart.getHeight());
break;
default:
break;
}
chart.paint(g, chart.getWidth(), chart.getHeight());
// Write the vector graphic output to a file
FileOutputStream file = new FileOutputStream(fileName + "." + vectorGraphicsFormat.toString().toLowerCase());
try {
file.write(g.getBytes());
} finally {
file.close();
}
}