Search in sources :

Example 6 with ChartViewWrapper

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

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

Example 8 with ChartViewWrapper

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

the class MSMSLibrarySubmissionWindow method updateAllChartSelectors.

/**
 * Create new scan selector panels
 */
public void updateAllChartSelectors() {
    group = new ChartGroup(showCrosshair, showCrosshair, true, false);
    pnCharts.removeAll();
    GridLayout layout = new GridLayout(0, 1);
    pnCharts.setLayout(layout);
    if (checkInput()) {
        Integer minSignals = paramSubmit.getParameter(LibrarySubmitParameters.minSignals).getValue();
        Double noiseLevel = paramSubmit.getParameter(LibrarySubmitParameters.noiseLevel).getValue();
        String massListName = paramSubmit.getParameter(LibrarySubmitParameters.massList).getValue();
        if (minSignals != null && noiseLevel != null && massListName != null) {
            ScanSortMode sort = (ScanSortMode) getComboSortMode().getSelectedItem();
            if (rows != null) {
                // create MS2 of all rows
                for (int i = 0; i < rows.length; i++) {
                    PeakListRow row = rows[i];
                    ScanSelectPanel pn = new ScanSelectPanel(row, sort, noiseLevel, minSignals, massListName);
                    pnScanSelect[i] = pn;
                    pn.addChartChangedListener(chart -> regroupCharts());
                    pnCharts.add(pn);
                    // add to group
                    EChartPanel c = pn.getChart();
                    if (c != null) {
                        group.add(new ChartViewWrapper(c));
                    }
                }
            } else if (scanList != null) {
                // all selectors of scanlist
                for (int i = 0; i < scanList.size(); i++) {
                    Scan[] scansEntry = scanList.get(i);
                    ScanSelectPanel pn = new ScanSelectPanel(scansEntry, sort, noiseLevel, minSignals, massListName);
                    pnScanSelect[i] = pn;
                    pn.addChartChangedListener(chart -> regroupCharts());
                    pnCharts.add(pn);
                    // add to group
                    EChartPanel c = pn.getChart();
                    if (c != null) {
                        group.add(new ChartViewWrapper(c));
                    }
                }
            }
        }
        streamSelection().forEach(pn -> {
            pn.setFragmentScan(isFragmentScan);
            // only show exclude/check button if more than 1 entry
            pn.setShowExcludeButton(pnScanSelect.length > 1);
        });
    }
    pnCharts.revalidate();
    pnCharts.repaint();
}
Also used : Color(java.awt.Color) OptionalModuleComponent(net.sf.mzmine.parameters.parametertypes.submodules.OptionalModuleComponent) Arrays(java.util.Arrays) URL(java.net.URL) ItemListener(java.awt.event.ItemListener) DataPoint(net.sf.mzmine.datamodel.DataPoint) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) Map(java.util.Map) ScanSortMode(net.sf.mzmine.util.scans.sorting.ScanSortMode) LibrarySubmitTask(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitTask) UserParameter(net.sf.mzmine.parameters.UserParameter) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) JMenuBar(javax.swing.JMenuBar) ScrollPaneConstants(javax.swing.ScrollPaneConstants) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) SortingProperty(net.sf.mzmine.util.SortingProperty) Font(java.awt.Font) PeakListRowSorter(net.sf.mzmine.util.PeakListRowSorter) LibraryMetaDataParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibraryMetaDataParameters) JMenu(javax.swing.JMenu) GUIUtils(net.sf.mzmine.util.GUIUtils) GridBagConstraints(java.awt.GridBagConstraints) Logger(java.util.logging.Logger) LibrarySubmitParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitParameters) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Platform(javafx.application.Platform) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) ComboComponent(net.sf.mzmine.parameters.parametertypes.ComboComponent) EmptyBorder(javax.swing.border.EmptyBorder) AbstractMSMSIdentity(net.sf.mzmine.datamodel.identities.ms2.interf.AbstractMSMSIdentity) JPanel(javax.swing.JPanel) Scan(net.sf.mzmine.datamodel.Scan) MZmineCore(net.sf.mzmine.main.MZmineCore) Parameter(net.sf.mzmine.parameters.Parameter) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) LibrarySubmitModule(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitModule) HashMap(java.util.HashMap) LibrarySubmitIonParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) GridLayout(java.awt.GridLayout) IntegerComponent(net.sf.mzmine.parameters.parametertypes.IntegerComponent) DelayedDocumentListener(net.sf.mzmine.framework.listener.DelayedDocumentListener) JMenuItem(javax.swing.JMenuItem) JFreeChart(org.jfree.chart.JFreeChart) Hashtable(java.util.Hashtable) JComponent(javax.swing.JComponent) HelpWindow(net.sf.mzmine.desktop.impl.helpwindow.HelpWindow) MZTolerance(net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance) JButton(javax.swing.JButton) MigLayout(net.miginfocom.swing.MigLayout) ValueAxis(org.jfree.chart.axis.ValueAxis) ActionEvent(java.awt.event.ActionEvent) ChartGroup(net.sf.mzmine.chartbasics.chartgroups.ChartGroup) Consumer(java.util.function.Consumer) JScrollPane(javax.swing.JScrollPane) SortingDirection(net.sf.mzmine.util.SortingDirection) MassListComponent(net.sf.mzmine.parameters.parametertypes.MassListComponent) OptionalParameterComponent(net.sf.mzmine.parameters.parametertypes.OptionalParameterComponent) JLabel(javax.swing.JLabel) DialogLoggerUtil(net.sf.mzmine.util.DialogLoggerUtil) PseudoSpectrumDataSet(net.sf.mzmine.modules.visualization.spectra.multimsms.pseudospectra.PseudoSpectrumDataSet) DoubleComponent(net.sf.mzmine.parameters.parametertypes.DoubleComponent) GridLayout(java.awt.GridLayout) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) ScanSortMode(net.sf.mzmine.util.scans.sorting.ScanSortMode) DataPoint(net.sf.mzmine.datamodel.DataPoint) ChartGroup(net.sf.mzmine.chartbasics.chartgroups.ChartGroup)

Example 9 with ChartViewWrapper

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

the class MultiMSMSWindow method updateAllCharts.

/**
 * Create new charts
 */
public void updateAllCharts() {
    msone = null;
    group = new ChartGroup(showCrosshair, showCrosshair, true, false);
    // MS1
    if (createMS1) {
        Scan scan = null;
        Feature best = null;
        for (PeakListRow r : rows) {
            Feature f = raw == null ? r.getBestPeak() : r.getPeak(raw);
            if (f != null && (best == null || f.getHeight() > best.getHeight())) {
                best = f;
            }
        }
        if (best != null) {
            scan = best.getDataFile().getScan(best.getRepresentativeScanNumber());
            EChartPanel cp = SpectrumChartFactory.createScanChartPanel(scan, showTitle, showLegend);
            if (cp != null)
                msone = new ChartViewWrapper(cp);
        }
    } else {
        // pseudo MS1 from all rows and isotope pattern
        EChartPanel cp = PseudoSpectrum.createChartPanel(rows, raw, false, "pseudo");
        if (cp != null) {
            cp.getChart().getLegend().setVisible(showLegend);
            cp.getChart().getTitle().setVisible(showTitle);
            msone = new ChartViewWrapper(cp);
        }
    }
    if (msone != null)
        group.add(msone);
    // MS2 of all rows
    for (PeakListRow row : rows) {
        EChartPanel c = SpectrumChartFactory.createMSMSChartPanel(row, raw, showTitle, showLegend, alwaysShowBest, useBestForMissingRaw);
        if (c != null) {
            group.add(new ChartViewWrapper(c));
        }
    }
    renewCharts(group);
}
Also used : EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) Scan(net.sf.mzmine.datamodel.Scan) Feature(net.sf.mzmine.datamodel.Feature) ChartGroup(net.sf.mzmine.chartbasics.chartgroups.ChartGroup)

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