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);
}
}
Aggregations