Search in sources :

Example 31 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project MassBank-web by MassBank.

the class DrawPane method makeZoomSpinner.

private JSpinner makeZoomSpinner(final DrawPane canvas, Action zoomIn, Action zoomOut) {
    SpinnerNumberModel snm = new SpinnerNumberModel(0.8, 0.4, 3.0, 0.1);
    final JSpinner zoomSpinner = new JSpinner(snm);
    zoomSpinner.setMaximumSize(new Dimension(60, 30));
    JSpinner.NumberEditor sne = new JSpinner.NumberEditor(zoomSpinner, "###%");
    zoomSpinner.setEditor(sne);
    zoomSpinner.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent ce) {
            canvas.zoomChangeTo((float) ((Double) (zoomSpinner.getValue())).doubleValue());
        }
    });
    zoomIn.setActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            Object o = zoomSpinner.getNextValue();
            if (o != null)
                zoomSpinner.setValue(o);
        }
    });
    zoomOut.setActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            Object o = zoomSpinner.getPreviousValue();
            if (o != null)
                zoomSpinner.setValue(o);
        }
    });
    return zoomSpinner;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener) Dimension(java.awt.Dimension)

Example 32 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project knime-core by knime.

the class RuleEngine2PortsNodeDialog method initControls.

/**
 * Creates and adds most of the controls to the dialog.
 */
private void initControls() {
    m_pmml = new JCheckBox("Enable PMML RuleSet generation (fails when result would not be a valid PMML RuleSet)");
    m_ruleSelectionMethod = new JComboBox<>(new Vector<>(RuleEngine2PortsSettings.POSSIBLE_RULE_SELECTION_METHODS));
    m_hasDefaultScore = new JCheckBox("Default value (when nothing matches): ");
    m_defaultScore = Util.createTextFieldWithWatermark(RuleEngine2PortsSettings.DEFAULT_DEFAULT_SCORE, 22, "Default score/value when nothing matches");
    m_hasDefaultConfidence = new JCheckBox("Default confidence value (when not specified in the confidence column): ");
    m_defaultConfidence = new JSpinner(new SpinnerNumberModel(RuleEngine2PortsSettings.DEFAULT_DEFAULT_CONFIDENCE, 0d, 1d, .1));
    @SuppressWarnings("unchecked") DataValueColumnFilter doubleValueFilter = new DataValueColumnFilter(DoubleValue.class);
    m_ruleConfidenceColumn = new ColumnSelectionPanel((Border) null, doubleValueFilter, true);
    m_hasDefaultWeight = new JCheckBox("Default weight value (when not specified in the weight column): ");
    m_defaultWeight = new JSpinner(new SpinnerNumberModel(RuleEngine2PortsSettings.DEFAULT_DEFAULT_WEIGHT, 0d, 1e6, .1));
    m_ruleWeightColumn = new ColumnSelectionPanel((Border) null, doubleValueFilter, true);
    m_computeConfidence = new JCheckBox("Confidence column name: ");
    m_predictionConfidenceColumn = Util.createTextFieldWithWatermark(RuleEngine2PortsSettings.DEFAULT_PREDICTION_CONFIDENCE_COLUMN, 22, "Computed confidence column name");
    m_provideStatistics = new JCheckBox("Provide statistics");
    @SuppressWarnings("unchecked") DataValueColumnFilter validationColumnFilter = new DataValueColumnFilter(StringValue.class, BooleanValue.class, DoubleValue.class);
    m_validationColumn = new ColumnSelectionPanel(null, validationColumnFilter, true);
    m_pmmlLabels = new ArrayList<>();
    m_pmmlBorders = new ArrayList<>();
    m_validateLabel = new JLabel("Validation column");
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) DataValueColumnFilter(org.knime.core.node.util.DataValueColumnFilter) Vector(java.util.Vector) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 33 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method createMethodUIControls.

private JPanel createMethodUIControls() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 0;
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodFixedNumber = new JRadioButton("Fixed number of bins");
    m_methodFixedNumber.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(m_methodFixedNumber.isSelected());
            m_equalityMethod.setEnabled(m_methodFixedNumber.isSelected());
            m_sampleQuantiles.setEnabled(!m_methodFixedNumber.isSelected());
        }
    });
    p.add(m_methodFixedNumber, c);
    c.gridy++;
    // JPanel numBinsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    JPanel numBinsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    numBinsPanel.add(new JLabel("Number of bins:"), gbc);
    gbc.gridx++;
    m_numBins = new JSpinner(new SpinnerNumberModel(5, 1, Integer.MAX_VALUE, 1));
    numBinsPanel.add(m_numBins, gbc);
    gbc.weightx = 1;
    gbc.gridx++;
    numBinsPanel.add(new JLabel(), gbc);
    gbc.weightx = 0;
    gbc.gridx = 0;
    gbc.gridy++;
    numBinsPanel.add(new JLabel("Equal:"), gbc);
    gbc.gridx++;
    m_equalityMethod = new JComboBox<EqualityMethod>(EqualityMethod.values());
    numBinsPanel.add(m_equalityMethod, gbc);
    numBinsPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    p.add(numBinsPanel, c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodSampleQuantiles = new JRadioButton("Sample quantiles");
    m_methodSampleQuantiles.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_equalityMethod.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_sampleQuantiles.setEnabled(m_methodSampleQuantiles.isSelected());
        }
    });
    p.add(m_methodSampleQuantiles, c);
    c.gridy++;
    JPanel quantilesPanel = new JPanel(new GridBagLayout());
    int gridy = c.gridy;
    c.gridy = 0;
    c.gridwidth = 1;
    quantilesPanel.add(new JLabel("Quantiles (comma separated):"), c);
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 1;
    m_sampleQuantiles = new JTextField();
    quantilesPanel.add(m_sampleQuantiles, c);
    quantilesPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    c.gridy = gridy;
    c.gridx = 0;
    c.gridwidth = 1;
    p.add(quantilesPanel, c);
    ButtonGroup method = new ButtonGroup();
    method.add(m_methodFixedNumber);
    method.add(m_methodSampleQuantiles);
    p.setBorder(BorderFactory.createTitledBorder("Binning Method"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) EqualityMethod(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod)

Example 34 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method createNumberFormatSettingsTab.

private JPanel createNumberFormatSettingsTab() {
    JPanel p = new JPanel(new GridBagLayout());
    m_defaultFormatting = new JRadioButton("Default formatting");
    m_advancedFormatting = new JRadioButton("Advanced formatting");
    ButtonGroup formatting = new ButtonGroup();
    formatting.add(m_defaultFormatting);
    formatting.add(m_advancedFormatting);
    m_outputFormat = new JComboBox<OutputFormat>(OutputFormat.values());
    m_precision = new JSpinner(new SpinnerNumberModel(3, 0, Integer.MAX_VALUE, 1));
    m_precisionMode = new JComboBox<PrecisionMode>(PrecisionMode.values());
    m_roundingMode = new JComboBox<RoundingMode>(getRoundingModes());
    ActionListener formattingListener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_outputFormat.setEnabled(m_advancedFormatting.isSelected());
            m_precision.setEnabled(m_advancedFormatting.isSelected());
            m_precisionMode.setEnabled(m_advancedFormatting.isSelected());
            m_roundingMode.setEnabled(m_advancedFormatting.isSelected());
        }
    };
    m_defaultFormatting.addActionListener(formattingListener);
    m_advancedFormatting.addActionListener(formattingListener);
    GridBagConstraints gbc = new GridBagConstraints();
    Insets indentedInsets = new Insets(5, 15, 5, 5);
    Insets normalInsets = new Insets(5, 5, 5, 5);
    gbc.insets = normalInsets;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    p.add(m_defaultFormatting, gbc);
    gbc.gridy++;
    p.add(m_advancedFormatting, gbc);
    gbc.gridwidth = 1;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Output format"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_outputFormat, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Precision"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_precision, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Precision mode"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_precisionMode, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = indentedInsets;
    p.add(new JLabel("Rounding mode"), gbc);
    gbc.gridx++;
    gbc.insets = normalInsets;
    p.add(m_roundingMode, gbc);
    gbc.gridx++;
    gbc.gridy++;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    p.add(new JLabel(), gbc);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) RoundingMode(java.math.RoundingMode) ActionEvent(java.awt.event.ActionEvent) OutputFormat(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.OutputFormat) JLabel(javax.swing.JLabel) SpinnerNumberModel(javax.swing.SpinnerNumberModel) PrecisionMode(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.PrecisionMode) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner)

Example 35 with SpinnerNumberModel

use of javax.swing.SpinnerNumberModel in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method createMethodUIControls.

private JPanel createMethodUIControls() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 0;
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodFixedNumber = new JRadioButton("Fixed number of bins");
    m_methodFixedNumber.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(m_methodFixedNumber.isSelected());
            m_sampleQuantiles.setEnabled(!m_methodFixedNumber.isSelected());
        }
    });
    p.add(m_methodFixedNumber, c);
    c.gridy++;
    JPanel numBinsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    numBinsPanel.add(new JLabel("Number of bins:"));
    m_numBins = new JSpinner(new SpinnerNumberModel(5, 1, Integer.MAX_VALUE, 1));
    numBinsPanel.add(m_numBins);
    numBinsPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    p.add(numBinsPanel, c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodSampleQuantiles = new JRadioButton("Sample quantiles");
    m_methodSampleQuantiles.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_sampleQuantiles.setEnabled(m_methodSampleQuantiles.isSelected());
        }
    });
    p.add(m_methodSampleQuantiles, c);
    c.gridy++;
    JPanel quantilesPanel = new JPanel(new GridBagLayout());
    int gridy = c.gridy;
    c.gridy = 0;
    c.gridwidth = 1;
    quantilesPanel.add(new JLabel("Quantiles (comma separated):"), c);
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 1;
    m_sampleQuantiles = new JTextField();
    quantilesPanel.add(m_sampleQuantiles, c);
    quantilesPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    c.gridy = gridy;
    c.gridx = 0;
    c.gridwidth = 1;
    p.add(quantilesPanel, c);
    ButtonGroup method = new ButtonGroup();
    method.add(m_methodFixedNumber);
    method.add(m_methodSampleQuantiles);
    p.setBorder(BorderFactory.createTitledBorder("Binning Method"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner)

Aggregations

SpinnerNumberModel (javax.swing.SpinnerNumberModel)84 JSpinner (javax.swing.JSpinner)63 JLabel (javax.swing.JLabel)41 JPanel (javax.swing.JPanel)40 ActionEvent (java.awt.event.ActionEvent)35 GridBagLayout (java.awt.GridBagLayout)25 Dimension (java.awt.Dimension)22 ActionListener (java.awt.event.ActionListener)22 ChangeEvent (javax.swing.event.ChangeEvent)19 Insets (java.awt.Insets)17 GridBagConstraints (java.awt.GridBagConstraints)16 JRadioButton (javax.swing.JRadioButton)16 JCheckBox (javax.swing.JCheckBox)15 ButtonGroup (javax.swing.ButtonGroup)12 ChangeListener (javax.swing.event.ChangeListener)12 JButton (javax.swing.JButton)11 JTextField (javax.swing.JTextField)10 BorderLayout (java.awt.BorderLayout)8 BoxLayout (javax.swing.BoxLayout)7 FormLayout (com.jgoodies.forms.layout.FormLayout)6