Java Code Examples for org.jfree.chart.util.ExportUtils

The following examples show how to use org.jfree.chart.util.ExportUtils. These examples are extracted from open source projects. 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 Project: openstock   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 2
Source Project: openstock   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 3
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to PNG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "*.png");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.canvas.getChart(), (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
            throw new RuntimeException(ex);
        }
    }        
}
 
Example 4
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to JPEG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("JPEG", "*.jpg");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.canvas.getChart(), (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
            throw new RuntimeException(ex);
        }
    }        
}
 
Example 5
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to PNG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.canvas.getChart(), (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}
 
Example 6
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to JPEG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("JPEG", "jpg");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.canvas.getChart(), (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
            throw new RuntimeException(ex);
        }
    }
}
 
Example 7
Source Project: ccu-historian   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 8
Source Project: ccu-historian   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 9
Source Project: SIMVA-SoS   Source File: ChartViewer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 10
Source Project: SIMVA-SoS   Source File: ChartViewer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 11
Source Project: ECG-Viewer   Source File: ChartViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 12
Source Project: ECG-Viewer   Source File: ChartViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 13
Source Project: buffer_bci   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 14
Source Project: buffer_bci   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 15
Source Project: buffer_bci   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 16
Source Project: buffer_bci   Source File: ChartViewer.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to JPEG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "JPEG", "jpg"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.chart, (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
        }
    }        
}
 
Example 17
Source Project: openstock   Source File: ChartViewer.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "pdf"));
    fileChooser.setTitle("Export to PDF");
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    } 
}
 
Example 18
Source Project: openstock   Source File: ChartViewer.java    License: 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 19
/**
 * Creates the context menu.
 * 
 * @return The context menu.
 */
private ContextMenu createContextMenu() {
    final ContextMenu menu = new ContextMenu();
    menu.setAutoHide(true);
    Menu export = new Menu("Export As");
    
    MenuItem pngItem = new MenuItem("PNG...");
    pngItem.setOnAction(e -> handleExportToPNG());        
    export.getItems().add(pngItem);
    
    MenuItem jpegItem = new MenuItem("JPEG...");
    jpegItem.setOnAction(e -> handleExportToJPEG());        
    export.getItems().add(jpegItem);
    
    if (ExportUtils.isOrsonPDFAvailable()) {
        MenuItem pdfItem = new MenuItem("PDF...");
        pdfItem.setOnAction(e -> handleExportToPDF());
        export.getItems().add(pdfItem);
    }
    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction(e -> handleExportToSVG());
        export.getItems().add(svgItem);        
    }
    menu.getItems().add(export);
    return menu;
}
 
Example 20
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to PDF");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "*.pdf");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.canvas.getChart(), (int) getWidth(), 
                (int) getHeight(), file);
    } 
}
 
Example 21
/**
 * 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 22
/**
 * Creates the context menu.
 *
 * @return The context menu.
 */
private ContextMenu createContextMenu() {
    final ContextMenu menu = new ContextMenu();
    menu.setAutoHide(true);
    Menu export = new Menu("Export As");

    MenuItem pngItem = new MenuItem("PNG...");
    pngItem.setOnAction(e -> handleExportToPNG());
    export.getItems().add(pngItem);

    MenuItem jpegItem = new MenuItem("JPEG...");
    jpegItem.setOnAction(e -> handleExportToJPEG());
    export.getItems().add(jpegItem);

    if (ExportUtils.isOrsonPDFAvailable()) {
        MenuItem pdfItem = new MenuItem("PDF...");
        pdfItem.setOnAction(e -> handleExportToPDF());
        export.getItems().add(pdfItem);
    }
    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction(e -> handleExportToSVG());
        export.getItems().add(svgItem);
    }
    menu.getItems().add(export);
    return menu;
}
 
Example 23
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to PDF");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "pdf");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.canvas.getChart(), (int) getWidth(),
                (int) getHeight(), file);
    }
}
 
Example 24
/**
 * 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 25
Source Project: ccu-historian   Source File: ChartViewer.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "pdf"));
    fileChooser.setTitle("Export to PDF");
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    } 
}
 
Example 26
Source Project: ccu-historian   Source File: ChartViewer.java    License: 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 27
Source Project: SIMVA-SoS   Source File: ChartViewer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "pdf"));
    fileChooser.setTitle("Export to PDF");
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    } 
}
 
Example 28
Source Project: SIMVA-SoS   Source File: ChartViewer.java    License: 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 29
Source Project: ECG-Viewer   Source File: ChartViewer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * A handler for the export to PDF option in the context menu.
 */
private void handleExportToPDF() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter(
            "Portable Document Format (PDF)", "pdf"));
    fileChooser.setTitle("Export to PDF");
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        ExportUtils.writeAsPDF(this.chart, (int) getWidth(), 
                (int) getHeight(), file);
    } 
}
 
Example 30
Source Project: ECG-Viewer   Source File: ChartViewer.java    License: 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);
    }
}