Example usage for org.jfree.chart ChartPanel zoomOutDomain

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

Introduction

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

Prototype

public void zoomOutDomain(double x, double y) 

Source Link

Document

Increases the length of the domain axis, centered about the given coordinate on the screen.

Usage

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);
            }/*from w  ww  .  ja v  a2  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);
            }
        }
    };
}