Example usage for org.jfree.chart ChartPanel restoreAutoBounds

List of usage examples for org.jfree.chart ChartPanel restoreAutoBounds

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel restoreAutoBounds.

Prototype

public void restoreAutoBounds() 

Source Link

Document

Restores the auto-range calculation on both axes.

Usage

From source file:org.esa.snap.rcp.statistics.ChartPagePanel.java

private JPanel createChartBottomPanel(final ChartPanel chartPanel) {

    final AbstractButton zoomAllButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/view-fullscreen.png"), false);
    zoomAllButton.setToolTipText("Zoom all.");
    zoomAllButton.setName("zoomAllButton.");
    zoomAllButton.addActionListener(e -> {
        chartPanel.restoreAutoBounds();
        chartPanel.repaint();//from www. j  a  v a  2  s .  com
    });

    final AbstractButton propertiesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Edit24.gif"), false);
    propertiesButton.setToolTipText("Edit properties.");
    propertiesButton.setName("propertiesButton.");
    propertiesButton.addActionListener(e -> chartPanel.doEditChartProperties());

    final AbstractButton saveButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    saveButton.setToolTipText("Save chart as image.");
    saveButton.setName("saveButton.");
    saveButton.addActionListener(e -> {
        try {
            chartPanel.doSaveAs();
        } catch (IOException e1) {
            JOptionPane.showMessageDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    });

    final AbstractButton printButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Print24.gif"), false);
    printButton.setToolTipText("Print chart.");
    printButton.setName("printButton.");
    printButton.addActionListener(e -> chartPanel.createChartPrintJob());

    final TableLayout tableLayout = new TableLayout(6);
    tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
    tableLayout.setColumnWeightX(4, 1.0);
    JPanel buttonPanel = new JPanel(tableLayout);
    tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
    buttonPanel.add(zoomAllButton);
    tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
    buttonPanel.add(propertiesButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(printButton);
    buttonPanel.add(new JPanel());
    buttonPanel.add(getHelpButton());

    return buttonPanel;
}

From source file:com.philng.telemetrydisplay.GraphDisplay.java

/**
 * Build all the initial data//  w w w .  ja v a2  s.c  om
 */
public GraphDisplay() {
    voltage = new TimeSeries("Voltage");
    current = new TimeSeries("Current");

    this.setLayout(new BorderLayout());
    final JFreeChart chart = createChart(createDatasetVoltage());

    final ChartPanel chartPanel = new ChartPanel(chart);

    add(chartPanel, BorderLayout.CENTER);
    chartPanel.setVisible(true);
    setVisible(true);

    // Add a mouse listener for when the user double clicks the mousse
    // on the graph, it will reset the zoome
    ChartMouseListener cml = new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent chartMouseEvent) {
            if (chartMouseEvent.getTrigger().getClickCount() == 2) {
                chartPanel.restoreAutoBounds();
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent chartMouseEvent) {

        }
    };
    chartPanel.addChartMouseListener(cml);
}

From source file:org.esa.beam.visat.toolviews.stat.ChartPagePanel.java

private JPanel createChartBottomPanel(final ChartPanel chartPanel) {

    final AbstractButton zoomAllButton = ToolButtonFactory.createButton(
            UIUtils.loadImageIcon("/com/bc/ceres/swing/actions/icons_22x22/view-fullscreen.png"), false);
    zoomAllButton.setToolTipText("Zoom all.");
    zoomAllButton.setName("zoomAllButton.");
    zoomAllButton.addActionListener(new ActionListener() {
        @Override/* w  w  w . ja v a 2s . c o  m*/
        public void actionPerformed(ActionEvent e) {
            chartPanel.restoreAutoBounds();
            chartPanel.repaint();
        }
    });

    final AbstractButton propertiesButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Edit24.gif"), false);
    propertiesButton.setToolTipText("Edit properties.");
    propertiesButton.setName("propertiesButton.");
    propertiesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.doEditChartProperties();
        }
    });

    final AbstractButton saveButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false);
    saveButton.setToolTipText("Save chart as image.");
    saveButton.setName("saveButton.");
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                chartPanel.doSaveAs();
            } catch (IOException e1) {
                JOptionPane.showMessageDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    final AbstractButton printButton = ToolButtonFactory
            .createButton(UIUtils.loadImageIcon("icons/Print24.gif"), false);
    printButton.setToolTipText("Print chart.");
    printButton.setName("printButton.");
    printButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            chartPanel.createChartPrintJob();
        }
    });

    final TableLayout tableLayout = new TableLayout(6);
    tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL);
    tableLayout.setColumnWeightX(4, 1.0);
    JPanel buttonPanel = new JPanel(tableLayout);
    tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0));
    buttonPanel.add(zoomAllButton);
    tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0));
    buttonPanel.add(propertiesButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(printButton);
    buttonPanel.add(new JPanel());
    buttonPanel.add(getHelpButton());

    return buttonPanel;
}