Search in sources :

Example 1 with AxisRangeChangedListener

use of net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener in project mzmine2 by mzmine.

the class SpectralMatchPanel method coupleZoomYListener.

private void coupleZoomYListener() {
    CombinedDomainXYPlot domainPlot = (CombinedDomainXYPlot) mirrorChart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) domainPlot.getDomainAxis();
    axis.setLabel("m/z");
    queryPlot = (XYPlot) domainPlot.getSubplots().get(0);
    libraryPlot = (XYPlot) domainPlot.getSubplots().get(1);
    queryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {

        @Override
        public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
            rangeHasChanged(newR);
        }
    });
    libraryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {

        @Override
        public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
            rangeHasChanged(newR);
        }
    });
}
Also used : ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) NumberAxis(org.jfree.chart.axis.NumberAxis) AxisRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener) ValueAxis(org.jfree.chart.axis.ValueAxis) Range(org.jfree.data.Range) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot)

Example 2 with AxisRangeChangedListener

use of net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener in project mzmine2 by mzmine.

the class ChartGroup method combineAxes.

/**
 * Combines the zoom of axes of all charts
 *
 * @param chart
 */
private void combineAxes(JFreeChart chart) {
    try {
        if (combineDomainAxes && hasDomainAxis(chart)) {
            if (domainListener == null)
                domainListener = new ArrayList<>();
            AxisRangeChangedListener listener = new AxisRangeChangedListener(null) {

                @Override
                public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                    domainHasChanged(newR);
                }
            };
            domainListener.add(listener);
            chart.getXYPlot().getDomainAxis().addChangeListener(listener);
        }
        if (combineRangeAxes && hasRangeAxis(chart)) {
            if (rangeListener == null)
                rangeListener = new ArrayList<>();
            AxisRangeChangedListener listener = new AxisRangeChangedListener(null) {

                @Override
                public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                    rangeHasChanged(newR);
                }
            };
            rangeListener.add(listener);
            chart.getXYPlot().getRangeAxis().addChangeListener(listener);
        }
    } catch (Exception e) {
    }
}
Also used : ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) AxisRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener) ValueAxis(org.jfree.chart.axis.ValueAxis) ArrayList(java.util.ArrayList) Range(org.jfree.data.Range)

Example 3 with AxisRangeChangedListener

use of net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener in project mzmine2 by mzmine.

the class EChartPanel method initChartPanel.

/**
 * Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
 * Y-Axis0
 */
private void initChartPanel(boolean stickyZeroForRangeAxis) {
    final EChartPanel chartPanel = this;
    // remove old init
    if (mouseAdapter != null) {
        this.removeMouseListener(mouseAdapter);
        this.removeMouseMotionListener(mouseAdapter);
        this.removeMouseWheelListener(mouseAdapter);
    }
    if (chartPanel.getChart().getPlot() instanceof XYPlot) {
        // set sticky zero
        if (stickyZeroForRangeAxis) {
            ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
            if (rangeAxis instanceof NumberAxis) {
                NumberAxis axis = (NumberAxis) rangeAxis;
                axis.setAutoRangeIncludesZero(true);
                axis.setAutoRange(true);
                axis.setAutoRangeStickyZero(true);
                axis.setRangeType(RangeType.POSITIVE);
            }
        }
        Plot p = getChart().getPlot();
        if (addZoomHistory && (p instanceof XYPlot) && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
            // zoom history
            zoomHistory = new ZoomHistory(this, 20);
            // axis range changed listener for zooming and more
            ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
            ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
            if (rangeAxis != null) {
                rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {

                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
            if (domainAxis != null) {
                domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {

                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
        }
        // mouse adapter for scrolling and zooming
        mouseAdapter = new ChartGestureMouseAdapter();
        // mouseAdapter.addDebugHandler();
        this.addMouseListener(mouseAdapter);
        this.addMouseMotionListener(mouseAdapter);
        this.addMouseWheelListener(mouseAdapter);
        // add gestures
        if (standardGestures) {
            addStandardGestures();
        }
    }
}
Also used : ZoomHistory(net.sf.mzmine.chartbasics.listener.ZoomHistory) NumberAxis(org.jfree.chart.axis.NumberAxis) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) Plot(org.jfree.chart.plot.Plot) Range(org.jfree.data.Range) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) AxisRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) AxesRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot)

Example 4 with AxisRangeChangedListener

use of net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener in project mzmine2 by mzmine.

the class EChartViewer method initChartPanel.

/**
 * Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
 * Y-Axis0
 */
private void initChartPanel() {
    final EChartViewer chartPanel = this;
    // remove old init
    if (mouseAdapter != null) {
        this.getCanvas().removeMouseHandler(mouseAdapter);
    }
    if (chartPanel.getChart().getPlot() instanceof XYPlot) {
        // set sticky zero
        if (stickyZeroForRangeAxis) {
            ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
            if (rangeAxis instanceof NumberAxis) {
                NumberAxis axis = (NumberAxis) rangeAxis;
                axis.setAutoRangeIncludesZero(true);
                axis.setAutoRange(true);
                axis.setAutoRangeStickyZero(true);
                axis.setRangeType(RangeType.POSITIVE);
            }
        }
        Plot p = getChart().getPlot();
        if (addZoomHistory && p instanceof XYPlot && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
            // zoom history
            zoomHistory = new ZoomHistory(this, 20);
            // axis range changed listener for zooming and more
            ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
            ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
            if (rangeAxis != null) {
                rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {

                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
            if (domainAxis != null) {
                domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {

                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
        }
        // mouse adapter for scrolling and zooming
        mouseAdapter = new ChartGestureMouseAdapterFX("gestures", this);
        addMouseHandler(mouseAdapter);
        // add gestures
        if (standardGestures) {
            addStandardGestures();
        }
    // mouseAdapter.addDebugHandler();
    }
}
Also used : ZoomHistory(net.sf.mzmine.chartbasics.listener.ZoomHistory) NumberAxis(org.jfree.chart.axis.NumberAxis) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) Plot(org.jfree.chart.plot.Plot) Range(org.jfree.data.Range) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) AxisRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) AxesRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot)

Aggregations

ChartViewWrapper (net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper)4 AxisRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener)4 ValueAxis (org.jfree.chart.axis.ValueAxis)4 Range (org.jfree.data.Range)4 NumberAxis (org.jfree.chart.axis.NumberAxis)3 CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)3 AxesRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener)2 ZoomHistory (net.sf.mzmine.chartbasics.listener.ZoomHistory)2 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)2 Plot (org.jfree.chart.plot.Plot)2 XYPlot (org.jfree.chart.plot.XYPlot)2 ArrayList (java.util.ArrayList)1