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);
}
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);
}
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());
}
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();
}
}
});
}
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;
}
Aggregations