Search in sources :

Example 26 with JSpinner

use of javax.swing.JSpinner 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_includedColumns = new ColumnFilterPanel(true, StringValue.class);
    p.add(m_includedColumns, 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(JTextField.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(JTextField.RIGHT);
    p.add(m_mapMissingTo, c);
    c.gridy++;
    c.weighty = 1;
    p.add(new JPanel(), c);
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ColumnFilterPanel(org.knime.core.node.util.ColumnFilterPanel) JSpinner(javax.swing.JSpinner) StringValue(org.knime.core.data.StringValue)

Example 27 with JSpinner

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

the class DateInputDialog method initialize.

/**
 * This method initializes the dialog Component, with standard values. Which are later on overwritten by the load
 * method. All possible JComponets are created and initialized nevertheless they might not be used due to different
 * configurations.
 */
private void initialize() {
    m_useSeconds = new JCheckBox();
    m_useMinutes = new JCheckBox();
    m_useHours = new JCheckBox();
    m_useDate = new JCheckBox();
    m_hours = new JSpinner(new SpinnerNumberModel(0, 0, 23, 1));
    m_hours.setMaximumSize(new Dimension(SPINNER_WIDTH, 25));
    m_hours.setMinimumSize(new Dimension(SPINNER_WIDTH, 25));
    m_minutes = new JSpinner(new SpinnerNumberModel(0, 0, 59, 1));
    m_minutes.setMaximumSize(new Dimension(SPINNER_WIDTH, 25));
    m_minutes.setMinimumSize(new Dimension(SPINNER_WIDTH, 25));
    m_seconds = new JSpinner(new SpinnerNumberModel(0, 0, 59, 1));
    m_seconds.setMaximumSize(new Dimension(SPINNER_WIDTH, 25));
    m_seconds.setMinimumSize(new Dimension(SPINNER_WIDTH, 25));
    m_startDate = new JDateChooser() {

        {
            // fixes bug AP-5865
            popup.setFocusable(false);
        }
    };
    m_startDate.setLocale(Locale.US);
    m_startDate.getJCalendar().getCalendar().setTimeZone(TimeZone.getTimeZone("UTC"));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setMinimumSize(new Dimension(PANEL_WIDTH, 60));
    Box outerBox = Box.createVerticalBox();
    Box dateBox = Box.createHorizontalBox();
    if (m_isOptional) {
        dateBox.add(m_useDate);
        dateBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
    }
    dateBox.add(m_startDate);
    dateBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
    dateBox.setPreferredSize(new Dimension(PANEL_WIDTH, 25));
    dateBox.setMaximumSize(new Dimension(PANEL_WIDTH, 25));
    dateBox.setMinimumSize(new Dimension(PANEL_WIDTH, 25));
    outerBox.add(dateBox);
    Box timeBox = Box.createHorizontalBox();
    if (m_displayHours) {
        if (m_optionalTime) {
            timeBox.add(m_useHours);
        }
        timeBox.add(new JLabel("Hour: "));
        timeBox.add(m_hours);
        timeBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
        timeBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
        if (m_displayMinutes) {
            if (m_optionalTime) {
                timeBox.add(m_useMinutes);
            }
            timeBox.add(new JLabel("Minute: "));
            timeBox.add(m_minutes);
            timeBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
            timeBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
            if (m_displaySeconds) {
                if (m_optionalTime) {
                    timeBox.add(m_useSeconds);
                }
                timeBox.add(new JLabel("Second: "));
                timeBox.add(m_seconds);
                timeBox.add(Box.createHorizontalStrut(HORIZ_SPACE));
            }
        }
    }
    timeBox.add(Box.createHorizontalGlue());
    outerBox.setMaximumSize(new Dimension(PANEL_WIDTH, 60));
    outerBox.setMinimumSize(new Dimension(PANEL_WIDTH, 60));
    outerBox.add(Box.createVerticalStrut(VERT_SPACE));
    outerBox.add(timeBox);
    if (m_isOptional) {
        m_startDate.setEnabled(false);
        m_useHours.setEnabled(false);
    } else {
        m_startDate.setEnabled(true);
        m_useHours.setEnabled(true);
    }
    m_useHours.setSelected(false);
    m_hours.setEnabled(false);
    m_useMinutes.setEnabled(false);
    m_minutes.setEnabled(false);
    m_useSeconds.setEnabled(false);
    m_seconds.setEnabled(false);
    m_useDate.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_useDate.isSelected()) {
                m_startDate.setEnabled(true);
                m_useHours.setEnabled(true);
            } else {
                m_startDate.setEnabled(false);
                m_startDate.cleanup();
                m_useHours.setSelected(false);
                m_useHours.setEnabled(false);
                m_hours.setEnabled(false);
                m_useMinutes.setEnabled(false);
                m_useMinutes.setSelected(false);
                m_minutes.setEnabled(false);
                m_useSeconds.setEnabled(false);
                m_useSeconds.setSelected(false);
                m_seconds.setEnabled(false);
            }
        }
    });
    m_useHours.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_useHours.isSelected()) {
                m_hours.setEnabled(true);
                m_useMinutes.setEnabled(true);
                m_minutes.setEnabled(false);
                m_useSeconds.setEnabled(false);
                m_seconds.setEnabled(false);
            } else {
                m_hours.setEnabled(false);
                m_useMinutes.setEnabled(false);
                m_useMinutes.setSelected(false);
                m_minutes.setEnabled(false);
                m_useSeconds.setEnabled(false);
                m_useSeconds.setSelected(false);
                m_seconds.setEnabled(false);
            }
        }
    });
    m_useMinutes.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_useMinutes.isSelected()) {
                m_minutes.setEnabled(true);
                m_useSeconds.setEnabled(true);
                m_seconds.setEnabled(false);
            } else {
                m_useMinutes.setSelected(false);
                m_minutes.setEnabled(false);
                m_useSeconds.setEnabled(false);
                m_useSeconds.setSelected(false);
                m_seconds.setEnabled(false);
                m_seconds.setEnabled(false);
            }
        }
    });
    m_useSeconds.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (m_useSeconds.isSelected()) {
                m_seconds.setEnabled(true);
            } else {
                m_seconds.setEnabled(false);
            }
        }
    });
    if (!m_optionalTime) {
        m_useHours.setSelected(true);
        m_useMinutes.setSelected(true);
        m_useSeconds.setSelected(true);
    }
    add(outerBox);
    add(Box.createVerticalStrut(VERT_SPACE));
}
Also used : JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JDateChooser(com.toedter.calendar.JDateChooser) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) Dimension(java.awt.Dimension)

Example 28 with JSpinner

use of javax.swing.JSpinner 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;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 29 with JSpinner

use of javax.swing.JSpinner 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));
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) Dimension(java.awt.Dimension)

Example 30 with JSpinner

use of javax.swing.JSpinner 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));
    }
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner) NumberFormat(java.text.NumberFormat)

Aggregations

JSpinner (javax.swing.JSpinner)76 SpinnerNumberModel (javax.swing.SpinnerNumberModel)61 JLabel (javax.swing.JLabel)47 JPanel (javax.swing.JPanel)41 ActionEvent (java.awt.event.ActionEvent)28 ActionListener (java.awt.event.ActionListener)27 JCheckBox (javax.swing.JCheckBox)22 JRadioButton (javax.swing.JRadioButton)21 GridBagConstraints (java.awt.GridBagConstraints)18 Insets (java.awt.Insets)18 ChangeEvent (javax.swing.event.ChangeEvent)18 GridBagLayout (java.awt.GridBagLayout)17 JButton (javax.swing.JButton)15 Dimension (java.awt.Dimension)13 ChangeListener (javax.swing.event.ChangeListener)13 ButtonGroup (javax.swing.ButtonGroup)12 BorderLayout (java.awt.BorderLayout)11 JTextField (javax.swing.JTextField)11 JScrollPane (javax.swing.JScrollPane)10 JMenuItem (javax.swing.JMenuItem)8