use of javax.swing.SpinnerNumberModel in project ACS by ACS-Community.
the class BeanGrouper method startSample.
/**
* Method to begin the sampling of all the samples contained in the class.
* It initializes the SamplingDataCorrelator Object, which is used to store data to file.<br>
*/
private void startSample() {
double freq = 0;
int prev_status;
freq = ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().doubleValue();
Date startTimestamp = new Date();
if (getSaveButton().isSelected()) {
_sdc = new SamplingDataCorrelator(group, ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().intValue(), startTimestamp);
getFileNameLabel().setText("Sampling to file: " + _sdc.getFilename());
getFileNameLabel().setToolTipText("Saving data to: " + _sdc.getFilename());
} else {
}
prev_status = getStatusIcon().getStatus();
model.clear();
for (DataPrinter wp : samplers) {
wp.setFrequency(freq);
try {
wp.startSample();
isStopped = false;
addToStatusList("Status: Sampling of " + wp.getComponent() + "#" + wp.getProperty() + " started");
updateStatusList();
setStatusIcon(StatusIcon.SAMPLING);
ssg.setStatus(StatusIcon.CONNECTED_TO_SAMPMANAGER);
} catch (alma.ACSErrTypeCommon.CouldntAccessComponentEx e) {
wp.setComponentAvailable(false, "Cannot access component");
addToStatusList("Status: Cannot access component " + wp.getComponent());
updateStatusList();
setStatusIcon(StatusIcon.SAMPLING_WARNING);
} catch (alma.ACSErrTypeCommon.TypeNotSupportedEx e) {
wp.setComponentAvailable(false, "Type not supported");
addToStatusList("Status: Type not supported " + wp.getComponent() + "#" + wp.getProperty());
updateStatusList();
setStatusIcon(StatusIcon.SAMPLING_WARNING);
} catch (alma.ACSErrTypeCommon.CouldntAccessPropertyEx e) {
wp.setComponentAvailable(false, "Cannot access property");
addToStatusList("Status: Cannot access property " + wp.getProperty());
updateStatusList();
setStatusIcon(StatusIcon.SAMPLING_WARNING);
} catch (cl.utfsm.samplingSystemUI.core.SamplingManagerException e) {
wp.setComponentAvailable(false, "Sampling Manager fault");
//to have only one "Status: Sampling Manager Fault" in the statusComboBox
if (!faultErrorAddedToStatusBox) {
addToStatusList("Status: Sampling Manager fault");
updateStatusList();
faultErrorAddedToStatusBox = true;
}
getStatusIcon().setStatus(StatusIcon.DISCONNECTED);
ssg.setStatus(StatusIcon.DISCONNECTED);
}
}
if (isStopped) {
stopButton.setEnabled(false);
pauseButton.setEnabled(false);
startButton.setEnabled(true);
freqSpinner.setEnabled(true);
timeSampSpinner.setEnabled(true);
getSaveButton().setEnabled(true);
//setStatusIcon(prev_status);
return;
}
if (script != null)
new ScriptRunner(script).start();
int mins = ((SpinnerNumberModel) this.getTimeSampSpinner().getModel()).getNumber().intValue();
if (script == null && mins != 0)
new Watchdog(mins).start();
}
use of javax.swing.SpinnerNumberModel in project ACS by ACS-Community.
the class BeanGrouper method getTimeWindowSpinner.
/**
* Initializes the TextField that will allow to input the desired Time Window for the Sampling Group.<br>
* By default the value is 10, which means 10 minutes.<br>
* Also checks for its correctness when the value changes.
* @return javax.swing.JTextField Reference to the Text Field containing the number.
*/
private JSpinner getTimeWindowSpinner() {
if (timeWindowSpinner == null) {
timeWindowSpinner = new JSpinner();
timeWindowSpinner.setToolTipText("How much data, expressed in seconds, will the trend present in the graph.");
timeWindowSpinner.setModel(new SpinnerNumberModel(5, 1, 900, 1));
timeWindowSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
setTimeWindow();
}
});
}
return timeWindowSpinner;
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class GuiLafConfigPane method doToolTipDismissDelay.
public void doToolTipDismissDelay(JPanel panel) {
GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
JLabel toolTipDismissDelayLabel = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelay"));
toolTipDismissDelaySpinner = new JSpinner(new SpinnerNumberModel(manager.getToolTipDismissDelay() / 1000, MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME, 1));
this.toolTipDismissDelaySpinner.addChangeListener((ChangeEvent e) -> {
// convert to milliseconds from seconds
manager.setToolTipDismissDelay((int) toolTipDismissDelaySpinner.getValue() * 1000);
});
this.toolTipDismissDelaySpinner.setToolTipText(MessageFormat.format(ConfigBundle.getMessage("GUIToolTipDismissDelayToolTip"), MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME));
toolTipDismissDelayLabel.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
JLabel toolTipDismissDelayUoM = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelayUoM"));
toolTipDismissDelayUoM.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
panel.add(toolTipDismissDelayLabel);
panel.add(toolTipDismissDelaySpinner);
panel.add(toolTipDismissDelayUoM);
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class CoordinateEdit method initSetXY.
public void initSetXY() {
oldX = pl.getX();
oldY = pl.getY();
textX = new javax.swing.JLabel();
textX.setText("X: " + pl.getX());
textX.setVisible(true);
textY = new javax.swing.JLabel();
textY.setText("Y: " + pl.getY());
textY.setVisible(true);
SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 10000, 1);
ChangeListener listener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int x = ((Number) spinX.getValue()).intValue();
int y = ((Number) spinY.getValue()).intValue();
pl.setLocation(x, y);
textX.setText("X: " + pl.getX());
textY.setText("Y: " + pl.getY());
}
};
spinX = new javax.swing.JSpinner(model);
spinX.setValue(Integer.valueOf(pl.getX()));
spinX.setToolTipText(Bundle.getMessage("EnterXcoord"));
spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
spinX.addChangeListener(listener);
model = new javax.swing.SpinnerNumberModel(0, 0, 10000, 1);
spinY = new javax.swing.JSpinner(model);
spinY.setValue(Integer.valueOf(pl.getY()));
spinY.setToolTipText(Bundle.getMessage("EnterYcoord"));
spinY.setMaximumSize(new Dimension(spinY.getMaximumSize().width, spinY.getPreferredSize().height));
spinY.addChangeListener(listener);
getContentPane().setLayout(new GridBagLayout());
addSpinItems(true);
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
int x = ((Number) spinX.getValue()).intValue();
int y = ((Number) spinY.getValue()).intValue();
pl.setLocation(x, y);
textX.setText("X: " + pl.getX());
textY.setText("Y: " + pl.getY());
dispose();
}
});
okButton.getRootPane().setDefaultButton(okButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pl.setLocation(oldX, oldY);
dispose();
}
});
// make large enough to easily move
setMinimumSize(new Dimension(250, 175));
pack();
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class DecoratorPanel method makeFontPanels.
protected void makeFontPanels() {
JPanel fontPanel = new JPanel();
_fontSizeBox = new AJComboBox(FONTSIZE, SIZE);
// NOI18N
fontPanel.add(makeBoxPanel("FontSize", _fontSizeBox));
int row = 4;
for (int i = 0; i < FONTSIZE.length; i++) {
if (_util.getFontSize() == Integer.parseInt(FONTSIZE[i])) {
row = i;
break;
}
}
_fontSizeBox.setSelectedIndex(row);
_fontStyleBox = new AJComboBox(STYLES, STYLE);
// NOI18N
fontPanel.add(makeBoxPanel("FontStyle", _fontStyleBox));
_fontStyleBox.setSelectedIndex(_util.getFont().getStyle());
_fontJustBox = new AJComboBox(JUSTIFICATION, JUST);
// NOI18N
fontPanel.add(makeBoxPanel("Justification", _fontJustBox));
switch(_util.getJustification()) {
case PositionablePopupUtil.LEFT:
row = 0;
break;
case PositionablePopupUtil.RIGHT:
row = 2;
break;
case PositionablePopupUtil.CENTRE:
row = 1;
break;
default:
row = 2;
}
_fontJustBox.setSelectedIndex(row);
this.add(fontPanel);
JPanel sizePanel = new JPanel();
SpinnerNumberModel model = new SpinnerNumberModel(_util.getBorderSize(), 0, 100, 1);
_borderSpin = new AJSpinner(model, BORDER);
sizePanel.add(makeSpinPanel("borderSize", _borderSpin));
model = new SpinnerNumberModel(_util.getMargin(), 0, 100, 1);
_marginSpin = new AJSpinner(model, MARGIN);
sizePanel.add(makeSpinPanel("marginSize", _marginSpin));
model = new SpinnerNumberModel(_util.getFixedWidth(), 0, 1000, 1);
_widthSpin = new AJSpinner(model, FWIDTH);
sizePanel.add(makeSpinPanel("fixedWidth", _widthSpin));
model = new SpinnerNumberModel(_util.getFixedHeight(), 0, 1000, 1);
_heightSpin = new AJSpinner(model, FHEIGHT);
sizePanel.add(makeSpinPanel("fixedHeight", _heightSpin));
this.add(sizePanel);
JPanel colorPanel = new JPanel();
colorPanel.add(makeButton(new AJRadioButton(Bundle.getMessage("borderColor"), BORDER_COLOR)));
this.add(colorPanel);
}
Aggregations