Java Code Examples for org.jfree.chart.util.ExportUtils#writeAsSVG()

The following examples show how to use org.jfree.chart.util.ExportUtils#writeAsSVG() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartViewer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 2
Source File: ChartViewer.java    From jfreechart-fx with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
private void handleExportToSVG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to SVG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Scalable Vector Graphics (SVG)", "*.svg");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.canvas.getChart(), (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 3
Source File: TaChartViewer.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
private void handleExportToSVG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to SVG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Scalable Vector Graphics (SVG)", "svg");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.canvas.getChart(), (int) getWidth(),
                (int) getHeight(), file);
    }
}
 
Example 4
Source File: ChartViewer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 5
Source File: ChartViewer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 6
Source File: ChartViewer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 7
Source File: ChartViewer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 8
Source File: ChartViewer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to SVG option in the context menu.
 */
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(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsSVG(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    }
}
 
Example 9
Source File: JFreeChartUtils.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public static void exportToImageFile(ChartViewer chartNode, File file, ImgFileType fileType) {

    final JFreeChart chart = chartNode.getChart();
    final int width = (int) chartNode.getWidth();
    final int height = (int) chartNode.getHeight();

    try {

      switch (fileType) {

        case JPG:
          ExportUtils.writeAsJPEG(chart, width, height, file);
          break;

        case PNG:
          ExportUtils.writeAsPNG(chart, width, height, file);
          break;

        case SVG:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsSVG(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case PDF:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsPDF(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EMF:
          FileOutputStream out2 = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EMFGraphics2D g2d2 = new EMFGraphics2D(out2, new Dimension(width, height));
          g2d2.startExport();
          chart.draw(g2d2, new Rectangle(width, height));
          g2d2.endExport();
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EPS:
          FileOutputStream out = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
          g2d.setGraphicContext(new GraphicContext());
          g2d.setupDocument(out, width, height);
          chart.draw(g2d, new Rectangle(width, height));
          g2d.finish();
          setDrawSeriesLineAsPath(chart, false);
          out.close();
          break;

      }

    } catch (IOException e) {
      MZmineGUI.displayMessage("Unable to save image: " + e.getMessage());
      e.printStackTrace();
    }
  }