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;
}
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;
}
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;
}
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);
}
}
}
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("+");
}
}
Aggregations