use of javax.swing.JSpinner in project knime-core by knime.
the class SleepNodeDialog method waitForTimePanel.
private void waitForTimePanel() {
m_waitForSpinnerModel = new SpinnerDateModel();
m_forSpinner = new JSpinner(m_waitForSpinnerModel);
m_forSpinner.setEditor(new JSpinner.DateEditor(m_forSpinner, "HH:mm:ss"));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
m_waitForSpinnerModel.setValue(cal.getTime());
m_forRB = new JRadioButton("Wait for time:");
m_forRB.doClick();
m_forRB.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (m_forRB.isSelected()) {
m_selection = 0;
}
m_forSpinner.setEnabled(m_forRB.isSelected());
}
});
}
use of javax.swing.JSpinner in project knime-core by knime.
the class SorterNodeDialogPanel2 method update.
/**
* Updates this panel based on the DataTableSpec, the list of columns to
* include and the corresponding sorting order.
*
* @param spec the DataTableSpec
* @param incl the list to include
* @param sortOrder the sorting order
* @param nrsortitems the inital number of sortitems to be shown
* @param sortInMemory whether to perform the sorting in memory or not
* @param missingToEnd Whether to move missings to the end
*/
void update(final DataTableSpec spec, final List<String> incl, final boolean[] sortOrder, final int nrsortitems, final boolean sortInMemory, final boolean missingToEnd) {
m_spec = spec;
m_memory = sortInMemory;
super.removeAll();
m_components.removeAllElements();
int interncounter = 0;
if (spec != null) {
Vector<DataColumnSpec> values = new Vector<DataColumnSpec>();
values.add(NOSORT);
values.add(ROWKEY);
for (int j = 0; j < spec.getNumColumns(); j++) {
values.add(spec.getColumnSpec(j));
}
if ((incl == null) || (sortOrder == null)) {
for (int i = 0; i < nrsortitems && i < spec.getNumColumns(); i++) {
DataColumnSpec selected = (i == 0) ? values.get(i + 1) : values.get(0);
SortItem temp = new SortItem(i, values, selected, true);
super.add(temp);
m_components.add(temp);
}
} else {
for (int i = 0; i < incl.size(); i++) {
String includeString = incl.get(i);
int columnIndex = spec.findColumnIndex(includeString);
if (columnIndex != -1) {
DataColumnSpec colspec = spec.getColumnSpec(columnIndex);
SortItem temp = new SortItem(interncounter, values, colspec, sortOrder[interncounter]);
super.add(temp);
m_components.add(temp);
interncounter++;
} else if (includeString.equals(NOSORT.getName())) {
SortItem temp = new SortItem(interncounter, values, NOSORT, sortOrder[interncounter]);
super.add(temp);
m_components.add(temp);
interncounter++;
} else if (includeString.equals(ROWKEY.getName())) {
SortItem temp = new SortItem(interncounter, values, ROWKEY, sortOrder[interncounter]);
super.add(temp);
m_components.add(temp);
interncounter++;
} else if (columnIndex == -1) {
SortItem temp = new SortItem(interncounter, values, includeString, sortOrder[interncounter]);
super.add(temp);
m_components.add(temp);
interncounter++;
}
}
}
Box buttonbox = Box.createHorizontalBox();
Border addColumnBorder = BorderFactory.createTitledBorder("Add columns");
buttonbox.setBorder(addColumnBorder);
int maxCols = m_spec.getNumColumns() - m_components.size() + 1;
JButton addSortItemButton = new JButton("new columns");
final JSpinner spinner = new JSpinner();
SpinnerNumberModel snm;
if (maxCols == 0) {
snm = new SpinnerNumberModel(0, 0, maxCols, 1);
spinner.setEnabled(false);
addSortItemButton.setEnabled(false);
} else {
snm = new SpinnerNumberModel(1, 1, maxCols, 1);
}
spinner.setModel(snm);
spinner.setMaximumSize(new Dimension(50, 25));
spinner.setPreferredSize(new Dimension(50, 25));
NumberEditor ne = (NumberEditor) spinner.getEditor();
final JFormattedTextField spinnertextfield = ne.getTextField();
// workaround to ensure same background color
Color backColor = spinnertextfield.getBackground();
// when spinner's text field is editable false
spinnertextfield.setEditable(false);
spinnertextfield.setBackground(backColor);
addSortItemButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ae) {
ArrayList<String> newlist = new ArrayList<String>();
for (int i = 0; i < m_components.size(); i++) {
SortItem temp = m_components.get(i);
newlist.add(temp.getColumnText());
}
int oldsize = m_components.size();
String temp = spinner.getValue().toString();
int newsize = Integer.parseInt(temp);
for (int n = oldsize; n < oldsize + newsize; n++) {
newlist.add(NOSORT.getName());
}
boolean[] oldbool = new boolean[oldsize];
boolean[] newbool = new boolean[oldsize + newsize];
// copy old values
for (int i = 0; i < m_components.size(); i++) {
SortItem temp2 = m_components.get(i);
newbool[i] = temp2.getSortOrder();
}
// create new values
for (int i = oldbool.length; i < newbool.length; i++) {
newbool[i] = true;
}
boolean misToEnd = m_sortMissingToEndChecker.isSelected();
update(m_spec, newlist, newbool, (oldsize + newsize), m_memory, misToEnd);
}
});
buttonbox.add(spinner);
buttonbox.add(Box.createHorizontalStrut(10));
buttonbox.add(addSortItemButton);
super.add(buttonbox);
Box memorybox = Box.createHorizontalBox();
m_memorycheckb = new JCheckBox("Sort in memory", m_memory);
m_memorycheckb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent ae) {
if (m_memorycheckb.isSelected()) {
m_memory = true;
} else {
m_memory = false;
}
}
});
memorybox.add(m_memorycheckb);
super.add(memorybox);
Box missingToEndBox = Box.createHorizontalBox();
m_sortMissingToEndChecker.setSelected(missingToEnd);
missingToEndBox.add(m_sortMissingToEndChecker);
super.add(missingToEndBox);
revalidate();
}
}
use of javax.swing.JSpinner in project knime-core by knime.
the class DefaultAlphaColorPanel method buildChooser.
/**
* {@inheritDoc}
*/
@Override
protected void buildChooser() {
super.setLayout(new BorderLayout());
m_slider = new JSlider(JSlider.HORIZONTAL, 0, 255, 255);
m_slider.setMajorTickSpacing(85);
m_slider.setMinorTickSpacing(17);
m_slider.setPaintTicks(true);
m_slider.setPaintLabels(true);
m_spinner = new JSpinner(new SpinnerNumberModel(255, 0, 255, 5));
JPanel spinnerPanel = new JPanel(new FlowLayout());
spinnerPanel.add(m_spinner);
super.add(new JLabel("Alpha "), BorderLayout.WEST);
super.add(m_slider, BorderLayout.CENTER);
super.add(spinnerPanel, BorderLayout.EAST);
super.add(new JLabel("\n(Alpha composition is " + "expensive in cases when operations performed are not " + "hardware-accelerated.)"), BorderLayout.SOUTH);
m_slider.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
setAlpha(m_slider.getValue());
}
});
m_spinner.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent e) {
try {
m_spinner.commitEdit();
setAlpha((Integer) m_spinner.getValue());
} catch (ParseException pe) {
setAlpha(255);
}
}
});
m_slider.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(final FocusEvent fe) {
getAlpha();
}
});
m_spinner.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(final FocusEvent fe) {
getAlpha();
}
});
}
use of javax.swing.JSpinner in project knime-core by knime.
the class TwoColumnProperties method createRangeBox.
/**
* Creates the necessary graphical components for adjusting the displayed
* column ranges.
* @return the box containing the graphical components for the column ranges
* adjustment
*/
private Box createRangeBox() {
m_xMinSpinner = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
m_xMaxSpinner = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
m_yMinSpinner = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
m_yMaxSpinner = new JSpinner(new SpinnerNumberModel(1.0, null, null, 0.1));
Dimension spinnerSize = new Dimension(100, m_xMinSpinner.getPreferredSize().height);
m_xMinSpinner.setPreferredSize(spinnerSize);
m_xMaxSpinner.setPreferredSize(spinnerSize);
m_yMinSpinner.setPreferredSize(spinnerSize);
m_yMaxSpinner.setPreferredSize(spinnerSize);
Box xBox = Box.createHorizontalBox();
xBox.add(Box.createHorizontalStrut(SMALL_SPACE));
xBox.add(new JLabel("X attribute"));
xBox.add(Box.createHorizontalStrut(SPACE));
xBox.add(m_xMinSpinner);
xBox.add(Box.createHorizontalStrut(SPACE));
xBox.add(m_xMaxSpinner);
xBox.add(Box.createHorizontalStrut(SMALL_SPACE));
Box yBox = Box.createHorizontalBox();
yBox.add(Box.createHorizontalStrut(SMALL_SPACE));
yBox.add(new JLabel("Y attribute"));
yBox.add(Box.createHorizontalStrut(SPACE));
yBox.add(m_yMinSpinner);
yBox.add(Box.createHorizontalStrut(SPACE));
yBox.add(m_yMaxSpinner);
yBox.add(Box.createHorizontalStrut(SMALL_SPACE));
Box rangeBox = Box.createVerticalBox();
rangeBox.add(Box.createVerticalStrut(SMALL_SPACE));
rangeBox.add(xBox);
rangeBox.add(Box.createVerticalStrut(SPACE));
rangeBox.add(yBox);
rangeBox.add(Box.createVerticalStrut(SMALL_SPACE));
rangeBox.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
return rangeBox;
}
use of javax.swing.JSpinner in project knime-core by knime.
the class LinReg2LearnerNodeDialogPane method createRegressionPropertiesPanel.
private JPanel createRegressionPropertiesPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 0;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.BASELINE;
c.insets = new Insets(5, 5, 0, 0);
m_predefinedOffsetValue = new JCheckBox("Predefined Offset Value:");
panel.add(m_predefinedOffsetValue, c);
c.gridx++;
m_offsetValue = new JSpinner(new SpinnerNumberModel(0.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1.0));
m_offsetValue.setPreferredSize(new Dimension(m_offsetValue.getPreferredSize().width + 70, m_offsetValue.getPreferredSize().height));
panel.add(m_offsetValue, c);
m_predefinedOffsetValue.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
m_offsetValue.setEnabled(m_predefinedOffsetValue.isSelected());
}
});
return panel;
}
Aggregations