Search in sources :

Example 1 with UserParameter

use of net.sf.mzmine.parameters.UserParameter 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 2 with UserParameter

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

the class GraphicsExportDialog method updateComponentsFromParameters.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void updateComponentsFromParameters() {
    for (Parameter<?> p : parameters.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        up.setValueToComponent(component, up.getValue());
    }
    for (Parameter<?> p : chartParam.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        if (component instanceof JFontSpecs) {
            // stop listeners from changing all fonts to master
            JFontSpecs f = (JFontSpecs) component;
            setListenersEnabled(false);
            up.setValueToComponent(f, up.getValue());
            f.stopListener();
            setListenersEnabled(true);
        } else
            up.setValueToComponent(component, up.getValue());
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) JFontSpecs(net.sf.mzmine.framework.fontspecs.JFontSpecs) JComponent(javax.swing.JComponent)

Example 3 with UserParameter

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

the class MSMSLibrarySubmissionWindow method createMetaDataPanel.

private void createMetaDataPanel() {
    // Main panel which holds all the components in a grid
    pnMetaData = new GridBagPanel();
    scrollMeta = new JScrollPane(pnMetaData);
    scrollMeta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollMeta.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pnSideMenu.add(scrollMeta, BorderLayout.CENTER);
    int rowCounter = 0;
    int vertWeightSum = 0;
    // Create labels and components for each parameter
    for (Parameter p : paramMeta.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        JLabel label = new JLabel(p.getName());
        pnMetaData.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        // Multiple selection will be expandable, other components not
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        vertWeightSum += verticalWeight;
        pnMetaData.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) UserParameter(net.sf.mzmine.parameters.UserParameter) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) UserParameter(net.sf.mzmine.parameters.UserParameter) Parameter(net.sf.mzmine.parameters.Parameter) JLabel(javax.swing.JLabel) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 4 with UserParameter

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

the class MSMSLibrarySubmissionWindow method createSubmitParamPanel.

private void createSubmitParamPanel() {
    // Main panel which holds all the components in a grid
    pnSubmitParam = new GridBagPanel();
    pnSideMenu.add(pnSubmitParam, BorderLayout.NORTH);
    int rowCounter = 0;
    // Create labels and components for each parameter
    for (Parameter p : paramSubmit.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        // add separator
        if (p.getName().equals(LibrarySubmitParameters.LOCALFILE.getName())) {
            pnSubmitParam.addSeparator(0, rowCounter, 2);
            rowCounter++;
        }
        JLabel label = new JLabel(p.getName());
        pnSubmitParam.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        pnSubmitParam.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) UserParameter(net.sf.mzmine.parameters.UserParameter) Parameter(net.sf.mzmine.parameters.Parameter) JLabel(javax.swing.JLabel) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 5 with UserParameter

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

the class MSMSLibrarySubmissionWindow method updateParameterSetFromComponents.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void updateParameterSetFromComponents() {
    for (Parameter<?> p : paramSubmit.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        up.setValueFromComponent(component);
    }
    for (Parameter<?> p : paramMeta.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        up.setValueFromComponent(component);
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) JComponent(javax.swing.JComponent)

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