Search in sources :

Example 1 with ScanSelectionComponent

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent in project mzmine2 by mzmine.

the class MZRangeComponent method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setAutoButton) {
        RawDataFile[] currentFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
        ScanSelection scanSelection = new ScanSelection();
        try {
            ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this);
            RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog.getComponentForParameter(new RawDataFilesParameter());
            if (rdc != null) {
                RawDataFile[] matchingFiles = rdc.getValue().getMatchingRawDataFiles();
                if (matchingFiles.length > 0)
                    currentFiles = matchingFiles;
            }
            ScanSelectionComponent ssc = (ScanSelectionComponent) setupDialog.getComponentForParameter(new ScanSelectionParameter());
            if (ssc != null)
                scanSelection = ssc.getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Range<Double> mzRange = null;
        for (RawDataFile file : currentFiles) {
            Scan[] scans = scanSelection.getMatchingScans(file);
            for (Scan s : scans) {
                Range<Double> scanRange = s.getDataPointMZRange();
                if (scanRange == null)
                    continue;
                if (mzRange == null)
                    mzRange = scanRange;
                else
                    mzRange = mzRange.span(scanRange);
            }
        }
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromMassButton) {
        Range<Double> mzRange = MzRangeMassCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromFormulaButton) {
        Range<Double> mzRange = MzRangeFormulaCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) ScanSelectionParameter(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionParameter) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) RawDataFilesComponent(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) ScanSelectionComponent(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Aggregations

RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 Scan (net.sf.mzmine.datamodel.Scan)1 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)1 RawDataFilesComponent (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent)1 RawDataFilesParameter (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)1 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)1 ScanSelectionComponent (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent)1 ScanSelectionParameter (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionParameter)1