use of javax.swing.JComboBox in project knime-core by knime.
the class DecTreePredictorGraphView 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 DecTreeLearnerGraphView2 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 ColumnRowFilterPanel method instantiateComponents.
@SuppressWarnings("unchecked")
private void instantiateComponents(final RowFilterNodeDialogPane parentPane, final DataTableSpec tSpec) throws NotConfigurableException {
/* instantiate the col idx selector, depending on the table spec */
assert ((tSpec != null) && (tSpec.getNumColumns() > 0));
Vector<String> colNames = new Vector<String>();
for (int c = 0; c < tSpec.getNumColumns(); c++) {
colNames.add(tSpec.getColumnSpec(c).getName());
}
m_colCombo = new ColumnSelectionComboxBox((Border) null, DataValue.class);
m_colCombo.update(tSpec, null);
m_colCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
selectedColChanged();
}
});
m_deepFiltering = new JCheckBox("filter based on collection elements");
/* the selectors for what kind of checking will be done */
m_useRange = new JRadioButton("use range checking");
m_useRegExpr = new JRadioButton("use pattern matching");
m_useMissValue = new JRadioButton("only missing values match");
m_useRange.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_useMissValue.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
radiosChanged();
}
});
m_radios = new ButtonGroup();
m_radios.add(m_useRange);
m_radios.add(m_useRegExpr);
m_radios.add(m_useMissValue);
/* the bound edit fields */
m_lowerLabel = new JLabel("lower bound:");
m_lowerLabel.setToolTipText("Smallest value of the range to be filtered.");
m_lowerBound = new JTextField();
m_upperLabel = new JLabel("upper bound:");
m_upperLabel.setToolTipText("Largest value of the range to be filtered.");
m_upperBound = new JTextField();
m_lowerBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
m_upperBound.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
boundsChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
boundsChanged();
}
});
/* the regular expression stuff */
m_regLabel = new JLabel("pattern:");
// it's important that the column selection is created before!
m_regExpr = new JComboBox(getPossibleValuesOfSelectedColumn());
m_regExpr.setEditable(true);
m_regExpr.setSelectedItem("");
m_regExpr.setMinimumSize(new Dimension(50, m_regExpr.getPreferredSize().height));
// m_regExpr.setPreferredSize(new Dimension(200, 50));
m_regExpr.setMaximumSize(new Dimension(300, 50));
JTextField ed = (JTextField) m_regExpr.getEditor().getEditorComponent();
ed.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
regExprChanged();
}
@Override
public void changedUpdate(final DocumentEvent e) {
regExprChanged();
}
});
m_regExpr.addItemListener(this);
/* add flow variable button for the pattern/regexpr */
FlowVariableModel fvm = parentPane.createFlowVariableModel(new String[] { RowFilterNodeModel.CFGFILTER, StringCompareRowFilter.CFGKEY_PATTERN }, FlowVariable.Type.STRING);
fvm.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent evt) {
FlowVariableModel fvm = (FlowVariableModel) (evt.getSource());
m_regExpr.setEnabled(!fvm.isVariableReplacementEnabled());
if (fvm.isVariableReplacementEnabled() && m_regExpr.getSelectedItem().equals("")) {
// TODO: replace with more meaningful default - empty
// pattern are rejected by dialog.
m_regExpr.setSelectedItem(fvm.getInputVariableName());
}
}
});
m_regExprVarButton = new FlowVariableModelButton(fvm);
m_caseSensitive = new JCheckBox("case sensitive match");
m_isRegExpr = new JCheckBox("regular expression");
m_hasWildCards = new JCheckBox("contains wild cards");
m_hasWildCards.setToolTipText("insert '?' or '*' to match any one " + "character or any sequence (including none) of characters.");
m_isRegExpr.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
m_hasWildCards.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
wildRegExprChanged(e);
// also trigger regular expression recompile
regExprChanged();
}
});
/* and a label to display errors/warnings */
m_errText = new JTextArea();
m_errText.setEditable(false);
m_errText.setLineWrap(true);
m_errText.setWrapStyleWord(true);
m_errText.setBackground(getBackground());
m_errText.setFont(new Font(m_errText.getFont().getName(), Font.BOLD, m_errText.getFont().getSize()));
m_errText.setMinimumSize(new Dimension(350, 50));
m_errText.setMaximumSize(new Dimension(350, 100));
m_errText.setForeground(Color.RED);
/* set the default values */
m_useRegExpr.setSelected(true);
}
use of javax.swing.JComboBox in project knime-core by knime.
the class Joiner2NodeDialog method createJoinPredicateUIControls.
/**
* @param includeRowId <code>true</code> if the user can select the row id as a potential matching column
* @param showMatchModes <code>true</code> if the AND and OR match mode option should available
* @return the column pair panel
* @since 2.12
* @noreference This method is not intended to be referenced by clients.
*/
protected JPanel createJoinPredicateUIControls(final boolean includeRowId, final boolean showMatchModes) {
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.gridx = 0;
c.gridy = 0;
if (showMatchModes) {
JPanel matchButtonPanel = new JPanel(new FlowLayout());
matchButtonPanel.add(m_matchAllButton);
matchButtonPanel.add(m_matchAnyButton);
p.add(matchButtonPanel, c);
ButtonGroup group = new ButtonGroup();
group.add(m_matchAllButton);
group.add(m_matchAnyButton);
c.gridx = 0;
c.gridy++;
}
c.gridwidth = 3;
c.weightx = 1;
c.weighty = 1;
m_columnPairs = new ColumnPairsSelectionPanel(includeRowId) {
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected void initComboBox(final DataTableSpec spec, final JComboBox comboBox, final String selected) {
super.initComboBox(spec, comboBox, selected);
// the first entry is the row id, set as default.
if (selected == null) {
comboBox.setSelectedIndex(0);
}
}
};
m_columnPairs.setRowKeyIdentifier(Joiner2Settings.ROW_KEY_IDENTIFIER);
JScrollPane scrollPane = new JScrollPane(m_columnPairs);
m_columnPairs.setBackground(Color.white);
Component header = m_columnPairs.getHeaderView();
header.setPreferredSize(new Dimension(300, 20));
scrollPane.setColumnHeaderView(header);
scrollPane.setPreferredSize(new Dimension(300, 200));
scrollPane.setMinimumSize(new Dimension(300, 100));
p.add(scrollPane, c);
p.setBorder(BorderFactory.createTitledBorder("Joining Columns"));
return p;
}
use of javax.swing.JComboBox in project knime-core by knime.
the class FileReaderNodeDialog method createSettingsPanel.
private JPanel createSettingsPanel() {
JButton advanced = new JButton("Advanced...");
int buttonHeight = advanced.getPreferredSize().height;
m_hasRowHeaders = new JCheckBox("read row IDs");
m_hasRowHeaders.setToolTipText("Check if the file contains row IDs" + " in the first column");
m_hasColHeaders = new JCheckBox("read column headers");
m_hasColHeaders.setToolTipText("Check if the file contains column" + " headers in the first line");
JLabel deliLabel = new JLabel("Column delimiter:");
m_delimField = new JComboBox();
m_delimField.setMaximumSize(new Dimension(70, buttonHeight));
m_delimField.setMinimumSize(new Dimension(70, buttonHeight));
m_delimField.setPreferredSize(new Dimension(70, buttonHeight));
m_delimField.setEditable(true);
Delimiter[] selDelims = DEFAULT_DELIMS;
m_delimField.setModel(new DefaultComboBoxModel(selDelims));
deliLabel.setToolTipText("Specify the data delimiter character(s)");
m_delimField.setToolTipText("Specify the data delimiter character(s)");
m_cStyleComment = new JCheckBox("Java-style comments");
m_cStyleComment.setToolTipText("Check to add support for '//' and " + "\"'/*' and '*/'\" comment");
m_singleLineComment = new JTextField(2);
m_singleLineComment.setMaximumSize(new Dimension(55, buttonHeight));
m_singleLineComment.setMinimumSize(new Dimension(55, buttonHeight));
m_singleLineComment.setPreferredSize(new Dimension(55, buttonHeight));
JLabel commentLabel = new JLabel("Single line comment:");
m_ignoreWS = new JCheckBox("ignore spaces and tabs");
m_ignoreWS.setToolTipText("If checked, whitespaces (spaces and tabs)" + " will be discarded (if not quoted)");
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(3, 3));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Basic Settings"));
// top row
Box rowBox = Box.createHorizontalBox();
rowBox.add(m_hasRowHeaders);
rowBox.add(Box.createGlue());
Box delimBox = Box.createHorizontalBox();
delimBox.add(Box.createHorizontalStrut(4));
delimBox.add(deliLabel);
delimBox.add(Box.createHorizontalStrut(3));
delimBox.add(m_delimField);
delimBox.add(Box.createGlue());
Box advBox = Box.createHorizontalBox();
advBox.add(Box.createGlue());
advBox.add(advanced);
advBox.add(Box.createGlue());
// middle row
Box colBox = Box.createHorizontalBox();
colBox.add(m_hasColHeaders);
colBox.add(Box.createGlue());
Box wsBox = Box.createHorizontalBox();
wsBox.add(m_ignoreWS);
wsBox.add(Box.createGlue());
// bottom row
Box pValBox = Box.createHorizontalBox();
// placeholder
pValBox.add(new JLabel(""));
pValBox.add(Box.createGlue());
Box cCmtBox = Box.createHorizontalBox();
cCmtBox.add(m_cStyleComment);
cCmtBox.add(Box.createGlue());
Box slcBox = Box.createHorizontalBox();
slcBox.add(commentLabel);
slcBox.add(Box.createHorizontalStrut(3));
slcBox.add(m_singleLineComment);
slcBox.add(Box.createGlue());
// now fill the grid: first row
panel.add(rowBox);
panel.add(delimBox);
panel.add(advBox);
// second row
panel.add(colBox);
panel.add(wsBox);
panel.add(new JLabel(""));
// third row
panel.add(pValBox);
panel.add(cCmtBox);
panel.add(slcBox);
int componentsHeight = (2 * COMP_HEIGHT) + 30 + buttonHeight;
panel.setMaximumSize(new Dimension(PANEL_WIDTH, componentsHeight));
advanced.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
advancedSettings();
}
});
m_hasRowHeaders.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
rowHeadersSettingsChanged();
}
});
m_hasColHeaders.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
colHeadersSettingsChanged();
}
});
m_cStyleComment.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
commentSettingsChanged();
}
});
m_delimField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
delimSettingsChanged();
}
});
m_ignoreWS.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
ignoreWSChanged();
}
});
m_singleLineComment.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(final DocumentEvent e) {
commentSettingsChanged();
}
@Override
public void insertUpdate(final DocumentEvent e) {
commentSettingsChanged();
}
@Override
public void removeUpdate(final DocumentEvent e) {
commentSettingsChanged();
}
});
// add a panel for the errors:
m_errorLabel = new JLabel("");
m_errorLabel.setForeground(Color.red);
m_errorDetail = new JLabel("");
m_errorDetail.setForeground(Color.red);
JPanel errorBox = new JPanel();
errorBox.setLayout(new BoxLayout(errorBox, BoxLayout.X_AXIS));
errorBox.add(Box.createHorizontalGlue());
errorBox.add(m_errorLabel);
// reserve a certain height for the (in the beginning invisible) label
errorBox.add(Box.createVerticalStrut(17));
errorBox.add(Box.createHorizontalGlue());
JPanel detailBox = new JPanel();
detailBox.setLayout(new BoxLayout(detailBox, BoxLayout.X_AXIS));
detailBox.add(Box.createHorizontalGlue());
detailBox.add(m_errorDetail);
// reserve a certain height for the (in the beginning invisible) label
detailBox.add(Box.createVerticalStrut(17));
detailBox.add(Box.createHorizontalGlue());
JPanel result = new JPanel();
result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));
result.add(panel);
result.add(errorBox);
result.add(detailBox);
return result;
}
Aggregations