Example usage for org.jfree.chart.ui ChartPropertyEditPanel updateChartProperties

List of usage examples for org.jfree.chart.ui ChartPropertyEditPanel updateChartProperties

Introduction

In this page you can find the example usage for org.jfree.chart.ui ChartPropertyEditPanel updateChartProperties.

Prototype

public void updateChartProperties(JFreeChart chart) 

Source Link

Document

Updates the properties of a chart to match the properties defined on the panel.

Usage

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

/**
 * Handles an action event.//  www  .j av a2s .  com
 * 
 * @param evt
 *            the event.
 */
public void actionPerformed(ActionEvent evt) {
    try {
        String acmd = evt.getActionCommand();

        if (acmd.equals(ACTION_CHART_ZOOM_BOX)) {
            setPanMode(false);
        } else if (acmd.equals(ACTION_CHART_PAN)) {
            setPanMode(true);
        } else if (acmd.equals(ACTION_CHART_ZOOM_IN)) {
            ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
            Rectangle2D rect = info.getPlotInfo().getDataArea();
            zoomBoth(rect.getCenterX(), rect.getCenterY(), ZOOM_FACTOR);
        } else if (acmd.equals(ACTION_CHART_ZOOM_OUT)) {
            ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
            Rectangle2D rect = info.getPlotInfo().getDataArea();
            zoomBoth(rect.getCenterX(), rect.getCenterY(), 1 / ZOOM_FACTOR);
        } else if (acmd.equals(ACTION_CHART_ZOOM_TO_FIT)) {

            // X-axis (has no fixed borders)
            chartPanel.autoRangeHorizontal();
            Plot plot = chartPanel.getChart().getPlot();
            if (plot instanceof ValueAxisPlot) {
                XYPlot vvPlot = (XYPlot) plot;
                ValueAxis axis = vvPlot.getRangeAxis();
                if (axis != null) {
                    axis.setLowerBound(yMin);
                    axis.setUpperBound(yMax);
                }
            }
        } else if (acmd.equals(ACTION_CHART_EXPORT)) {
            try {
                chartPanel.doSaveAs();
            } catch (IOException i) {
                MsgBox.error(i.getMessage());
            }
        } else if (acmd.equals(ACTION_CHART_PRINT)) {
            chartPanel.createChartPrintJob();

        } else if (acmd.equals(ACTION_CHART_PROPERTIES)) {
            ChartPropertyEditPanel panel = new ChartPropertyEditPanel(jFreeChart);
            int result = JOptionPane.showConfirmDialog(this, panel,
                    localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
            if (result == JOptionPane.OK_OPTION) {
                panel.updateChartProperties(jFreeChart);
            }
        }

    } catch (Exception e) {
        MsgBox.error(e.getMessage());
    }
}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

/**
 * Displays a dialog that allows the user to edit the properties for the
 * current chart.//from ww  w  .  j  a  v a 2s  .c  o m
 */
private void attemptEditChartProperties() {

    ChartPropertyEditPanel panel = new ChartPropertyEditPanel(chart);
    int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Chart_Properties"),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        panel.updateChartProperties(chart);
    }
}