Search in sources :

Example 1 with IntegerParameter

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

the class ScanSelectionComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setButton) {
        SimpleParameterSet paramSet;
        ExitCode exitCode;
        Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
        final IntRangeParameter scanNumParameter = new IntRangeParameter("Scan number", "Range of included scan numbers", false, scanNumberRange);
        final IntegerParameter baseFilteringIntegerParameter = new IntegerParameter("Base Filtering Integer", "Enter an integer for which every multiple of that integer in the list will be filtered. (Every Nth element will be shown)", this.baseFilteringInteger, false);
        final RTRangeParameter rtParameter = new RTRangeParameter(false);
        if (scanRTRange != null)
            rtParameter.setValue(scanRTRange);
        final IntegerParameter msLevelParameter = new IntegerParameter("MS level", "MS level", msLevel, false);
        final StringParameter scanDefinitionParameter = new StringParameter("Scan definition", "Include only scans that match this scan definition. You can use wild cards, e.g. *FTMS*", scanDefinition, false);
        final String[] polarityTypes = { "Any", "+", "-" };
        final ComboParameter<String> polarityParameter = new ComboParameter<>("Polarity", "Include only scans of this polarity", polarityTypes);
        if ((polarity == PolarityType.POSITIVE) || (polarity == PolarityType.NEGATIVE))
            polarityParameter.setValue(polarity.asSingleChar());
        final String[] spectraTypes = { "Any", "Centroided", "Profile", "Thresholded" };
        final ComboParameter<String> spectrumTypeParameter = new ComboParameter<>("Spectrum type", "Include only spectra of this type", spectraTypes);
        if (spectrumType != null) {
            switch(spectrumType) {
                case CENTROIDED:
                    spectrumTypeParameter.setValue(spectraTypes[1]);
                    break;
                case PROFILE:
                    spectrumTypeParameter.setValue(spectraTypes[2]);
                    break;
                case THRESHOLDED:
                    spectrumTypeParameter.setValue(spectraTypes[3]);
                    break;
            }
        }
        paramSet = new SimpleParameterSet(new Parameter[] { scanNumParameter, baseFilteringIntegerParameter, rtParameter, msLevelParameter, scanDefinitionParameter, polarityParameter, spectrumTypeParameter });
        exitCode = paramSet.showSetupDialog(parent, true);
        if (exitCode == ExitCode.OK) {
            scanNumberRange = paramSet.getParameter(scanNumParameter).getValue();
            this.baseFilteringInteger = paramSet.getParameter(baseFilteringIntegerParameter).getValue();
            scanRTRange = paramSet.getParameter(rtParameter).getValue();
            msLevel = paramSet.getParameter(msLevelParameter).getValue();
            scanDefinition = paramSet.getParameter(scanDefinitionParameter).getValue();
            final int selectedPolarityIndex = Arrays.asList(polarityTypes).indexOf(paramSet.getParameter(polarityParameter).getValue());
            switch(selectedPolarityIndex) {
                case 1:
                    polarity = PolarityType.POSITIVE;
                    break;
                case 2:
                    polarity = PolarityType.NEGATIVE;
                    break;
                default:
                    polarity = null;
                    break;
            }
            final int selectedSpectraTypeIndex = Arrays.asList(spectraTypes).indexOf(paramSet.getParameter(spectrumTypeParameter).getValue());
            switch(selectedSpectraTypeIndex) {
                case 1:
                    spectrumType = MassSpectrumType.CENTROIDED;
                    break;
                case 2:
                    spectrumType = MassSpectrumType.PROFILE;
                    break;
                case 3:
                    spectrumType = MassSpectrumType.THRESHOLDED;
                    break;
                default:
                    spectrumType = null;
                    break;
            }
        }
    }
    if (src == clearButton) {
        scanNumberRange = null;
        baseFilteringInteger = null;
        scanRTRange = null;
        polarity = null;
        spectrumType = null;
        msLevel = null;
        scanDefinition = null;
    }
    updateRestrictionList();
}
Also used : Window(java.awt.Window) IntegerParameter(net.sf.mzmine.parameters.parametertypes.IntegerParameter) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) RTRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter) IntRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter) ExitCode(net.sf.mzmine.util.ExitCode) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) Parameter(net.sf.mzmine.parameters.Parameter) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) IntRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter) RTRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) IntegerParameter(net.sf.mzmine.parameters.parametertypes.IntegerParameter)

Aggregations

Window (java.awt.Window)1 Parameter (net.sf.mzmine.parameters.Parameter)1 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)1 ComboParameter (net.sf.mzmine.parameters.parametertypes.ComboParameter)1 IntegerParameter (net.sf.mzmine.parameters.parametertypes.IntegerParameter)1 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)1 IntRangeParameter (net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter)1 RTRangeParameter (net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter)1 ExitCode (net.sf.mzmine.util.ExitCode)1