Search in sources :

Example 21 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class ParameterSetupDialog method updateParameterSetFromComponents.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void updateParameterSetFromComponents() {
    for (Parameter<?> p : parameterSet.getParameters()) {
        if (!(p instanceof UserParameter) && !(p instanceof HiddenParameter))
            continue;
        UserParameter up;
        if (p instanceof UserParameter)
            up = (UserParameter) p;
        else
            up = (UserParameter) ((HiddenParameter) p).getEmbeddedParameter();
        JComponent component = parametersAndComponents.get(p.getName());
        // if a parameter is a HiddenParameter it does not necessarily have component
        if (component != null)
            up.setValueFromComponent(component);
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) HiddenParameter(net.sf.mzmine.parameters.parametertypes.HiddenParameter) JComponent(javax.swing.JComponent)

Example 22 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class HeatmapSetupDialog method parametersChanged.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void parametersChanged() {
    // Get the current value of the "Sample parameter" combo
    UserParameter<?, ?> currentParameterSelection = (UserParameter<?, ?>) selDataCombo.getSelectedItem();
    if (currentParameterSelection == null)
        return;
    // If the value has changed, update the "Reference group" combo
    if (currentParameterSelection != previousParameterSelection) {
        ArrayList<Object> values = new ArrayList<Object>();
        // Obtain all possible values
        for (RawDataFile dataFile : MZmineCore.getProjectManager().getCurrentProject().getDataFiles()) {
            Object paramValue = MZmineCore.getProjectManager().getCurrentProject().getParameterValue(currentParameterSelection, dataFile);
            if (paramValue == null)
                continue;
            if (!values.contains(paramValue))
                values.add(paramValue);
        }
        // Update the parameter and combo model
        Object[] newValues = values.toArray();
        super.parameterSet.getParameter(HeatMapParameters.referenceGroup).setChoices(newValues);
        refGroupCombo.setModel(new DefaultComboBoxModel(newValues));
        previousParameterSelection = currentParameterSelection;
    }
    this.updateParameterSetFromComponents();
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

UserParameter (net.sf.mzmine.parameters.UserParameter)22 JComponent (javax.swing.JComponent)8 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)5 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)4 ArrayList (java.util.ArrayList)3 JComboBox (javax.swing.JComboBox)3 JLabel (javax.swing.JLabel)3 Parameter (net.sf.mzmine.parameters.Parameter)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 GridBagPanel (net.sf.mzmine.util.components.GridBagPanel)3 DataPoint (net.sf.mzmine.datamodel.DataPoint)2 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)2 DoubleParameter (net.sf.mzmine.parameters.parametertypes.DoubleParameter)2 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 java.util (java.util)1 HashMap (java.util.HashMap)1