Search in sources :

Example 6 with AxesSetupDialog

use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.

the class ScatterPlotChart method actionPerformed.

public void actionPerformed(ActionEvent event) {
    super.actionPerformed(event);
    String command = event.getActionCommand();
    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(window, plot);
        dialog.setVisible(true);
        return;
    }
    if (command.equals("TIC")) {
        double valueX = plot.getDomainCrosshairValue();
        double valueY = plot.getRangeCrosshairValue();
        PeakListRow selectedRow = mainDataSet.getRow(valueX, valueY);
        if (selectedRow == null) {
            MZmineCore.getDesktop().displayErrorMessage(window, "No peak is selected");
            return;
        }
        Feature[] peaks = selectedRow.getPeaks();
        Range<Double> rtRange = peakList.getRowsRTRange();
        Range<Double> mzRange = PeakUtils.findMZRange(peaks);
        // Label best peak with preferred identity.
        final Feature bestPeak = selectedRow.getBestPeak();
        final PeakIdentity peakIdentity = selectedRow.getPreferredPeakIdentity();
        final Map<Feature, String> labelMap = new HashMap<Feature, String>(1);
        if (bestPeak != null && peakIdentity != null) {
            labelMap.put(bestPeak, peakIdentity.getName());
        }
        ScanSelection scanSelection = new ScanSelection(rtRange, 1);
        TICVisualizerModule.showNewTICVisualizerWindow(peakList.getRawDataFiles(), peaks, labelMap, scanSelection, TICPlotType.BASEPEAK, mzRange);
    }
    if ("SAVE_EMF".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EMF Image", "EMF");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".emf"))
                file += ".emf";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EMF);
            new Thread(SI).start();
        }
    }
    if ("SAVE_EPS".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EPS Image", "EPS");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".eps"))
                file += ".eps";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EPS);
            new Thread(SI).start();
        }
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) HashMap(java.util.HashMap) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage) Feature(net.sf.mzmine.datamodel.Feature) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) JFileChooser(javax.swing.JFileChooser)

Example 7 with AxesSetupDialog

use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.

the class MsMsVisualizerWindow method actionPerformed.

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("SHOW_SPECTRUM")) {
        CursorPosition pos = getCursorPosition();
        if (pos != null) {
            SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
        }
    }
    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
        dialog.setVisible(true);
    }
    if (command.equals("SHOW_DATA_POINTS")) {
        IDAPlot.switchDataPointsVisible();
    }
    if (command.equals("SWITCH_TOOLTIPS")) {
        if (tooltipMode) {
            IDAPlot.showPeaksTooltips(false);
            toolBar.setTooltipButton(false);
            tooltipMode = false;
        } else {
            IDAPlot.showPeaksTooltips(true);
            toolBar.setTooltipButton(true);
            tooltipMode = true;
        }
    }
    if (command.equals("FIND_SPECTRA")) {
        // Parameters
        final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for.");
        final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();
        final DoubleParameter inputIntensity = new DoubleParameter("Min. ion intensity", "Only ions with intensities above this value will be searched for.");
        final BooleanParameter inputNL = new BooleanParameter("Neutral Loss", "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.", false);
        final ComboParameter<Colors> inputColors = new ComboParameter<Colors>("Color", "The color which the data points will be marked with.", Colors.values());
        Parameter<?>[] parameters = new Parameter<?>[5];
        parameters[0] = inputMZ;
        parameters[1] = inputMZTolerance;
        parameters[2] = inputIntensity;
        parameters[3] = inputNL;
        parameters[4] = inputColors;
        final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
        ExitCode exitCode = parametersSearch.showSetupDialog(this, true);
        if (exitCode != ExitCode.OK)
            return;
        double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
        MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
        double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
        boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();
        Color highligtColor = Color.red;
        ;
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
            highligtColor = Color.green;
        }
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
            highligtColor = Color.blue;
        }
        // Find and highlight spectra with specific ion
        dataset.highlightSpectra(searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);
        // Add legend entry
        LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
        chartLegend.add(new LegendItem("Ion: " + searchMZ, "", "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: " + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity, "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor));
        IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) MZTolerance(net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) MZToleranceParameter(net.sf.mzmine.parameters.parametertypes.tolerances.MZToleranceParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) LegendItemCollection(org.jfree.chart.LegendItemCollection) ExitCode(net.sf.mzmine.util.ExitCode) Color(java.awt.Color) BooleanParameter(net.sf.mzmine.parameters.parametertypes.BooleanParameter) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) LegendItem(org.jfree.chart.LegendItem) Parameter(net.sf.mzmine.parameters.Parameter) WindowSettingsParameter(net.sf.mzmine.parameters.parametertypes.WindowSettingsParameter) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) BooleanParameter(net.sf.mzmine.parameters.parametertypes.BooleanParameter) MZToleranceParameter(net.sf.mzmine.parameters.parametertypes.tolerances.MZToleranceParameter) CursorPosition(net.sf.mzmine.modules.visualization.tic.CursorPosition)

Example 8 with AxesSetupDialog

use of net.sf.mzmine.util.dialogs.AxesSetupDialog in project mzmine2 by mzmine.

the class TICPlot method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    super.actionPerformed(event);
    final String command = event.getActionCommand();
    if ("SHOW_DATA_POINTS".equals(command)) {
        switchDataPointsVisible();
    }
    if ("SHOW_ANNOTATIONS".equals(command)) {
        switchItemLabelsVisible();
    }
    if ("SETUP_AXES".equals(command)) {
        JFrame parent = null;
        if (visualizer instanceof JFrame)
            parent = (JFrame) visualizer;
        new AxesSetupDialog(parent, getXYPlot()).setVisible(true);
    }
    if ("ZOOM_IN".equals(command)) {
        getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR);
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
    }
    // Set tick size to auto when zooming
    String[] zoomList = new String[] { "ZOOM_IN_BOTH", "ZOOM_IN_DOMAIN", "ZOOM_IN_RANGE", "ZOOM_OUT_BOTH", "ZOOM_DOMAIN_BOTH", "ZOOM_RANGE_BOTH", "ZOOM_RESET_BOTH", "ZOOM_RESET_DOMAIN", "ZOOM_RESET_RANGE" };
    if (Arrays.asList(zoomList).contains(command)) {
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
    }
    if ("ZOOM_OUT".equals(command)) {
        getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR);
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
    // if (getXYPlot().getDomainAxis().getRange().contains(0.0000001)) {
    // getXYPlot().getDomainAxis().setAutoRange(true);
    // getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
    // }
    }
    if ("ZOOM_AUTO".equals(command)) {
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
        restoreAutoDomainBounds();
        restoreAutoRangeBounds();
    }
    if ("SET_SAME_RANGE".equals(command)) {
        // Get current axes range.
        final NumberAxis xAxis = (NumberAxis) getXYPlot().getDomainAxis();
        final NumberAxis yAxis = (NumberAxis) getXYPlot().getRangeAxis();
        final double xMin = xAxis.getRange().getLowerBound();
        final double xMax = xAxis.getRange().getUpperBound();
        final double xTick = xAxis.getTickUnit().getSize();
        final double yMin = yAxis.getRange().getLowerBound();
        final double yMax = yAxis.getRange().getUpperBound();
        final double yTick = yAxis.getTickUnit().getSize();
        // Set the range of these frames
        for (final Window frame : JFrame.getWindows()) {
            if (frame instanceof TICVisualizerWindow) {
                final TICVisualizerWindow ticFrame = (TICVisualizerWindow) frame;
                ticFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
            }
        }
    }
    if ("SHOW_SPECTRUM".equals(command)) {
        visualizer.actionPerformed(event);
    }
    if ("SHOW_LEGEND".equals(command)) {
        // Toggle legend visibility.
        final LegendTitle legend = getChart().getLegend();
        legend.setVisible(!legend.isVisible());
    }
    if ("GRAY_BACKGROUND".equals(command)) {
        // Toggle background color
        final Paint color = getChart().getPlot().getBackgroundPaint();
        Color bgColor, liColor;
        if (color.equals(Color.lightGray)) {
            bgColor = Color.white;
            liColor = Color.lightGray;
        } else {
            bgColor = Color.lightGray;
            liColor = Color.white;
        }
        getChart().getPlot().setBackgroundPaint(bgColor);
        getChart().getXYPlot().setDomainGridlinePaint(liColor);
        getChart().getXYPlot().setRangeGridlinePaint(liColor);
    }
    if ("SAVE_EMF".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EMF Image", "EMF");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".emf"))
                file += ".emf";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EMF);
            new Thread(SI).start();
        }
    }
    if ("SAVE_EPS".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EPS Image", "EPS");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".eps"))
                file += ".eps";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EPS);
            new Thread(SI).start();
        }
    }
}
Also used : Window(java.awt.Window) NumberAxis(org.jfree.chart.axis.NumberAxis) Color(java.awt.Color) LegendTitle(org.jfree.chart.title.LegendTitle) Paint(java.awt.Paint) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage) Paint(java.awt.Paint) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame)

Aggregations

AxesSetupDialog (net.sf.mzmine.util.dialogs.AxesSetupDialog)8 Color (java.awt.Color)2 Window (java.awt.Window)2 JFileChooser (javax.swing.JFileChooser)2 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 PeakList (net.sf.mzmine.datamodel.PeakList)2 ExitCode (net.sf.mzmine.util.ExitCode)2 SaveImage (net.sf.mzmine.util.SaveImage)2 NumberAxis (org.jfree.chart.axis.NumberAxis)2 Paint (java.awt.Paint)1 HashMap (java.util.HashMap)1 JFrame (javax.swing.JFrame)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 Feature (net.sf.mzmine.datamodel.Feature)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 MSMSLibrarySubmissionWindow (net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow)1 DataPointProcessingManager (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager)1 CursorPosition (net.sf.mzmine.modules.visualization.tic.CursorPosition)1