Example usage for org.jfree.chart ChartPanel getMinimumDrawWidth

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

Introduction

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

Prototype

public int getMinimumDrawWidth() 

Source Link

Document

Returns the minimum drawing width for charts.

Usage

From source file:ec.util.chart.swing.Charts.java

public static void copyChart(@Nonnull ChartPanel chartPanel) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Insets insets = chartPanel.getInsets();
    int w = chartPanel.getWidth() - insets.left - insets.right;
    int h = chartPanel.getHeight() - insets.top - insets.bottom;
    Transferable selection = new ChartTransferable2(chartPanel.getChart(), w, h,
            chartPanel.getMinimumDrawWidth(), chartPanel.getMinimumDrawHeight(),
            chartPanel.getMaximumDrawWidth(), chartPanel.getMaximumDrawHeight(), true);
    clipboard.setContents(selection, null);
}

From source file:com.vgi.mafscaling.MafChartPanel.java

private void zoomChartAxis(ChartPanel chart, boolean increase) {
    int width = chart.getMaximumDrawWidth() - chart.getMinimumDrawWidth();
    int height = chart.getMaximumDrawHeight() - chart.getMinimumDrawWidth();
    if (increase)
        chart.zoomInBoth(width / 2, height / 2);
    else/*from w  w w.ja va  2  s  .  c  om*/
        chart.zoomOutBoth(width / 2, height / 2);
}

From source file:api3.transform.PlotWave.java

private MouseWheelListener addZoomWheel() {
    return new MouseWheelListener() {
        private void zoomChartAxis(ChartPanel chartP, boolean increase) {
            int width = chartP.getMaximumDrawWidth() - chartP.getMinimumDrawWidth();
            int height = chartP.getMaximumDrawHeight() - chartP.getMinimumDrawWidth();
            if (increase) {
                chartP.zoomInDomain(width / 2, height / 2);
            } else {
                chartP.zoomOutDomain(width / 2, height / 2);
            }/* w  w  w  .  j  a v  a  2 s. c  o m*/
            lastValue = SLIDER_DEFAULT_VALUE;
            slider.setValue(lastValue);

        }

        public synchronized void decreaseZoom(JComponent chart, boolean saveAction) {
            ChartPanel ch = (ChartPanel) chart;
            zoomChartAxis(ch, false);
        }

        public synchronized void increaseZoom(JComponent chart, boolean saveAction) {
            ChartPanel ch = (ChartPanel) chart;
            zoomChartAxis(ch, true);
        }

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() != MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                return;
            }
            if (e.getWheelRotation() < 0) {
                increaseZoom((ChartPanel) e.getComponent(), true);
            } else {
                decreaseZoom((ChartPanel) e.getComponent(), true);
            }
        }
    };
}