com.ontimize.gui.field.spinner
Class CustomSpinnerNumberModel
java.lang.Object
javax.swing.AbstractSpinnerModel
javax.swing.SpinnerNumberModel
com.ontimize.gui.field.spinner.CustomSpinnerNumberModel
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.SpinnerModel
- public class CustomSpinnerNumberModel
- extends javax.swing.SpinnerNumberModel
- implements java.io.Serializable
- See Also:
- Serialized Form
|
Field Summary |
protected java.lang.Comparable |
maximum
|
protected java.lang.Comparable |
minimum
|
protected java.lang.Number |
stepSize
|
protected java.lang.Number |
value
|
| Fields inherited from class javax.swing.AbstractSpinnerModel |
listenerList |
|
Method Summary |
java.lang.Object |
getNextValue()
Returns the next number in the sequence. |
java.lang.Object |
getPreviousValue()
Returns the previous number in the sequence. |
java.lang.Object |
getValue()
Returns the value of the current element of the sequence. |
protected java.lang.Number |
incrValue(int dir)
|
void |
setValue(java.lang.Object value)
Sets the current value for this sequence. |
| Methods inherited from class javax.swing.SpinnerNumberModel |
getMaximum, getMinimum, getNumber, getStepSize, setMaximum, setMinimum, setStepSize |
| Methods inherited from class javax.swing.AbstractSpinnerModel |
addChangeListener, fireStateChanged, getChangeListeners, getListeners, removeChangeListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stepSize
protected java.lang.Number stepSize
value
protected java.lang.Number value
minimum
protected java.lang.Comparable minimum
maximum
protected java.lang.Comparable maximum
CustomSpinnerNumberModel
public CustomSpinnerNumberModel()
CustomSpinnerNumberModel
public CustomSpinnerNumberModel(double value,
double minimum,
double maximum,
double stepSize)
CustomSpinnerNumberModel
public CustomSpinnerNumberModel(int value,
int minimum,
int maximum,
int stepSize)
CustomSpinnerNumberModel
public CustomSpinnerNumberModel(java.lang.Number value,
java.lang.Comparable minimum,
java.lang.Comparable maximum,
java.lang.Number stepSize)
getNextValue
public java.lang.Object getNextValue()
- Returns the next number in the sequence.
- Specified by:
getNextValue in interface javax.swing.SpinnerModel
- Returns:
value + stepSize or null if the sum
exceeds maximum.- See Also:
SpinnerModel.getNextValue(),
getPreviousValue(),
SpinnerNumberModel.setStepSize(java.lang.Number)
getPreviousValue
public java.lang.Object getPreviousValue()
- Returns the previous number in the sequence.
- Specified by:
getPreviousValue in interface javax.swing.SpinnerModel
- Returns:
value - stepSize, or
null if the sum is less
than minimum.- See Also:
SpinnerModel.getPreviousValue(),
getNextValue(),
SpinnerNumberModel.setStepSize(java.lang.Number)
getValue
public java.lang.Object getValue()
- Returns the value of the current element of the sequence.
- Specified by:
getValue in interface javax.swing.SpinnerModel
- Returns:
- the value property
- See Also:
setValue(java.lang.Object),
SpinnerNumberModel.getNumber()
setValue
public void setValue(java.lang.Object value)
- Sets the current value for this sequence. No
bounds checking is done here; the new value may invalidate the
(minimum <= value <= maximum)
invariant enforced by the constructors. It's also possible to set
the value to be something that wouldn't naturally occur in the sequence,
i.e. a value that's not modulo the stepSize.
This is to simplify updating the model, and to accommodate
spinners that don't want to restrict values that have been
directly entered by the user. Naturally, one should ensure that the
(minimum <= value <= maximum) invariant is true
before calling the next, previous, or
setValue methods.
This method fires a ChangeEvent if the value has changed.
- Specified by:
setValue in interface javax.swing.SpinnerModel
- Parameters:
value - the current (non null) Number
for this sequence
- Throws:
java.lang.IllegalArgumentException - if value is
null or not a Number- See Also:
SpinnerNumberModel.getNumber(),
getValue(),
SpinnerModel.addChangeListener(javax.swing.event.ChangeListener)
incrValue
protected java.lang.Number incrValue(int dir)