Search in sources :

Example 11 with JSlider

use of javax.swing.JSlider in project JMRI by JMRI.

the class DecVarSlider method stateChanged.

@Override
public void stateChanged(ChangeEvent e) {
    // called for new values of a slider - set the variable value as needed
    // e.getSource() points to the JSlider object - find it in the list
    JSlider j = (JSlider) e.getSource();
    BoundedRangeModel r = j.getModel();
    _var.setIntValue(r.getValue());
    _var.setState(AbstractValue.EDITED);
}
Also used : BoundedRangeModel(javax.swing.BoundedRangeModel) DefaultBoundedRangeModel(javax.swing.DefaultBoundedRangeModel) JSlider(javax.swing.JSlider)

Example 12 with JSlider

use of javax.swing.JSlider in project JMRI by JMRI.

the class VSDecoderPane method initComponents.

/**
     * initComponents()
     *
     * initialzies the GUI components.
     */
@Override
public void initComponents() {
    log.debug("initComponents()");
    //buildMenu();
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    // Add the tabbed pane to the VSDecoderPane.  The tabbedPane will contain all the other panes.
    tabbedPane = new JTabbedPane();
    GridBagConstraints gbc1 = new GridBagConstraints();
    gbc1.gridx = 0;
    gbc1.gridy = 0;
    gbc1.fill = GridBagConstraints.BOTH;
    gbc1.anchor = GridBagConstraints.CENTER;
    gbc1.weightx = 1.0;
    gbc1.weighty = 1.0;
    this.add(tabbedPane, gbc1);
    //-------------------------------------------------------------------
    // configPanel
    // The configPanel holds the stuff for addressing and configuration.
    configPanel = new VSDConfigPanel(decoder_id, this);
    tabbedPane.addTab("Config", configPanel);
    //-------------------------------------------------------------------
    // soundsPanel
    // The optionPanel holds controls for selecting sound options.
    optionPanel = new VSDOptionPanel(decoder_id, this);
    tabbedPane.addTab("Options", optionPanel);
    //-------------------------------------------------------------------
    // soundsPanel
    // The soundsPanel holds buttons for specific sounds.
    soundsPanel = new VSDSoundsPanel(decoder_id, this);
    tabbedPane.addTab("Sounds", soundsPanel);
    //-------------------------------------------------------------------
    // volumePanel
    // The volumePanel holds the master volume and mute controls.
    volumePanel = new JPanel();
    volumePanel.setLayout(new BorderLayout(10, 0));
    TitledBorder title = BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), "Volume");
    title.setTitlePosition(TitledBorder.DEFAULT_POSITION);
    volumePanel.setBorder(title);
    JSlider volume = new JSlider(0, 100);
    volume.setMinorTickSpacing(10);
    volume.setPaintTicks(true);
    volume.setValue(80);
    volume.setPreferredSize(new Dimension(200, 20));
    volume.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            volumeChange(e);
        }
    });
    volumePanel.add(volume, BorderLayout.LINE_START);
    JToggleButton mute_button = new JToggleButton("Mute");
    mute_button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            muteButtonPressed(e);
        }
    });
    volumePanel.add(mute_button, BorderLayout.LINE_END);
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridx = 0;
    gbc2.gridy = 1;
    gbc2.fill = GridBagConstraints.BOTH;
    gbc2.anchor = GridBagConstraints.CENTER;
    gbc2.weightx = 1.0;
    gbc2.weighty = 0.1;
    this.add(volumePanel, gbc2);
    //-------------------------------------------------------------------
    // statusBar
    // The statusBar shows decoder status.
    statusBar = new jmri.util.swing.StatusBar();
    statusBar.setMessage("Status: No decoder assigned");
    GridBagConstraints gbc3 = new GridBagConstraints();
    gbc3.gridx = 0;
    gbc3.gridy = 2;
    gbc3.fill = GridBagConstraints.BOTH;
    gbc3.anchor = GridBagConstraints.PAGE_END;
    gbc3.weightx = 1.0;
    gbc3.weighty = 0.1;
    this.add(statusBar, gbc3);
    //-------------------------------------------------------------------
    // Pack and set visible
    parent.pack();
    parent.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder) BorderLayout(java.awt.BorderLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChangeEvent(javax.swing.event.ChangeEvent) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 13 with JSlider

use of javax.swing.JSlider in project JMRI by JMRI.

the class VSDecoderPane method volumeChange.

/**
     * Handle a volume slider change
     */
// NOTE: should this be public???
public void volumeChange(ChangeEvent e) {
    JSlider v = (JSlider) e.getSource();
    log.debug("Volume slider moved. value = " + v.getValue());
    firePropertyChange(PropertyChangeID.VOLUME_CHANGE, v.getValue(), v.getValue());
}
Also used : JSlider(javax.swing.JSlider)

Example 14 with JSlider

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

the class PiePlotter method registerPropertiesChangeListener.

/**
 * Registers all histogram properties listener to the histogram
 * properties panel.
 */
private void registerPropertiesChangeListener() {
    m_props.addShowSectionOutlineChangedListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                vizModel.setDrawSectionOutline(e.getStateChange() == ItemEvent.SELECTED);
                final AbstractDrawingPane drawingPane = getPieDrawingPane();
                drawingPane.repaint();
            }
        }
    });
    m_props.addLabelDisplayListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                final P props = getPropertiesPanel();
                if (props != null) {
                    vizModel.setLabelDisplayPolicy(props.getLabelDisplayPolicy());
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addValueScaleListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                final P props = getPropertiesPanel();
                if (props != null) {
                    vizModel.setValueScale(props.getValueScale());
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addShowDetailsListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel != null) {
                if (vizModel.setShowDetails(e.getStateChange() == ItemEvent.SELECTED)) {
                    final AbstractDrawingPane drawingPane = getPieDrawingPane();
                    drawingPane.repaint();
                }
            }
        }
    });
    m_props.addPieSizeChangeListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            final JSlider source = (JSlider) e.getSource();
            final int pieSize = source.getValue();
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setPieSize((pieSize / 100.0))) {
                updatePaintModel();
            }
        }
    });
    m_props.addExplodeSizeChangeListener(new ChangeListener() {

        public void stateChanged(final ChangeEvent e) {
            final JSlider source = (JSlider) e.getSource();
            final int explodeSize = source.getValue();
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setExplodeSize((explodeSize / 100.0))) {
                updatePaintModel();
            }
        }
    });
    m_props.addAggrMethodListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            final String methodName = e.getActionCommand();
            if (!AggregationMethod.valid(methodName)) {
                throw new IllegalArgumentException("No valid aggregation method");
            }
            final AggregationMethod aggrMethod = AggregationMethod.getMethod4Command(methodName);
            if (vizModel.setAggregationMethod(aggrMethod)) {
                updatePaintModel();
            }
        }
    });
    m_props.addShowMissingValSectionListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setShowMissingValSection(e.getStateChange() == ItemEvent.SELECTED)) {
                // reset the details view if the missing section was selected
                final P properties = getPropertiesPanel();
                if (properties != null) {
                    properties.updateHTMLDetailsPanel(vizModel.getHTMLDetailData());
                }
                updatePaintModel();
            }
        }
    });
    m_props.addExplodeSelectedSectionListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            final PieVizModel vizModel = getVizModel();
            if (vizModel == null) {
                return;
            }
            if (vizModel.setExplodeSelectedSections(e.getStateChange() == ItemEvent.SELECTED)) {
                updatePaintModel();
            }
        }
    });
}
Also used : AggregationMethod(org.knime.base.node.viz.aggregation.AggregationMethod) ItemEvent(java.awt.event.ItemEvent) PieVizModel(org.knime.base.node.viz.pie.datamodel.PieVizModel) ActionEvent(java.awt.event.ActionEvent) AbstractDrawingPane(org.knime.base.node.viz.plotter.AbstractDrawingPane) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 15 with JSlider

use of javax.swing.JSlider in project vcell by virtualcell.

the class HistogramPanel method getVertSlider.

private JSlider getVertSlider() {
    if (vertScaleSlider != null) {
        return vertScaleSlider;
    }
    vertScaleSlider = new JSlider();
    vertScaleSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            repaint();
        }
    });
    vertScaleSlider.setMinimum(1);
    vertScaleSlider.setMaximum(400);
    vertScaleSlider.setValue(1);
    return vertScaleSlider;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

JSlider (javax.swing.JSlider)43 ChangeEvent (javax.swing.event.ChangeEvent)23 ChangeListener (javax.swing.event.ChangeListener)23 JLabel (javax.swing.JLabel)14 JPanel (javax.swing.JPanel)14 JButton (javax.swing.JButton)12 ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 GridBagLayout (java.awt.GridBagLayout)8 Dimension (java.awt.Dimension)7 GridBagConstraints (java.awt.GridBagConstraints)7 BorderLayout (java.awt.BorderLayout)6 JCheckBox (javax.swing.JCheckBox)6 JComponent (javax.swing.JComponent)6 JToggleButton (javax.swing.JToggleButton)6 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 JRadioButton (javax.swing.JRadioButton)5 JTextField (javax.swing.JTextField)5 Color (java.awt.Color)4 Point (java.awt.Point)4