Example usage for org.jfree.chart.editor ChartEditorManager getChartEditor

List of usage examples for org.jfree.chart.editor ChartEditorManager getChartEditor

Introduction

In this page you can find the example usage for org.jfree.chart.editor ChartEditorManager getChartEditor.

Prototype

public static ChartEditor getChartEditor(JFreeChart chart) 

Source Link

Document

Returns a component that can be used to edit the given chart.

Usage

From source file:daylightchart.options.chart.BaseChartOptions.java

/**
 * Gets a chart editor that has preset options.
 *
 * @return Chart editor.//from   w ww. ja va  2s .  c o m
 */
public final ChartEditor getChartEditor() {
    updateChart(chart);
    return ChartEditorManager.getChartEditor(chart);
}

From source file:org.nuclos.client.layout.wysiwyg.component.properties.PropertyChartPropertyGeneralStep.java

@Override
public void prepare() {
    super.prepare();

    chart = model.getChart();// w w  w  .  ja  v  a 2 s  . co m
    chartEditor = ChartEditorManager.getChartEditor(chart);

    try {
        jTabbedPanels = getChartFunction().getCustomPlotEditorPanels(model.getWYSIWYGChart().getChart());
        if (jTabbedPanels.length > 0) {
            JPanel editor = (JPanel) UIUtils.findFirstJComponent((JPanel) chartEditor,
                    (Class) Class.forName("org.jfree.chart.editor.DefaultPlotEditor"));
            JTabbedPane tab = (JTabbedPane) UIUtils.findFirstJComponent(editor, JTabbedPane.class);

            if (getChartFunction().isCombinedChart())
                tab.removeAll();

            for (int i = 0; i < jTabbedPanels.length; i++) {
                JTabbedPanel jTabbedPanel = jTabbedPanels[i];
                if (getChartFunction().isCombinedChart())
                    tab.insertTab(jTabbedPanel.getTitle(), null, jTabbedPanel, null, i);
                else
                    tab.insertTab(jTabbedPanel.getTitle(), null, jTabbedPanel, null, tab.getTabCount());
            }
            tab.setSelectedIndex(0);
        }
    } catch (Exception e) {
        e.printStackTrace();
        // ignore.
    }
}

From source file:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java

public VGraphUI() {

    VHintButton zoomIn = new VHintButton(VIcons.ZOOM_IN);
    menu.add(zoomIn);//w ww . ja v  a 2 s. c om
    zoomIn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            VGraphCell cell = selectedCell;

            Object o = cell.getUserObject();

            if (o != null && o instanceof VChartPanel) {
                VChartPanel chart = (VChartPanel) o;

                chart.zoomInBoth(0, 0);
                graph.repaint();
            }
        }
    });

    VHintButton zoomOut = new VHintButton(VIcons.ZOOM_OUT);
    menu.add(zoomOut);
    zoomOut.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            VGraphCell cell = selectedCell;

            Object o = cell.getUserObject();

            if (o != null && o instanceof VChartPanel) {
                VChartPanel chart = (VChartPanel) o;

                chart.zoomOutBoth(0, 0);
                graph.repaint();
            }
        }
    });

    VHintButton settings = new VHintButton(VIcons.APPLICATION_FORM_EDIT);
    menu.add(settings);
    settings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            VGraphCell cell = selectedCell;

            Object o = cell.getUserObject();

            if (o != null && o instanceof VChartPanel) {
                VChartPanel chart = (VChartPanel) o;

                ChartEditor editor = ChartEditorManager.getChartEditor(chart.getChart());
                int result = JOptionPane.showConfirmDialog(graph.getParent(), editor, "Chart_Properties",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
                if (result == JOptionPane.OK_OPTION) {
                    editor.updateChart(chart.getChart());
                    graph.repaint();
                }
            }
        }
    });

    VHintButton legend = new VHintButton(VIcons.BRICKS);
    menu.add(legend);
    legend.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {

            VGraphCell cell = selectedCell;

            Object o = cell.getUserObject();

            if (o != null && o instanceof VChartPanel) {
                VChartPanel chart = (VChartPanel) o;

                VLegend legend = new VLegend(chart.getChart());

                JPopupMenu menu = new JPopupMenu();
                menu.add(legend);

                menu.show(graph, 0, 0);
            }
        }
    });
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Initialize the menu/toolbar actions./*w w w  .  j  a v  a2  s.  c  o  m*/
 */
private void initActions() {

    final JFrame glue = this;

    actionFileExit = new FHAESAction("Close", "close.png") { //$NON-NLS-1$

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            dispose();
        }
    };

    actionChartProperties = new FHAESAction("Chart properties", "properties.png") { //$NON-NLS-1$

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            ChartEditor editor = ChartEditorManager
                    .getChartEditor(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart());
            int result = JOptionPane.showConfirmDialog(glue, editor, "Properties", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
            if (result == JOptionPane.OK_OPTION) {
                editor.updateChart(jsea.getChartList().get(segmentComboBox.getSelectedIndex()).getChart());
            }
        }
    };

    actionReset = new FHAESAction("Reset", "filenew.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            Object[] options = { "Yes", "No", "Cancel" };
            int n = JOptionPane.showOptionDialog(glue, "Are you sure you want to start a new analysis?",
                    "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
                    options[2]);

            if (n == JOptionPane.YES_OPTION) {
                setToDefault();
            }
        }
    };

    actionRun = new FHAESAction("Run analysis", "run.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            runAnalysis();
        }
    };

    actionSaveAll = new FHAESAction("Save all results", "save_all.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            File f;
            try {
                f = new File(file.getAbsolutePath() + File.separator + "report.txt");
                saveReportTXT(f);

                f = new File(file.getAbsolutePath() + File.separator + "report.pdf");
                saveReportPDF(f);

                f = new File(file.getAbsolutePath() + File.separator + "chart.png");
                saveChartPNG(f);

                f = new File(file.getAbsolutePath() + File.separator + "chart.pdf");
                saveChartPDF(f);

                f = new File(file.getAbsolutePath() + File.separator + "data.xls");
                saveDataXLS(f);

                f = new File(file.getAbsolutePath());
                saveDataCSV(f);

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    actionSaveData = new FHAESAction("Save data tables", "table.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            try {
                saveDataCSV(file);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    actionSaveReport = new FHAESAction("Save report", "report.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            // Set file filters
            fc.setAcceptAllFileFilterUsed(false);
            TXTFileFilter txtfilter = new TXTFileFilter();
            PDFFilter pdffilter = new PDFFilter();
            fc.addChoosableFileFilter(txtfilter);
            fc.addChoosableFileFilter(pdffilter);
            fc.setFileFilter(txtfilter);
            FileFilter chosenFilter;

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                chosenFilter = fc.getFileFilter();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            // Handle file type and extensions nicely
            if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) {
                if (chosenFilter.equals(txtfilter)) {
                    file = new File(file.getAbsoluteFile() + ".txt");
                } else if (chosenFilter.equals(pdffilter)) {
                    file = new File(file.getAbsoluteFile() + ".pdf");
                }
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("txt")
                    && chosenFilter.equals("pdf")) {
                chosenFilter = txtfilter;
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf")
                    && chosenFilter.equals("txt")) {
                chosenFilter = pdffilter;
            }

            // If file already exists confirm overwrite
            if (file.exists()) {
                // Check we have write access to this file
                if (!file.canWrite()) {
                    JOptionPane.showMessageDialog(glue, "You do not have write permission to this file",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                int n = JOptionPane.showConfirmDialog(glue,
                        "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?",
                        "Overwrite file?", JOptionPane.YES_NO_OPTION);
                if (n != JOptionPane.YES_OPTION) {
                    return;
                }
            }

            // Do save
            try {

                if (chosenFilter.equals(txtfilter)) {
                    saveReportTXT(file);
                } else if (chosenFilter.equals(pdffilter)) {
                    saveReportPDF(file);
                } else {
                    log.error("No export file format chosen.  Shouldn't be able to get here!");
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(glue, "Unable to save report.  Check log file.", "Warning",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }

        }
    };

    actionSaveChart = new FHAESAction("Save chart", "barchart.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            if (jsea == null)
                return;

            File file;
            JFileChooser fc;

            // Open file chooser in last folder if possible
            if (App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null) != null) {
                fc = new JFileChooser(App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null));
            } else {
                fc = new JFileChooser();
            }

            // Set file filters
            fc.setAcceptAllFileFilterUsed(false);
            PNGFilter pngfilter = new PNGFilter();
            PDFFilter pdffilter = new PDFFilter();
            fc.addChoosableFileFilter(pngfilter);
            fc.addChoosableFileFilter(pdffilter);
            fc.setFileFilter(pngfilter);
            FileFilter chosenFilter;

            // Show dialog and get specified file
            int returnVal = fc.showSaveDialog(glue);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                file = fc.getSelectedFile();
                chosenFilter = fc.getFileFilter();
                App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, file.getAbsolutePath());
            } else {
                return;
            }

            // Handle file type and extensions nicely
            if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("")) {
                if (chosenFilter.equals(pngfilter)) {
                    file = new File(file.getAbsoluteFile() + ".png");
                } else if (chosenFilter.equals(pdffilter)) {
                    file = new File(file.getAbsoluteFile() + ".pdf");
                }
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("png")
                    && chosenFilter.equals("pdf")) {
                chosenFilter = pngfilter;
            } else if (FilenameUtils.getExtension(file.getAbsolutePath()).toLowerCase().equals("pdf")
                    && chosenFilter.equals("png")) {
                chosenFilter = pdffilter;
            }

            // If file already exists confirm overwrite
            if (file.exists()) {
                // Check we have write access to this file
                if (!file.canWrite()) {
                    JOptionPane.showMessageDialog(glue, "You do not have write permission to this file",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                int n = JOptionPane.showConfirmDialog(glue,
                        "File: " + file.getName() + " already exists. " + "Would you like to overwrite it?",
                        "Overwrite file?", JOptionPane.YES_NO_OPTION);
                if (n != JOptionPane.YES_OPTION) {
                    return;
                }
            }

            // Do save
            try {

                if (chosenFilter.equals(pngfilter)) {
                    saveChartPNG(file);

                } else if (chosenFilter.equals(pdffilter)) {

                    saveChartPDF(file);
                } else {
                    log.error("No export file format chosen.  Shouldn't be able to get here!");
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(glue, "Unable to save chart.  Check log file.", "Warning",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }

        }
    };

    actionCopy = new FHAESAction("Copy", "edit_copy.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            copyCurrentSelectionToClipboard();
        }
    };

    actionLagMap = new FHAESAction("LagMap", "lagmap22.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            launchLagMap();
        }
    };

}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Displays a dialog that allows the user to edit the properties for the current chart.
 * /*from w  w  w . j a  va2 s .com*/
 * @since 1.0.3
 */
public void doEditChartProperties() {
    ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(this.chart);
    }

}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Displays a dialog that allows the user to edit the properties for the
 * current chart.//from w w w  . j a v a2s .  com
 *
 * @since 1.0.3
 */
public void doEditChartProperties() {

    ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(this.chart);
    }

}

From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java

/**
 * Displays a dialog that allows the user to edit the properties for the current chart.
 * /*from  w ww.j  a va  2 s .  c  o m*/
 * @since 1.0.3
 */

@Override
public void doEditChartProperties() {

    ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(this.chart);
    }

}