Search in sources :

Example 1 with OptionalParameterComponent

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

the class GraphicsExportDialog method renewPreview.

/**
 * renew chart preview with specified size
 */
protected void renewPreview() {
    // set dimensions to chartpanel
    try {
        // update param
        updateParameterSetFromComponents();
        // 
        if (parameters.isUseOnlyWidth()) {
            double height = (ChartLogics.calcHeightToWidth(chartPanel, parameters.getWidthPixel(), false));
            DoubleParameter p = parameters.getParameter(GraphicsExportParameters.height).getEmbeddedParameter();
            DoubleComponent c = ((OptionalParameterComponent<DoubleComponent>) parametersAndComponents.get(p.getName())).getEmbeddedComponent();
            p.setValueToComponent(c, height);
            p.setValueFromComponent(c);
            chartPanel.setSize((int) parameters.getWidthPixel(), (int) parameters.getHeightPixel());
            getPnChartPreview().repaint();
        } else {
            chartPanel.setSize((int) parameters.getWidthPixel(), (int) parameters.getHeightPixel());
            chartPanel.repaint();
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        LOG.log(Level.SEVERE, "Error while renewing preview of graphics export dialog ", ex);
    }
}
Also used : DoubleComponent(net.sf.mzmine.parameters.parametertypes.DoubleComponent) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) OptionalParameterComponent(net.sf.mzmine.parameters.parametertypes.OptionalParameterComponent)

Example 2 with OptionalParameterComponent

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

the class SpectraIdentificationSpectralDatabaseParameters method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    if ((getParameters() == null) || (getParameters().length == 0))
        return ExitCode.OK;
    ParameterSetupDialog dialog = new ParameterSetupDialog(parent, valueCheckRequired, this);
    // only enable precursor mz tolerance if precursor mz is used
    OptionalParameterComponent usePreComp = (OptionalParameterComponent) dialog.getComponentForParameter(usePrecursorMZ);
    JComponent mzTolPrecursor = dialog.getComponentForParameter(mzTolerancePrecursor);
    mzTolPrecursor.setEnabled(getParameter(usePrecursorMZ).getValue());
    usePreComp.addItemListener(e -> {
        mzTolPrecursor.setEnabled(usePreComp.isSelected());
    });
    dialog.setVisible(true);
    return dialog.getExitCode();
}
Also used : OptionalParameterComponent(net.sf.mzmine.parameters.parametertypes.OptionalParameterComponent) JComponent(javax.swing.JComponent) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)

Aggregations

OptionalParameterComponent (net.sf.mzmine.parameters.parametertypes.OptionalParameterComponent)2 JComponent (javax.swing.JComponent)1 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)1 DoubleComponent (net.sf.mzmine.parameters.parametertypes.DoubleComponent)1 DoubleParameter (net.sf.mzmine.parameters.parametertypes.DoubleParameter)1