Search in sources :

Example 1 with OutputFormat

use of org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.OutputFormat 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 2 with OutputFormat

use of org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.OutputFormat in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method saveSettingsTo.

/**
 * @param settings write intervals to
 * @throws InvalidSettingsException if a bin name is empty
 * @see NodeDialogPane#saveSettingsTo(NodeSettingsWO)
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    DataColumnSpecFilterConfiguration config = AutoBinnerLearnNodeModel.createDCSFilterConfiguration();
    m_filterPanel.saveConfiguration(config);
    m_settings.setFilterConfiguration(config);
    Method method = m_methodFixedNumber.isSelected() ? Method.fixedNumber : Method.sampleQuantiles;
    m_settings.setMethod(method);
    m_settings.setBinCount(((Number) m_numBins.getValue()).intValue());
    m_settings.setEqualityMethod((EqualityMethod) m_equalityMethod.getSelectedItem());
    try {
        List<Double> sampleQuantiles = explode(m_sampleQuantiles.getText());
        double[] sq = normalizeSampleQuantiles(sampleQuantiles);
        m_settings.setSampleQuantiles(sq);
    } catch (NumberFormatException e) {
        throw new InvalidSettingsException("Cannot parse the list of quantiles. Changes are " + "not applied.");
    }
    BinNaming binNaming = null;
    if (m_binNamingNumbered.isSelected()) {
        binNaming = BinNaming.numbered;
    }
    if (m_binNamingEdges.isSelected()) {
        binNaming = BinNaming.edges;
    }
    if (m_binNamingMidpoints.isSelected()) {
        binNaming = BinNaming.midpoints;
    }
    m_settings.setBinNaming(binNaming);
    m_settings.setReplaceColumn(m_replaceColumn.isSelected());
    m_settings.setIntegerBounds(m_integerBounds.isSelected());
    m_settings.setAdvancedFormatting(m_advancedFormatting.isSelected());
    m_settings.setOutputFormat((OutputFormat) m_outputFormat.getSelectedItem());
    m_settings.setPrecision(((Number) m_precision.getValue()).intValue());
    m_settings.setPrecisionMode((PrecisionMode) m_precisionMode.getSelectedItem());
    m_settings.setRoundingMode((RoundingMode) m_roundingMode.getSelectedItem());
    m_settings.saveSettings(settings);
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) EqualityMethod(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod) Method(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method) BinNaming(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)

Example 3 with OutputFormat

use of org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.OutputFormat 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.autobinner3.AutoBinnerLearnSettings.OutputFormat) JLabel(javax.swing.JLabel) SpinnerNumberModel(javax.swing.SpinnerNumberModel) PrecisionMode(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.PrecisionMode) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner)

Aggregations

GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 RoundingMode (java.math.RoundingMode)2 ButtonGroup (javax.swing.ButtonGroup)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JRadioButton (javax.swing.JRadioButton)2 JSpinner (javax.swing.JSpinner)2 SpinnerNumberModel (javax.swing.SpinnerNumberModel)2 OutputFormat (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.OutputFormat)1 PrecisionMode (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.PrecisionMode)1 BinNaming (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)1 EqualityMethod (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod)1 Method (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method)1 OutputFormat (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.OutputFormat)1 PrecisionMode (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.PrecisionMode)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1