Search in sources :

Example 91 with ButtonGroup

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

the class RankNodeDialog method initPanel.

private JPanel initPanel() {
    JPanel jp = new JPanel();
    jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
    Box rankColSelection = Box.createHorizontalBox();
    // add column list
    Box rankCols = initRankTableBox();
    rankColSelection.add(rankCols);
    // add buttons
    Box rankButtonBox = initRankButtonBox();
    rankColSelection.add(rankButtonBox);
    Box groupColSelection = Box.createHorizontalBox();
    groupColSelection.add(initGroupTableBox());
    groupColSelection.add(initGroupButtonBox());
    Box otherOptions = Box.createHorizontalBox();
    otherOptions.add(Box.createHorizontalGlue());
    Box modusBox = Box.createHorizontalBox();
    modusBox.setBorder(new TitledBorder("Ranking Mode"));
    modusBox.add(new JLabel("Mode:  "));
    Box radioPanel = Box.createVerticalBox();
    ButtonGroup modusGroup = new ButtonGroup();
    m_modusGroup = modusGroup;
    for (RankMode rankMode : RankMode.values()) {
        JRadioButton radio = new JRadioButton(rankMode.toString());
        modusGroup.add(radio);
        radioPanel.add(radio);
        if (m_rankMode.getStringValue().equals(radio.getText())) {
            radio.setSelected(true);
        }
    }
    modusBox.add(radioPanel);
    otherOptions.add(modusBox);
    otherOptions.add(Box.createHorizontalGlue());
    otherOptions.add(initOtherOptionsBox());
    otherOptions.add(Box.createHorizontalGlue());
    jp.add(rankColSelection);
    jp.add(groupColSelection);
    jp.add(otherOptions);
    otherOptions.revalidate();
    otherOptions.repaint();
    return jp;
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) RankMode(org.knime.base.node.preproc.rank.RankNodeModel.RankMode) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) TitledBorder(javax.swing.border.TitledBorder)

Example 92 with ButtonGroup

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

the class NormalizerNodeDialog method generateContent.

/*
     * Generates the radio buttons and text fields
     */
private JPanel generateContent() {
    JPanel panel = new JPanel();
    // min-max
    JPanel panel1 = new JPanel();
    GridLayout gl = new GridLayout(2, 4);
    panel1.setLayout(gl);
    m_minmaxButton = new JRadioButton("Min-Max Normalization");
    m_minmaxButton.setSelected(true);
    JLabel nmin = new JLabel("Min: ");
    JPanel spanel1 = new JPanel();
    spanel1.setLayout(new BorderLayout());
    spanel1.add(nmin, BorderLayout.EAST);
    spanel1.setMaximumSize(new Dimension(30, 10));
    m_newminTextField = new JTextField(2);
    JLabel nmax = new JLabel("Max: ");
    JPanel spanel2 = new JPanel();
    spanel2.setLayout(new BorderLayout());
    spanel2.add(nmax, BorderLayout.EAST);
    spanel2.setMaximumSize(new Dimension(30, 10));
    m_newmaxTextField = new JTextField(2);
    panel1.add(m_minmaxButton);
    panel1.add(spanel1);
    panel1.add(m_newminTextField);
    panel1.add(Box.createHorizontalGlue());
    panel1.add(new JPanel());
    panel1.add(spanel2);
    panel1.add(m_newmaxTextField);
    panel1.add(Box.createHorizontalGlue());
    // z-score
    JPanel panel2 = new JPanel();
    panel2.setLayout(new BorderLayout());
    m_zscoreButton = new JRadioButton("Z-Score Normalization");
    panel2.add(m_zscoreButton, BorderLayout.WEST);
    // decimal scaling
    JPanel panel3 = new JPanel();
    panel3.setLayout(new BorderLayout());
    m_decButton = new JRadioButton("Normalization by Decimal Scaling");
    panel3.add(m_decButton, BorderLayout.WEST);
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(m_minmaxButton);
    group.add(m_zscoreButton);
    group.add(m_decButton);
    m_minmaxButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (m_minmaxButton.isSelected()) {
                m_filterpanel.setEnabled(true);
                m_newminTextField.setEnabled(true);
                m_newmaxTextField.setEnabled(true);
            }
        }
    });
    m_zscoreButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (m_zscoreButton.isSelected()) {
                m_filterpanel.setEnabled(true);
                m_newminTextField.setEnabled(false);
                m_newmaxTextField.setEnabled(false);
            }
        }
    });
    m_decButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (m_decButton.isSelected()) {
                m_filterpanel.setEnabled(true);
                m_newminTextField.setEnabled(false);
                m_newmaxTextField.setEnabled(false);
            }
        }
    });
    BoxLayout bly = new BoxLayout(panel, BoxLayout.Y_AXIS);
    panel.setLayout(bly);
    panel.add(panel1);
    panel.add(panel2);
    panel.add(panel3);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) ItemListener(java.awt.event.ItemListener) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 93 with ButtonGroup

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

the class EditNumericDomainNodeDialogPane method createMinMaxTab.

private void createMinMaxTab() {
    m_filterPanel = new DataColumnSpecFilterPanel();
    m_filterPanel.setIncludeTitle(" Include ");
    m_filterPanel.setExcludeTitle(" Exclude ");
    m_lowerBField = createTextField("0.0");
    m_upperBField = createTextField("1.0");
    JPanel retainMinMaxPanel = new JPanel(new GridLayout(2, 2));
    retainMinMaxPanel.setBorder(BorderFactory.createTitledBorder("Domain"));
    createBoundedBox(retainMinMaxPanel, m_lowerBField, LOWER_B + ": ");
    createBoundedBox(retainMinMaxPanel, m_upperBField, UPPER_B + ": ");
    Box outOfDomainBox = Box.createVerticalBox();
    outOfDomainBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Out of Domain Policy"));
    m_buttonGrp = new ButtonGroup();
    for (final DomainOverflowPolicy handler : DomainOverflowPolicy.values()) {
        JRadioButton jRadioButton = new JRadioButton(handler.getDescription());
        jRadioButton.setActionCommand(handler.toString());
        jRadioButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                m_handler = handler;
            }
        });
        m_buttonGrp.add(jRadioButton);
        outOfDomainBox.add(jRadioButton, Component.LEFT_ALIGNMENT);
    }
    JPanel tabpanel = new JPanel();
    tabpanel.setLayout(new BorderLayout());
    tabpanel.add(m_filterPanel, BorderLayout.NORTH);
    tabpanel.add(retainMinMaxPanel, BorderLayout.WEST);
    outOfDomainBox.add(Box.createHorizontalGlue());
    tabpanel.add(outOfDomainBox, BorderLayout.SOUTH);
    addTab("Edit Domain", tabpanel);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JRadioButton(javax.swing.JRadioButton) DataColumnSpecFilterPanel(org.knime.core.node.util.filter.column.DataColumnSpecFilterPanel) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) Box(javax.swing.Box) DomainOverflowPolicy(org.knime.base.node.preproc.domain.editnumeric.EditNumericDomainNodeModel.DomainOverflowPolicy)

Example 94 with ButtonGroup

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

the class RowFilterNodeDialogPane method createDialogPanel.

protected JPanel createDialogPanel() {
    JPanel result = new JPanel();
    result.setLayout(new BoxLayout(result, BoxLayout.X_AXIS));
    // the panel on the left side for the filter selection
    Box selectionBox = Box.createVerticalBox();
    selectionBox.setMaximumSize(new Dimension(300, 500));
    m_rangeInclRadio = new JRadioButton("Include rows by number");
    m_rangeExclRadio = new JRadioButton("Exclude rows by number");
    m_rangeInclRadio.setActionCommand("range");
    m_rangeExclRadio.setActionCommand("range");
    addActionListener(m_rangeInclRadio);
    addActionListener(m_rangeExclRadio);
    m_rowIDInclRadio = new JRadioButton("Include rows by row ID");
    m_rowIDExclRadio = new JRadioButton("Exclude rows by row ID");
    m_rowIDInclRadio.setActionCommand("id");
    m_rowIDExclRadio.setActionCommand("id");
    addActionListener(m_rowIDInclRadio);
    addActionListener(m_rowIDExclRadio);
    m_colValInclRadio = new JRadioButton("Include rows by attribute value");
    m_colValExclRadio = new JRadioButton("Exclude rows by attribute value");
    m_colValInclRadio.setActionCommand("colval");
    m_colValExclRadio.setActionCommand("colval");
    addActionListener(m_colValInclRadio);
    addActionListener(m_colValExclRadio);
    // only one at a time should be selected
    ButtonGroup group = new ButtonGroup();
    group.add(m_rangeInclRadio);
    group.add(m_rangeExclRadio);
    group.add(m_rowIDInclRadio);
    group.add(m_rowIDExclRadio);
    group.add(m_colValInclRadio);
    group.add(m_colValExclRadio);
    selectionBox.add(Box.createVerticalGlue());
    selectionBox.add(m_colValInclRadio);
    selectionBox.add(m_colValExclRadio);
    selectionBox.add(Box.createVerticalStrut(3));
    selectionBox.add(m_rangeInclRadio);
    selectionBox.add(m_rangeExclRadio);
    selectionBox.add(Box.createVerticalStrut(3));
    selectionBox.add(m_rowIDInclRadio);
    selectionBox.add(m_rowIDExclRadio);
    selectionBox.add(Box.createVerticalGlue());
    // the panel containing the filter panels. They will be instantiated
    // in loadSettings
    m_filterPanel = new JPanel();
    m_filterPanel.setLayout(new BoxLayout(m_filterPanel, BoxLayout.Y_AXIS));
    m_filterPanel.setPreferredSize(new Dimension(400, 400));
    result.add(selectionBox);
    result.add(Box.createHorizontalStrut(7));
    result.add(m_filterPanel);
    return result;
}
Also used : JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) Box(javax.swing.Box) Dimension(java.awt.Dimension)

Example 95 with ButtonGroup

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

the class CharsetNamePanel method getSelectionPanel.

private Container getSelectionPanel() {
    m_group = new ButtonGroup();
    /*
         * use action commands that are valid charset names (we use them later
         * directly as parameter). Except for "default" and "user defined".
         */
    m_default = new JRadioButton(DEFAULT_LABEL);
    m_default.setToolTipText("uses the default decoding set by the operating system");
    m_default.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_default);
    m_iso8859 = new JRadioButton("ISO-8859-1");
    m_iso8859.setToolTipText("ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1");
    m_iso8859.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_iso8859);
    m_utf8 = new JRadioButton("UTF-8");
    m_utf8.setToolTipText("Eight-bit UCS Transformation Format");
    m_utf8.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_utf8);
    m_utf16le = new JRadioButton("UTF-16LE");
    m_utf16le.setToolTipText("Sixteen-bit UCS Transformation Format, little-endian byte order");
    m_utf16le.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_utf16le);
    m_utf16be = new JRadioButton("UTF-16BE");
    m_utf16be.setToolTipText("Sixteen-bit UCS Transformation Format, big-endian byte order");
    m_utf16be.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_utf16be);
    m_utf16 = new JRadioButton("UTF-16");
    m_utf16.setToolTipText("Sixteen-bit UCS Transformation Format, byte order identified by an optional " + "byte-order mark in the file");
    m_utf16.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_utf16);
    m_custom = new JRadioButton(CUSTOM_LABEL);
    m_custom.setToolTipText("Enter a valid charset name supported by the Java Virtual Machine");
    m_custom.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            buttonsChanged();
        }
    });
    m_group.add(m_custom);
    m_customName = new JTextField(20);
    m_customName.setPreferredSize(new Dimension(250, 25));
    m_customName.setMaximumSize(new Dimension(250, 25));
    m_customName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(final DocumentEvent e) {
            checkCustomCharsetName();
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            checkCustomCharsetName();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            checkCustomCharsetName();
        }
    });
    JPanel result = new JPanel(new GridBagLayout());
    result.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Select a character set for decoding:"));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    result.add(m_default, gbc);
    gbc.gridy++;
    result.add(m_iso8859, gbc);
    gbc.gridy++;
    result.add(m_utf8, gbc);
    gbc.gridy++;
    result.add(m_utf16le, gbc);
    gbc.gridy++;
    result.add(m_utf16be, gbc);
    gbc.gridy++;
    result.add(m_utf16, gbc);
    gbc.gridy++;
    result.add(m_custom, gbc);
    gbc.gridx++;
    result.add(m_customName, gbc);
    gbc.gridx++;
    gbc.gridy++;
    gbc.weightx = 1;
    gbc.weighty = 1;
    result.add(new JPanel(), gbc);
    return result;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) ChangeListener(javax.swing.event.ChangeListener)

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