Search in sources :

Example 1 with CombinedRangeXYPlot

use of org.jfree.chart.plot.CombinedRangeXYPlot in project SIMVA-SoS by SESoS.

the class StandardChartTheme method applyToXYPlot.

/**
 * Applies the attributes of this theme to a {@link XYPlot}.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToXYPlot(XYPlot plot) {
    plot.setAxisOffset(this.axisOffset);
    plot.setDomainZeroBaselinePaint(this.baselinePaint);
    plot.setRangeZeroBaselinePaint(this.baselinePaint);
    plot.setDomainGridlinePaint(this.domainGridlinePaint);
    plot.setRangeGridlinePaint(this.rangeGridlinePaint);
    plot.setDomainCrosshairPaint(this.crosshairPaint);
    plot.setRangeCrosshairPaint(this.crosshairPaint);
    plot.setShadowGenerator(this.shadowGenerator);
    // process all domain axes
    int domainAxisCount = plot.getDomainAxisCount();
    for (int i = 0; i < domainAxisCount; i++) {
        ValueAxis axis = plot.getDomainAxis(i);
        if (axis != null) {
            applyToValueAxis(axis);
        }
    }
    // process all range axes
    int rangeAxisCount = plot.getRangeAxisCount();
    for (int i = 0; i < rangeAxisCount; i++) {
        ValueAxis axis = plot.getRangeAxis(i);
        if (axis != null) {
            applyToValueAxis(axis);
        }
    }
    // process all renderers
    int rendererCount = plot.getRendererCount();
    for (int i = 0; i < rendererCount; i++) {
        XYItemRenderer r = plot.getRenderer(i);
        if (r != null) {
            applyToXYItemRenderer(r);
        }
    }
    // process all annotations
    Iterator iter = plot.getAnnotations().iterator();
    while (iter.hasNext()) {
        XYAnnotation a = (XYAnnotation) iter.next();
        applyToXYAnnotation(a);
    }
    if (plot instanceof CombinedDomainXYPlot) {
        CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot;
        Iterator iterator = cp.getSubplots().iterator();
        while (iterator.hasNext()) {
            XYPlot subplot = (XYPlot) iterator.next();
            if (subplot != null) {
                applyToPlot(subplot);
            }
        }
    }
    if (plot instanceof CombinedRangeXYPlot) {
        CombinedRangeXYPlot cp = (CombinedRangeXYPlot) plot;
        Iterator iterator = cp.getSubplots().iterator();
        while (iterator.hasNext()) {
            XYPlot subplot = (XYPlot) iterator.next();
            if (subplot != null) {
                applyToPlot(subplot);
            }
        }
    }
}
Also used : XYAnnotation(org.jfree.chart.annotations.XYAnnotation) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) Paint(java.awt.Paint)

Example 2 with CombinedRangeXYPlot

use of org.jfree.chart.plot.CombinedRangeXYPlot in project mzmine2 by mzmine.

the class ChartLogics method findXYSubplot.

/**
 * Subplot or main plot at point
 *
 * @param chart
 * @param info
 * @param mouseX
 * @param mouseY
 * @return
 */
public static XYPlot findXYSubplot(JFreeChart chart, ChartRenderingInfo info, double mouseX, double mouseY) {
    int subplot = info.getPlotInfo().getSubplotIndex(new Point2D.Double(mouseX, mouseY));
    XYPlot plot = null;
    if (subplot != -1) {
        if (chart.getPlot() instanceof CombinedDomainXYPlot)
            plot = (XYPlot) ((CombinedDomainXYPlot) chart.getPlot()).getSubplots().get(subplot);
        else if (chart.getPlot() instanceof CombinedRangeXYPlot)
            plot = (XYPlot) ((CombinedRangeXYPlot) chart.getPlot()).getSubplots().get(subplot);
    }
    if (plot == null && chart.getPlot() instanceof XYPlot)
        plot = (XYPlot) chart.getPlot();
    return plot;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) Point2D(java.awt.geom.Point2D) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) Point(java.awt.Point)

Example 3 with CombinedRangeXYPlot

use of org.jfree.chart.plot.CombinedRangeXYPlot in project mzmine2 by mzmine.

the class ChartLogicsFX method findXYSubplot.

/**
 * Subplot or main plot at point
 *
 * @param chart
 * @param info
 * @param mouseX
 * @param mouseY
 * @return
 */
public static XYPlot findXYSubplot(JFreeChart chart, ChartRenderingInfo info, double mouseX, double mouseY) {
    int subplot = info.getPlotInfo().getSubplotIndex(new Point2D.Double(mouseX, mouseY));
    XYPlot plot = null;
    if (subplot != -1) {
        if (chart.getPlot() instanceof CombinedDomainXYPlot)
            plot = (XYPlot) ((CombinedDomainXYPlot) chart.getPlot()).getSubplots().get(subplot);
        else if (chart.getPlot() instanceof CombinedRangeXYPlot)
            plot = (XYPlot) ((CombinedRangeXYPlot) chart.getPlot()).getSubplots().get(subplot);
    }
    if (plot == null && chart.getPlot() instanceof XYPlot)
        plot = (XYPlot) chart.getPlot();
    return plot;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) Point2D(java.awt.geom.Point2D) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot)

Example 4 with CombinedRangeXYPlot

use of org.jfree.chart.plot.CombinedRangeXYPlot 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 5 with CombinedRangeXYPlot

use of org.jfree.chart.plot.CombinedRangeXYPlot 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

CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)5 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)5 XYPlot (org.jfree.chart.plot.XYPlot)5 ValueAxis (org.jfree.chart.axis.ValueAxis)3 Point2D (java.awt.geom.Point2D)2 ChartViewWrapper (net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper)2 AxesRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener)2 AxisRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener)2 ZoomHistory (net.sf.mzmine.chartbasics.listener.ZoomHistory)2 NumberAxis (org.jfree.chart.axis.NumberAxis)2 Plot (org.jfree.chart.plot.Plot)2 Range (org.jfree.data.Range)2 Paint (java.awt.Paint)1 Point (java.awt.Point)1 Iterator (java.util.Iterator)1 XYAnnotation (org.jfree.chart.annotations.XYAnnotation)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1