Search in sources :

Example 1 with SaveImage

use of net.sf.mzmine.util.SaveImage in project mzmine2 by mzmine.

the class SpectraPlot method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    super.actionPerformed(event);
    final String command = event.getActionCommand();
    if ("SHOW_REMOVED_TITLES".equals(command)) {
        for (int i = 0; i < getChart().getSubtitleCount(); i++) {
            getChart().getSubtitle(i).setVisible(true);
        }
        getChart().getTitle().setVisible(true);
    }
    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 : JFileChooser(javax.swing.JFileChooser) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage)

Example 2 with SaveImage

use of net.sf.mzmine.util.SaveImage in project mzmine2 by mzmine.

the class ProductIonFilterPlot method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    super.actionPerformed(event);
    final String command = event.getActionCommand();
    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 : JFileChooser(javax.swing.JFileChooser) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage)

Example 3 with SaveImage

use of net.sf.mzmine.util.SaveImage 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 4 with SaveImage

use of net.sf.mzmine.util.SaveImage in project mzmine2 by mzmine.

the class MsMsPlot method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    super.actionPerformed(event);
    final String command = event.getActionCommand();
    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 : JFileChooser(javax.swing.JFileChooser) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage)

Example 5 with SaveImage

use of net.sf.mzmine.util.SaveImage 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

JFileChooser (javax.swing.JFileChooser)7 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)7 SaveImage (net.sf.mzmine.util.SaveImage)7 AxesSetupDialog (net.sf.mzmine.util.dialogs.AxesSetupDialog)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 Window (java.awt.Window)1 HashMap (java.util.HashMap)1 JFrame (javax.swing.JFrame)1 Feature (net.sf.mzmine.datamodel.Feature)1 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 LegendTitle (org.jfree.chart.title.LegendTitle)1