Search in sources :

Example 81 with ButtonGroup

use of javax.swing.ButtonGroup 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)

Example 82 with ButtonGroup

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

the class AutoBinnerLearnNodeDialogPane method createBinNamingUIControls.

private JPanel createBinNamingUIControls() {
    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.gridy = 0;
    c.gridx = 0;
    c.weightx = 0;
    c.gridwidth = 2;
    m_binNamingNumbered = new JRadioButton("Numbered");
    p.add(m_binNamingNumbered, c);
    c.gridx = 2;
    c.gridwidth = 1;
    c.weightx = 1;
    c.insets = new Insets(6, 2, 2, 2);
    JLabel exampleNumbered = new JLabel("e.g.: Bin 1, Bin 2, Bin 3");
    exampleNumbered.setEnabled(false);
    p.add(exampleNumbered, c);
    c.weightx = 0;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    m_binNamingEdges = new JRadioButton("Borders");
    p.add(m_binNamingEdges, c);
    c.gridx = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.insets = new Insets(6, 2, 2, 2);
    JLabel exampleEdges = new JLabel("e.g.: [-10,0], (0,10], (10,20]");
    exampleEdges.setEnabled(false);
    p.add(exampleEdges, c);
    c.weightx = 0;
    c.insets = new Insets(2, 2, 2, 2);
    ButtonGroup method = new ButtonGroup();
    method.add(m_binNamingNumbered);
    method.add(m_binNamingEdges);
    p.setBorder(BorderFactory.createTitledBorder("Bin Naming"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) JLabel(javax.swing.JLabel)

Example 83 with ButtonGroup

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

the class MissingValueHandling2Panel method createEastLayout.

/**
 * @param setting
 * @param panel
 * @param spec
 */
private void createEastLayout(final MissingValueHandling2ColSetting setting, final JPanel panel, final DataColumnSpec... spec) {
    ButtonGroup buttonGroup = new ButtonGroup();
    ActionListener actionListener = new ButtonListener();
    // NO HANDLING Button
    m_nothingButton = new JRadioButton("Do Nothing");
    m_nothingButton.setToolTipText("No missing value handling.");
    m_nothingButton.addActionListener(actionListener);
    buttonGroup.add(m_nothingButton);
    panel.add(m_nothingButton);
    // REMOVE Button
    m_removeButton = new JRadioButton("Remove Row");
    m_removeButton.setToolTipText("Ignore rows that contain a " + "missing value");
    m_removeButton.addActionListener(actionListener);
    buttonGroup.add(m_removeButton);
    panel.add(m_removeButton);
    if (setting.getType() == MissingValueHandling2ColSetting.TYPE_DOUBLE || setting.getType() == MissingValueHandling2ColSetting.TYPE_INT) {
        // MIN Button
        m_minButton = new JRadioButton("Min");
        m_minButton.setToolTipText("Replaces missing values by the minimum " + "of the values in a column");
        m_minButton.addActionListener(actionListener);
        buttonGroup.add(m_minButton);
        panel.add(m_minButton);
        // MAX Button
        m_maxButton = new JRadioButton("Max");
        m_maxButton.setToolTipText("Replaces missing values by the " + "maximum of the values in a column");
        m_maxButton.addActionListener(actionListener);
        buttonGroup.add(m_maxButton);
        panel.add(m_maxButton);
        // MEAN Button
        m_meanButton = new JRadioButton("Mean");
        m_meanButton.setToolTipText("Replaces missing values by the mean " + "of the values in a column");
        m_meanButton.addActionListener(actionListener);
        buttonGroup.add(m_meanButton);
        panel.add(m_meanButton);
        if (setting.getType() == MissingValueHandling2ColSetting.TYPE_DOUBLE) {
            // even number of components
            panel.add(new JLabel());
        }
    } else {
        m_meanButton = null;
        m_minButton = null;
        m_maxButton = null;
    }
    if (setting.getType() == MissingValueHandling2ColSetting.TYPE_INT || setting.getType() == MissingValueHandling2ColSetting.TYPE_STRING) {
        m_mostFrequentButton = new JRadioButton("Most Frequent");
        m_mostFrequentButton.setToolTipText("Replaces missing values " + "by the most frequent value in a column");
        m_mostFrequentButton.addActionListener(actionListener);
        buttonGroup.add(m_mostFrequentButton);
        panel.add(m_mostFrequentButton);
        if (setting.getType() == MissingValueHandling2ColSetting.TYPE_STRING) {
            // even number of components
            panel.add(new JLabel());
        }
    } else {
        m_mostFrequentButton = null;
    }
    if (setting.getType() != MissingValueHandling2ColSetting.TYPE_UNKNOWN) {
        // FIX Button
        m_fixButton = new JRadioButton("Fix Value: ");
        m_fixButton.setToolTipText("Replaces missing values by a fixed value");
        m_fixButton.addActionListener(actionListener);
        buttonGroup.add(m_fixButton);
        panel.add(m_fixButton);
        m_fixText = getFixTextField(setting, spec);
        JPanel fixPanel = new JPanel(new BorderLayout());
        fixPanel.add(minHeight(createSpacer(1)), BorderLayout.NORTH);
        fixPanel.add(ViewUtils.getInFlowLayout(m_fixText), BorderLayout.CENTER);
        fixPanel.add(minHeight(createSpacer(1)), BorderLayout.SOUTH);
        panel.add(fixPanel);
    } else {
        m_fixButton = null;
        m_fixText = null;
    }
    switch(setting.getMethod()) {
        case MissingValueHandling2ColSetting.METHOD_FIX_VAL:
            m_fixButton.doClick();
            break;
        case MissingValueHandling2ColSetting.METHOD_IGNORE_ROWS:
            m_removeButton.doClick();
            break;
        case MissingValueHandling2ColSetting.METHOD_MOST_FREQUENT:
            m_mostFrequentButton.doClick();
            break;
        case MissingValueHandling2ColSetting.METHOD_MAX:
            m_maxButton.doClick();
            break;
        case MissingValueHandling2ColSetting.METHOD_MEAN:
            m_meanButton.doClick();
            break;
        case MissingValueHandling2ColSetting.METHOD_MIN:
            m_minButton.doClick();
            break;
        default:
            m_nothingButton.doClick();
    }
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) JLabel(javax.swing.JLabel)

Example 84 with ButtonGroup

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

the class Axis method createPopupMenu.

private JPopupMenu createPopupMenu() {
    if (getCoordinate() == null) {
        return null;
    }
    m_currFormat = NORMAL;
    JPopupMenu popupMenu = new JPopupMenu();
    createNotationMenu(popupMenu);
    // policies
    if (m_coordinate != null) {
        List<PolicyStrategy> strategies = new LinkedList<PolicyStrategy>();
        Set<PolicyStrategy> policies = m_coordinate.getCompatiblePolicies();
        if (policies != null) {
            strategies.addAll(policies);
            Collections.sort(strategies, new Comparator<PolicyStrategy>() {

                /**
                 * {@inheritDoc}
                 */
                @Override
                public int compare(final PolicyStrategy o1, final PolicyStrategy o2) {
                    return o1.getDisplayName().compareTo(o2.getDisplayName());
                }
            });
        }
        JMenu tickPolicyMenu = new JMenu("Tick policies");
        ButtonGroup tickPolicyButtons = new ButtonGroup();
        if (strategies.size() > 0) {
            popupMenu.add(tickPolicyMenu);
            for (PolicyStrategy strategy : strategies) {
                final PolicyStrategy tempStrategy = strategy;
                JRadioButtonMenuItem tickPolicy = new JRadioButtonMenuItem(strategy.getDisplayName());
                tickPolicyButtons.add(tickPolicy);
                tickPolicyMenu.add(tickPolicy);
                if (strategy.equals(m_coordinate.getCurrentPolicy())) {
                    tickPolicy.setSelected(true);
                }
                tickPolicy.addItemListener(new ItemListener() {

                    /**
                     * {@inheritDoc}
                     */
                    @Override
                    public void itemStateChanged(final ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            m_coordinate.setPolicy(tempStrategy);
                            // recreate popup menu
                            setComponentPopupMenu(createPopupMenu());
                            if (tempStrategy.isMappingAllowed()) {
                                m_mappingMethodMenu.setEnabled(true);
                                m_notationsMenu.setEnabled(true);
                            } else {
                                // hide mapping methods
                                m_mappingMethodMenu.setEnabled(false);
                                m_notationsMenu.setEnabled(false);
                                if (getCoordinate() != null) {
                                    getCoordinate().setActiveMappingMethod(null);
                                }
                            }
                            notifyChangeListeners();
                        }
                    }
                });
            }
        }
        // add strategies
        Set<MappingMethod> mappingMethods = m_coordinate.getCompatibleMappingMethods();
        m_mappingMethodMenu = new JMenu("Mapping Methods");
        if (mappingMethods != null && mappingMethods.size() > 0) {
            popupMenu.add(m_mappingMethodMenu);
            ButtonGroup buttons = new ButtonGroup();
            final Map<MappingMethod, JRadioButtonMenuItem> checkboxes = new HashMap<MappingMethod, JRadioButtonMenuItem>();
            JRadioButtonMenuItem none = new JRadioButtonMenuItem("none", true);
            buttons.add(none);
            none.addItemListener(new ItemListener() {

                @Override
                public void itemStateChanged(final ItemEvent e) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        m_coordinate.setActiveMappingMethod(null);
                        notifyChangeListeners();
                    }
                }
            });
            m_mappingMethodMenu.add(none);
            for (MappingMethod method : mappingMethods) {
                // final needed
                final MappingMethod tempMethod = method;
                JRadioButtonMenuItem checkbox = new JRadioButtonMenuItem(method.getDisplayName(), false);
                checkbox.setEnabled(method.isCompatibleWithDomain(getCoordinate().getDomain()));
                checkboxes.put(method, checkbox);
                buttons.add(checkbox);
                if (method.equals(m_coordinate.getActiveMappingMethod())) {
                    checkbox.setSelected(true);
                }
                checkbox.addItemListener(new ItemListener() {

                    /**
                     * {@inheritDoc}
                     */
                    @Override
                    public void itemStateChanged(final ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            m_coordinate.setActiveMappingMethod(tempMethod);
                        }
                        notifyChangeListeners();
                    }
                });
                m_mappingMethodMenu.add(checkbox);
            }
            for (Map.Entry<MappingMethod, JRadioButtonMenuItem> entry : checkboxes.entrySet()) {
                if (entry.getKey().isCompatibleWithDomain(getCoordinate().getDomain())) {
                    entry.getValue().setEnabled(true);
                }
            }
        }
    }
    if (popupMenu.getComponentCount() < 1) {
        return null;
    }
    return popupMenu;
}
Also used : PolicyStrategy(org.knime.base.util.coordinate.PolicyStrategy) ItemEvent(java.awt.event.ItemEvent) HashMap(java.util.HashMap) MappingMethod(org.knime.base.util.coordinate.MappingMethod) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JPopupMenu(javax.swing.JPopupMenu) LinkedList(java.util.LinkedList) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener) HashMap(java.util.HashMap) Map(java.util.Map) JMenu(javax.swing.JMenu)

Example 85 with ButtonGroup

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

the class BasisFunctionPredictor2NodeDialog method addOtherControls.

/**
 * {@inheritDoc}
 */
@Override
protected void addOtherControls(final JPanel panel) {
    m_dontKnow = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 1.0, 0.1));
    m_defaultButton = new JRadioButton("Default ", true);
    m_setButton = new JRadioButton("Use ");
    m_ignoreButton = new JRadioButton("Ignore ", true);
    // add don't know probability
    m_ignoreButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            selectionChanged();
        }
    });
    ButtonGroup bg = new ButtonGroup();
    bg.add(m_ignoreButton);
    bg.add(m_defaultButton);
    bg.add(m_setButton);
    m_dontKnow.setEditor(new JSpinner.NumberEditor(m_dontKnow, "#.##########"));
    m_dontKnow.setPreferredSize(new Dimension(75, 25));
    JPanel dontKnowPanel = new JPanel(new GridLayout(3, 1));
    dontKnowPanel.setBorder(BorderFactory.createTitledBorder(" Don't Know Class "));
    FlowLayout left = new FlowLayout(FlowLayout.LEFT);
    final JPanel ignorePanel = new JPanel(left), defaultPanel = new JPanel(left);
    ignorePanel.add(m_ignoreButton);
    defaultPanel.add(m_defaultButton);
    dontKnowPanel.add(ignorePanel);
    dontKnowPanel.add(defaultPanel);
    JPanel usePanel = new JPanel(left);
    dontKnowPanel.add(usePanel);
    usePanel.add(m_setButton);
    usePanel.add(m_dontKnow);
    panel.add(dontKnowPanel);
    m_defaultButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_dontKnow.setEnabled(false);
        }
    });
    m_setButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_dontKnow.setEnabled(true);
        }
    });
    getLayout().putConstraint(SpringLayout.EAST, dontKnowPanel, 0, SpringLayout.EAST, panel);
    getLayout().putConstraint(SpringLayout.WEST, dontKnowPanel, 0, SpringLayout.WEST, panel);
    super.setLastAdded(dontKnowPanel);
    getPanel().setPreferredSize(new Dimension(400, 240));
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) Dimension(java.awt.Dimension)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47