Search in sources :

Example 1 with ExitCode

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

the class PeakListTableWindow method actionPerformed.

/**
 * Methods for ActionListener interface implementation
 */
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("PROPERTIES")) {
        ExitCode exitCode = parameters.showSetupDialog(this, true);
        if (exitCode == ExitCode.OK) {
            int rowHeight = parameters.getParameter(PeakListTableParameters.rowHeight).getValue();
            table.setRowHeight(rowHeight);
            PeakListTableColumnModel cm = (PeakListTableColumnModel) table.getColumnModel();
            cm.createColumns();
        }
    }
    if (command.equals("AUTOCOLUMNWIDTH")) {
        // Auto size column width based on data
        for (int column = 0; column < table.getColumnCount(); column++) {
            TableColumn tableColumn = table.getColumnModel().getColumn(column);
            if (tableColumn.getHeaderValue() != "Peak shape" && tableColumn.getHeaderValue() != "Status") {
                TableCellRenderer renderer = tableColumn.getHeaderRenderer();
                if (renderer == null) {
                    renderer = table.getTableHeader().getDefaultRenderer();
                }
                Component component = renderer.getTableCellRendererComponent(table, tableColumn.getHeaderValue(), false, false, -1, column);
                int preferredWidth = component.getPreferredSize().width + 20;
                tableColumn.setPreferredWidth(preferredWidth);
            }
        }
    }
    if (command.equals("PRINT")) {
        try {
            table.print(PrintMode.FIT_WIDTH);
        } catch (PrinterException e) {
            MZmineCore.getDesktop().displayException(this, e);
        }
    }
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) PeakListTableColumnModel(net.sf.mzmine.modules.visualization.peaklisttable.table.PeakListTableColumnModel) ExitCode(net.sf.mzmine.util.ExitCode) PrinterException(java.awt.print.PrinterException) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point)

Example 2 with ExitCode

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

the class MSMSExportModule method exportMSMS.

public static void exportMSMS(PeakListRow row) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MSMSExportModule.class);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    File outputFile = parameters.getParameter(MSMSExportParameters.outputFile).getValue();
    String massListName = parameters.getParameter(MSMSExportParameters.massList).getValue();
    if ((outputFile == null) || (massListName == null))
        return;
    // Best peak always exists, because feature list row has at least one peak
    Feature bestPeak = row.getBestPeak();
    // Get the MS/MS scan number
    int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
    if (msmsScanNumber < 1) {
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no MS/MS scan for peak " + bestPeak);
        return;
    }
    // MS/MS scan must exist, because msmsScanNumber was > 0
    Scan msmsScan = bestPeak.getDataFile().getScan(msmsScanNumber);
    MassList massList = msmsScan.getMassList(massListName);
    if (massList == null) {
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no mass list called " + massListName + " for MS/MS scan #" + msmsScanNumber + " (" + bestPeak.getDataFile() + ")");
        return;
    }
    DataPoint[] peaks = massList.getDataPoints();
    try {
        FileWriter fileWriter = new FileWriter(outputFile);
        BufferedWriter writer = new BufferedWriter(fileWriter);
        for (DataPoint peak : peaks) {
            writer.write(peak.getMZ() + " " + peak.getIntensity());
            writer.newLine();
        }
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) FileWriter(java.io.FileWriter) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) BufferedWriter(java.io.BufferedWriter) DataPoint(net.sf.mzmine.datamodel.DataPoint) Scan(net.sf.mzmine.datamodel.Scan) File(java.io.File) MassList(net.sf.mzmine.datamodel.MassList)

Example 3 with ExitCode

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

the class IntensityPlotModule method showIntensityPlot.

public static void showIntensityPlot(@Nonnull MZmineProject project, PeakList peakList, PeakListRow[] rows) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(IntensityPlotModule.class);
    parameters.getParameter(IntensityPlotParameters.peakList).setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, new PeakList[] { peakList });
    parameters.getParameter(IntensityPlotParameters.dataFiles).setChoices(peakList.getRawDataFiles());
    parameters.getParameter(IntensityPlotParameters.dataFiles).setValue(peakList.getRawDataFiles());
    parameters.getParameter(IntensityPlotParameters.selectedRows).setValue(rows);
    UserParameter<?, ?>[] projectParams = project.getParameters();
    Object[] xAxisSources = new Object[projectParams.length + 1];
    xAxisSources[0] = IntensityPlotParameters.rawDataFilesOption;
    for (int i = 0; i < projectParams.length; i++) {
        xAxisSources[i + 1] = new ParameterWrapper(projectParams[i]);
    }
    parameters.getParameter(IntensityPlotParameters.xAxisValueSource).setChoices(xAxisSources);
    ExitCode exitCode = parameters.showSetupDialog(null, true);
    if (exitCode == ExitCode.OK) {
        PeakListRow[] selectedRows = parameters.getParameter(IntensityPlotParameters.selectedRows).getMatchingRows(peakList);
        if (selectedRows.length == 0) {
            MZmineCore.getDesktop().displayErrorMessage(null, "No rows selected");
            return;
        }
        IntensityPlotWindow newFrame = new IntensityPlotWindow(parameters.cloneParameterSet());
        newFrame.setVisible(true);
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) UserParameter(net.sf.mzmine.parameters.UserParameter) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) ExitCode(net.sf.mzmine.util.ExitCode)

Example 4 with ExitCode

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

the class PeakListsComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == detailsButton) {
        PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
        if (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS) {
            final MultiChoiceParameter<PeakList> plsParameter = new MultiChoiceParameter<PeakList>("Select feature lists", "Select feature lists", MZmineCore.getProjectManager().getCurrentProject().getPeakLists(), currentValue.getSpecificPeakLists());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { plsParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                PeakList[] pls = paramSet.getParameter(plsParameter).getValue();
                currentValue.setSpecificPeakLists(pls);
            }
        }
        if (type == PeakListsSelectionType.NAME_PATTERN) {
            final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                String namePattern = paramSet.getParameter(nameParameter).getValue();
                currentValue.setNamePattern(namePattern);
            }
        }
    }
    if (src == typeCombo) {
        PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
        currentValue.setSelectionType(type);
        detailsButton.setEnabled((type == PeakListsSelectionType.NAME_PATTERN) || (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS));
    }
    updateNumPeakLists();
}
Also used : Window(java.awt.Window) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) PeakList(net.sf.mzmine.datamodel.PeakList) MultiChoiceParameter(net.sf.mzmine.parameters.parametertypes.MultiChoiceParameter)

Example 5 with ExitCode

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

the class RawDataFilesComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == detailsButton) {
        RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
        if (type == RawDataFilesSelectionType.SPECIFIC_FILES) {
            final MultiChoiceParameter<RawDataFile> filesParameter = new MultiChoiceParameter<RawDataFile>("Select files", "Select files", MZmineCore.getProjectManager().getCurrentProject().getDataFiles(), currentValue.getSpecificFiles());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { filesParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                RawDataFile[] files = paramSet.getParameter(filesParameter).getValue();
                currentValue.setSpecificFiles(files);
            }
        }
        if (type == RawDataFilesSelectionType.NAME_PATTERN) {
            final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                String namePattern = paramSet.getParameter(nameParameter).getValue();
                currentValue.setNamePattern(namePattern);
            }
        }
    }
    if (src == typeCombo) {
        RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
        currentValue.setSelectionType(type);
        detailsButton.setEnabled((type == RawDataFilesSelectionType.NAME_PATTERN) || (type == RawDataFilesSelectionType.SPECIFIC_FILES));
    }
    updateNumFiles();
}
Also used : Window(java.awt.Window) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) MultiChoiceParameter(net.sf.mzmine.parameters.parametertypes.MultiChoiceParameter)

Aggregations

ExitCode (net.sf.mzmine.util.ExitCode)32 ParameterSet (net.sf.mzmine.parameters.ParameterSet)19 Window (java.awt.Window)7 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)7 PeakList (net.sf.mzmine.datamodel.PeakList)6 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)6 File (java.io.File)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)4 Scan (net.sf.mzmine.datamodel.Scan)4 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4 Task (net.sf.mzmine.taskcontrol.Task)4 ArrayList (java.util.ArrayList)3 Feature (net.sf.mzmine.datamodel.Feature)3 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)3 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)3 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)3 Parameter (net.sf.mzmine.parameters.Parameter)3 RawDataFilesParameter (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)3 BufferedWriter (java.io.BufferedWriter)2