Search in sources :

Example 81 with JComboBox

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

the class RegressionTreeLearnerNodeView method createRightPanel.

/* Create the Panel with the outline view and the controls */
private JPanel createRightPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    p.setBackground(Color.white);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(6, 6, 4, 6);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    p.add(m_graph.createOutlineView(), c);
    c.weighty = 0;
    c.gridy++;
    p.add(new JLabel("Zoom:"), c);
    c.gridy++;
    final Map<Object, Float> scaleFactors = new LinkedHashMap<Object, Float>();
    scaleFactors.put("140.0%", 140f);
    scaleFactors.put("120.0%", 120f);
    scaleFactors.put("100.0%", 100f);
    scaleFactors.put("80.0%", 80f);
    scaleFactors.put("60.0%", 60f);
    final JComboBox scaleFactorComboBox = new JComboBox(scaleFactors.keySet().toArray());
    scaleFactorComboBox.setEditable(true);
    scaleFactorComboBox.setSelectedItem("100.0%");
    scaleFactorComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            Object selected = scaleFactorComboBox.getSelectedItem();
            Float scaleFactor = scaleFactors.get(selected);
            if (null == scaleFactor) {
                String str = ((String) selected).trim();
                if (str.endsWith("%")) {
                    scaleFactor = Float.parseFloat(str.substring(0, str.length() - 1));
                } else {
                    scaleFactor = Float.parseFloat(str);
                }
            }
            if (scaleFactor < 10) {
                LOGGER.error("A zoom which is lower than 10% " + "is not supported");
                scaleFactor = 10f;
            }
            if (scaleFactor > 500) {
                LOGGER.error("A zoom which is greater than 500% " + "is not supported");
                scaleFactor = 500f;
            }
            String sf = Float.toString(scaleFactor) + "%";
            scaleFactorComboBox.setSelectedItem(sf);
            scaleFactor = scaleFactor / 100f;
            m_graph.setScaleFactor(scaleFactor);
            getComponent().validate();
            getComponent().repaint();
        }
    });
    p.add(scaleFactorComboBox, c);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) LinkedHashMap(java.util.LinkedHashMap) ActionListener(java.awt.event.ActionListener)

Example 82 with JComboBox

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

the class TreeEnsembleLearnerNodeView2 method createRightPanel.

/* Create the Panel with the outline view and the controls */
private JPanel createRightPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    p.setBackground(Color.white);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(6, 6, 4, 6);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    p.add(m_graph.createOutlineView(), c);
    c.weighty = 0;
    c.gridy++;
    p.add(new JLabel("Zoom:"), c);
    c.gridy++;
    final Map<Object, Float> scaleFactors = new LinkedHashMap<Object, Float>();
    scaleFactors.put("140.0%", 140f);
    scaleFactors.put("120.0%", 120f);
    scaleFactors.put("100.0%", 100f);
    scaleFactors.put("80.0%", 80f);
    scaleFactors.put("60.0%", 60f);
    final JComboBox scaleFactorComboBox = new JComboBox(scaleFactors.keySet().toArray());
    scaleFactorComboBox.setEditable(true);
    scaleFactorComboBox.setSelectedItem("100.0%");
    scaleFactorComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            Object selected = scaleFactorComboBox.getSelectedItem();
            Float scaleFactor = scaleFactors.get(selected);
            if (null == scaleFactor) {
                String str = ((String) selected).trim();
                if (str.endsWith("%")) {
                    scaleFactor = Float.parseFloat(str.substring(0, str.length() - 1));
                } else {
                    scaleFactor = Float.parseFloat(str);
                }
            }
            if (scaleFactor < 10) {
                LOGGER.error("A zoom which is lower than 10% " + "is not supported");
                scaleFactor = 10f;
            }
            if (scaleFactor > 500) {
                LOGGER.error("A zoom which is greater than 500% " + "is not supported");
                scaleFactor = 500f;
            }
            String sf = Float.toString(scaleFactor) + "%";
            scaleFactorComboBox.setSelectedItem(sf);
            scaleFactor = scaleFactor / 100f;
            m_graph.setScaleFactor(scaleFactor);
            getComponent().validate();
            getComponent().repaint();
        }
    });
    p.add(scaleFactorComboBox, c);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) LinkedHashMap(java.util.LinkedHashMap) ActionListener(java.awt.event.ActionListener)

Example 83 with JComboBox

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

the class LogRegLearnerNodeDialogPane method createTargetOptionsPanel.

/**
 * Create options panel for the target.
 */
private JPanel createTargetOptionsPanel() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.BASELINE_LEADING;
    c.insets = new Insets(5, 5, 0, 0);
    p.add(new JLabel("Target Column:"), c);
    c.gridx++;
    m_selectionPanel = new ColumnSelectionPanel(new EmptyBorder(0, 0, 0, 0), NominalValue.class);
    m_selectionPanel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            updateTargetCategories((DataCell) m_targetReferenceCategory.getSelectedItem());
        }
    });
    p.add(m_selectionPanel, c);
    c.gridx = 0;
    c.gridy++;
    p.add(new JLabel("Reference Category:"), c);
    c.gridx++;
    m_targetReferenceCategory = new JComboBox();
    p.add(m_targetReferenceCategory, c);
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 3;
    c.weightx = 1;
    m_notSortTarget = new JCheckBox("Use order from target column domain (only relevant for output representation)");
    p.add(m_notSortTarget, c);
    m_selectionPanel.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            Object selected = e.getItem();
            if (selected instanceof DataColumnSpec) {
                m_filterPanel.resetHiding();
                m_filterPanel.hideColumns((DataColumnSpec) selected);
            }
        }
    });
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) NominalValue(org.knime.core.data.NominalValue) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) DataColumnSpec(org.knime.core.data.DataColumnSpec) ActionListener(java.awt.event.ActionListener) DataCell(org.knime.core.data.DataCell) ItemListener(java.awt.event.ItemListener) ColumnSelectionPanel(org.knime.core.node.util.ColumnSelectionPanel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 84 with JComboBox

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

the class NodeDialogPane method noLightWeight.

/*
     * Converts the specified and all its parent Component object to no-light
     * weight components if they are of type JComboBox, JPopupMenu, or
     * BasicComboPopup.
     */
private static void noLightWeight(final Component c) {
    if (c instanceof Container) {
        if (c instanceof JComboBox) {
            JComboBox cb = (JComboBox) c;
            cb.setLightWeightPopupEnabled(false);
        }
        if (c instanceof JPopupMenu) {
            JPopupMenu pm = (JPopupMenu) c;
            pm.setLightWeightPopupEnabled(false);
        }
        if (c instanceof BasicComboPopup) {
            BasicComboPopup cp = (BasicComboPopup) c;
            cp.setLightWeightPopupEnabled(false);
        }
        Container o = (Container) c;
        for (int cnt = o.getComponentCount(); --cnt >= 0; ) {
            Component newComponent = o.getComponent(cnt);
            noLightWeight(newComponent);
        }
    }
}
Also used : NodeContainer(org.knime.core.node.workflow.NodeContainer) Container(java.awt.Container) JComboBox(javax.swing.JComboBox) Component(java.awt.Component) JComponent(javax.swing.JComponent) BasicComboPopup(javax.swing.plaf.basic.BasicComboPopup) JPopupMenu(javax.swing.JPopupMenu)

Example 85 with JComboBox

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

the class ColumnPairsSelectionPanel method addUIControls.

private void addUIControls(final int index, final String leftSelected, final String rightSelected) {
    m_leftComboBoxes.add(index, new JComboBox());
    m_leftComboBoxes.get(index).setModel(new DefaultComboBoxModel());
    ColumnComboBoxRenderer renderer = new ColumnComboBoxRenderer();
    renderer.attachTo(m_leftComboBoxes.get(index));
    initComboBox(m_specs[0], m_leftComboBoxes.get(index), leftSelected);
    m_rightComboBoxes.add(index, new JComboBox());
    m_rightComboBoxes.get(index).setModel(new DefaultComboBoxModel());
    renderer = new ColumnComboBoxRenderer();
    renderer.attachTo(m_rightComboBoxes.get(index));
    initComboBox(m_specs[1], m_rightComboBoxes.get(index), rightSelected);
    JButton addButton = new JButton("+");
    addButton.setToolTipText("Add row preceding this.");
    addButton.addActionListener(m_addButtonListener);
    m_addButtons.add(index, addButton);
    JButton removeButton = new JButton("-");
    removeButton.addActionListener(m_removeButtonListener);
    removeButton.setToolTipText("Remove this row.");
    m_removeButtons.add(index, removeButton);
    // if the first row was added
    if (m_leftComboBoxes.size() == 1) {
        m_persistentAddButton.setText("+");
    }
}
Also used : JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

JComboBox (javax.swing.JComboBox)226 JLabel (javax.swing.JLabel)97 JPanel (javax.swing.JPanel)88 ActionEvent (java.awt.event.ActionEvent)69 ActionListener (java.awt.event.ActionListener)66 JButton (javax.swing.JButton)55 GridBagLayout (java.awt.GridBagLayout)42 GridBagConstraints (java.awt.GridBagConstraints)41 Insets (java.awt.Insets)40 Dimension (java.awt.Dimension)39 JScrollPane (javax.swing.JScrollPane)37 JTextField (javax.swing.JTextField)36 BoxLayout (javax.swing.BoxLayout)34 JCheckBox (javax.swing.JCheckBox)33 DefaultCellEditor (javax.swing.DefaultCellEditor)27 JTable (javax.swing.JTable)26 BorderLayout (java.awt.BorderLayout)25 Component (java.awt.Component)25 TableColumn (javax.swing.table.TableColumn)23 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)22