use of javax.swing.SpinnerNumberModel in project knime-core by knime.
the class CrosstabNodeView method createControlsPanel.
private JPanel createControlsPanel() {
JPanel p = new JPanel(new GridBagLayout());
p.setBackground(Color.white);
GridBagConstraints c = createGridBagConstraints();
c.insets = new Insets(8, 3, 3, 3);
m_propsPanel = new JPanel(new GridBagLayout());
m_propsPanel.setBackground(Color.white);
p.add(m_propsPanel, c);
c.insets = new Insets(3, 3, 3, 3);
c.gridy++;
p.add(new JLabel("Max rows:"), c);
c.gridy++;
m_maxRows = new SpinnerNumberModel(DEFAULT_MAX_ROWS, 1, 10000, 1);
m_maxRows.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
reCreateCrosstabulation();
}
});
p.add(new JSpinner(m_maxRows), c);
c.insets = new Insets(8, 3, 3, 3);
c.gridy++;
c.gridx = 0;
p.add(new JLabel("Max columns:"), c);
c.gridy++;
c.insets = new Insets(3, 3, 3, 3);
m_maxCols = new SpinnerNumberModel(DEFAULT_MAX_COLS, 1, 10000, 1);
m_maxCols.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
reCreateCrosstabulation();
}
});
p.add(new JSpinner(m_maxCols), c);
c.gridy++;
c.weighty = 1;
JPanel foo = new JPanel();
foo.setBackground(Color.white);
p.add(foo, c);
return p;
}
use of javax.swing.SpinnerNumberModel 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));
}
use of javax.swing.SpinnerNumberModel in project knime-core by knime.
the class SettingsModelPCADimensions method configureQualitySlider.
/**
* @param spinner
* spinner component to be updated
*/
public void configureQualitySlider(final JSpinner spinner) {
if (m_eigenvalues != null) {
final double[] ev = getSortedCopy(m_eigenvalues);
double sum = 0;
for (final double e : ev) {
sum += e;
}
double frac = 0;
int[] values = new int[ev.length];
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMaximumFractionDigits(0);
int index = 0;
for (int i = ev.length - 1; i >= 0; i--) {
frac += ev[i];
// floor
final int p = (int) (frac / sum * 100);
// care for duplicates
if (index == 0 || index != 0 && values[index - 1] != p) {
values[index++] = p;
}
}
// care for duplicates
if (index != values.length) {
final int[] v = new int[index];
for (int i = 0; i < index; i++) {
v[i] = values[i];
}
values = v;
}
// last value is always 100% (numerical problem)
values[values.length - 1] = 100;
final Object currentValue = spinner.getValue();
spinner.setModel(new ArraySpinnerModel(values));
spinner.setValue(currentValue);
spinner.setEditor(new JSpinner.NumberEditor(spinner, "###"));
} else {
final int val = Math.max(Math.min((Integer) spinner.getValue(), 100), 25);
spinner.setModel(new SpinnerNumberModel(val, 25, 100, 1));
}
}
use of javax.swing.SpinnerNumberModel in project knime-core by knime.
the class CategoryToNumberNodeDialogPane method createCategoryToNumberSettingsTab.
@SuppressWarnings("unchecked")
private JPanel createCategoryToNumberSettingsTab() {
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;
c.gridwidth = 1;
c.weightx = 1;
c.weighty = 0;
Insets leftInsets = new Insets(3, 8, 3, 8);
Insets middleInsets = new Insets(3, 0, 3, 0);
c.gridwidth = 3;
m_filterPanel = new DataColumnSpecFilterPanel();
p.add(m_filterPanel, c);
c.weighty = 0;
c.weightx = 0;
c.gridy++;
c.gridwidth = 2;
c.gridx = 0;
c.insets = leftInsets;
m_appendColums = new JCheckBox("Append columns");
m_appendColums.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
m_columnSuffix.setEnabled(m_appendColums.isSelected());
}
});
p.add(m_appendColums, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Column suffix:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_columnSuffix = new JTextField();
p.add(m_columnSuffix, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Start value:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_startIndex = new JSpinner(new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1));
p.add(m_startIndex, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Increment:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_increment = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
p.add(m_increment, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Max. categories:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_maxCategories = new JSpinner(new SpinnerNumberModel(1000, 1, Integer.MAX_VALUE, 100));
p.add(m_maxCategories, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Default value:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_defaultValue = new JTextField();
m_defaultValue.setHorizontalAlignment(SwingConstants.RIGHT);
p.add(m_defaultValue, c);
c.gridy++;
c.gridwidth = 1;
c.gridx = 0;
c.insets = leftInsets;
p.add(new JLabel("Map missing to:"), c);
c.gridx = 1;
c.insets = middleInsets;
m_mapMissingTo = new JTextField();
m_mapMissingTo.setHorizontalAlignment(SwingConstants.RIGHT);
p.add(m_mapMissingTo, c);
c.gridy++;
c.weighty = 1;
p.add(new JPanel(), c);
return p;
}
use of javax.swing.SpinnerNumberModel in project knime-core by knime.
the class AbstractCorrelationComputeNodeView method getJMenu.
private JMenu getJMenu() {
JMenu menu = new JMenu("View");
JCheckBoxMenuItem useColorBox = new JCheckBoxMenuItem("Use Colors");
useColorBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (((JCheckBoxMenuItem) e.getSource()).isSelected()) {
changeRenderer(ColorRender.DESCRIPTION);
} else {
changeRenderer(DoubleValueRenderer.STANDARD_RENDERER.getDescription());
}
}
});
useColorBox.addPropertyChangeListener("ancestor", new PropertyChangeListener() {
/**
* {@inheritDoc}
*/
@Override
public void propertyChange(final PropertyChangeEvent evt) {
((JCheckBoxMenuItem) evt.getSource()).setSelected(m_currentRendererID.equals(ColorRender.DESCRIPTION));
}
});
JMenuItem colWidthItem = new JMenuItem("Cell Size...");
colWidthItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
int colWidth = m_tableView.getColumnWidth();
JSpinner s = new JSpinner(new SpinnerNumberModel(colWidth, 1, Integer.MAX_VALUE, 1));
int r = JOptionPane.showConfirmDialog(m_tableView, s, "Cell Size", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (r == JOptionPane.OK_OPTION) {
m_tableView.setColumnWidth((Integer) s.getValue());
m_tableView.setRowHeight((Integer) s.getValue());
}
}
});
menu.add(useColorBox);
menu.add(colWidthItem);
return menu;
}
Aggregations