Search in sources :

Example 1 with ChartViewWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.

the class ChartGestureMouseAdapterFX method handleMouseMoved.

/**
 * Handles a mouse moved event. This implementation does nothing, override the method if required.
 *
 * @param canvas the canvas ({@code null} not permitted).
 * @param e the event ({@code null} not permitted).
 */
@Override
public void handleMouseMoved(ChartCanvas chartPanel, MouseEvent eOrig) {
    if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOVED))
        return;
    MouseEventWrapper e = new MouseEventWrapper(eOrig);
    ChartViewWrapper cw = new ChartViewWrapper(chartViewer);
    ChartEntity entity = findChartEntity(e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());
    // handle event
    handleEvent(new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.MOVED, button)));
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 2 with ChartViewWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper 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 3 with ChartViewWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.

the class MultiMSMSWindow method renewCharts.

/**
 * @param group
 */
public void renewCharts(ChartGroup group) {
    pnCharts.removeAll();
    if (group != null && group.size() > 0) {
        realCol = autoCol ? (int) Math.floor(Math.sqrt(group.size())) - 1 : col;
        if (realCol < 1)
            realCol = 1;
        GridLayout layout = new GridLayout(0, realCol);
        pnCharts.setLayout(layout);
        // add to layout
        int i = 0;
        for (ChartViewWrapper cp : group.getList()) {
            // show only the last domain axes
            ValueAxis axis = cp.getChart().getXYPlot().getDomainAxis();
            axis.setVisible(!onlyShowOneAxis || i >= group.size() - realCol);
            pnCharts.add(cp.getChartSwing());
            i++;
        }
    }
    pnCharts.revalidate();
    pnCharts.repaint();
}
Also used : GridLayout(java.awt.GridLayout) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 4 with ChartViewWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper 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 5 with ChartViewWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.

the class ChartGestureDragDiffHandler method createConsumer.

/**
 * Handle PRESSED, DRAGGED, RELEASED events to generate drag diff events
 *
 * @return
 */
private Consumer<ChartGestureEvent> createConsumer() {
    return new Consumer<ChartGestureEvent>() {

        // variables
        boolean wasMouseZoomable = false;

        Point2D last = null, first = null;

        ChartGestureEvent startEvent = null, lastEvent = null;

        @Override
        public void accept(ChartGestureEvent event) {
            ChartViewWrapper chartPanel = event.getChartWrapper();
            JFreeChart chart = chartPanel.getChart();
            MouseEventWrapper e = event.getMouseEvent();
            // released?
            if (event.checkEvent(Event.RELEASED)) {
                chartPanel.setMouseZoomable(wasMouseZoomable);
                last = null;
            } else if (event.checkEvent(Event.PRESSED)) {
                // get data space coordinates
                last = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
                first = last;
                startEvent = event;
                lastEvent = event;
                if (last != null) {
                    wasMouseZoomable = chartPanel.isMouseZoomable();
                    chartPanel.setMouseZoomable(false);
                }
            } else if (event.checkEvent(Event.DRAGGED)) {
                if (last != null) {
                    // get data space coordinates
                    Point2D released = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
                    if (released != null) {
                        double offset = 0;
                        double start = 0;
                        // scroll x
                        if (getOrientation(event).equals(Orientation.HORIZONTAL)) {
                            offset = -(released.getX() - last.getX());
                            start = first.getX();
                        } else // scroll y
                        {
                            offset = -(released.getY() - last.getY());
                            start = first.getY();
                        }
                        // new dragdiff event
                        ChartGestureDragDiffEvent dragEvent = new ChartGestureDragDiffEvent(startEvent, lastEvent, event, start, offset, orient);
                        // choose handler by key filter
                        for (int i = 0; i < dragDiffHandler.length; i++) if (key[i].filter(event.getMouseEvent()))
                            dragDiffHandler[i].accept(dragEvent);
                        // set last event
                        lastEvent = event;
                        // save updated last
                        last = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
                    }
                }
            }
        }
    };
}
Also used : ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) Consumer(java.util.function.Consumer) Point2D(java.awt.geom.Point2D) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

ChartViewWrapper (net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper)9 ValueAxis (org.jfree.chart.axis.ValueAxis)6 AxisRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener)4 Range (org.jfree.data.Range)4 NumberAxis (org.jfree.chart.axis.NumberAxis)3 CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)3 GridLayout (java.awt.GridLayout)2 ArrayList (java.util.ArrayList)2 Consumer (java.util.function.Consumer)2 ChartGroup (net.sf.mzmine.chartbasics.chartgroups.ChartGroup)2 EChartPanel (net.sf.mzmine.chartbasics.gui.swing.EChartPanel)2 AxesRangeChangedListener (net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener)2 ZoomHistory (net.sf.mzmine.chartbasics.listener.ZoomHistory)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 JFreeChart (org.jfree.chart.JFreeChart)2 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)2 Plot (org.jfree.chart.plot.Plot)2 XYPlot (org.jfree.chart.plot.XYPlot)2 BorderLayout (java.awt.BorderLayout)1