public class MultiRangeSpinnerNumberModel
extends javax.swing.SpinnerNumberModel
| Constructor and Description |
|---|
MultiRangeSpinnerNumberModel()
Constructs a
MultiRangeSpinnerNumberModel with no
minimum or maximum value,
stepSize equal to one, and an initial value of zero. |
MultiRangeSpinnerNumberModel(double value,
double minimum,
double maximum,
double stepSize)
Constructs a
MultiRangeSpinnerNumberModel with the specified
value, minimum/maximum bounds,
and stepSize. |
MultiRangeSpinnerNumberModel(int value,
int minimum,
int maximum,
int stepSize)
Constructs a
MultiRangeSpinnerNumberModel with the specified
value, minimum/maximum bounds,
and stepSize. |
MultiRangeSpinnerNumberModel(java.lang.Number value,
java.lang.Comparable minimum,
java.lang.Comparable maximum,
java.lang.Number stepSize)
Constructs a
SpinnerModel that represents
a closed sequence of
numbers from minimum to maximum. |
| Modifier and Type | Method and Description |
|---|---|
void |
addRange(java.lang.Comparable minimum,
java.lang.Comparable maximum,
java.lang.Number stepSize)
Add another closed sequence of
numbers from
minimum to maximum. |
void |
addRange(double minimum,
double maximum,
double stepSize)
Add another closed sequence of
numbers from
minimum to maximum. |
java.lang.Comparable |
getMaximum()
Returns the last number in the sequence.
|
java.lang.Comparable |
getMinimum()
Returns the first number in this sequence.
|
java.lang.Object |
getNextValue()
Returns the next number in the sequence.
|
java.lang.Number |
getNumber()
Returns the value of the current element of the sequence.
|
java.lang.Object |
getPreviousValue()
Returns the previous number in the sequence.
|
java.lang.Number |
getStepSize()
Returns the size of the value change computed by the
getNextValue
and getPreviousValue methods. |
java.lang.Object |
getValue()
Returns the value of the current element of the sequence.
|
void |
setValue(java.lang.Object value)
Sets the current value for this sequence.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public MultiRangeSpinnerNumberModel(java.lang.Number value,
java.lang.Comparable minimum,
java.lang.Comparable maximum,
java.lang.Number stepSize)
SpinnerModel that represents
a closed sequence of
numbers from minimum to maximum. The
nextValue and previousValue methods
compute elements of the sequence by adding or subtracting
stepSize respectively. All of the parameters
must be mutually Comparable, value
and stepSize must be instances of Integer
Long, Float, or Double.
The minimum and maximum parameters
can be null to indicate that the range doesn't
have an upper or lower bound.
If value or stepSize is null,
or if both minimum and maximum
are specified and mininum > maximum then an
IllegalArgumentException is thrown.
Similarly if (minimum <= value <= maximum) is false,
an IllegalArgumentException is thrown.
value - the current (non null) value of the modelminimum - the first number in the sequence or nullmaximum - the last number in the sequence or nullstepSize - the difference between elements of the sequencejava.lang.IllegalArgumentException - if stepSize or value is
null or if the following expression is false:
minimum <= value <= maximumpublic MultiRangeSpinnerNumberModel(int value,
int minimum,
int maximum,
int stepSize)
MultiRangeSpinnerNumberModel with the specified
value, minimum/maximum bounds,
and stepSize.value - the current value of the modelminimum - the first number in the sequencemaximum - the last number in the sequencestepSize - the difference between elements of the sequencejava.lang.IllegalArgumentException - if the following expression is false:
minimum <= value <= maximumpublic MultiRangeSpinnerNumberModel(double value,
double minimum,
double maximum,
double stepSize)
MultiRangeSpinnerNumberModel with the specified
value, minimum/maximum bounds,
and stepSize.value - the current value of the modelminimum - the first number in the sequencemaximum - the last number in the sequencestepSize - the difference between elements of the sequencejava.lang.IllegalArgumentException - if the following expression is false:
minimum <= value <= maximumpublic MultiRangeSpinnerNumberModel()
MultiRangeSpinnerNumberModel with no
minimum or maximum value,
stepSize equal to one, and an initial value of zero.public void addRange(java.lang.Comparable minimum,
java.lang.Comparable maximum,
java.lang.Number stepSize)
minimum to maximum. The
nextValue and previousValue methods
compute elements of the sequence by adding or subtracting
stepSize respectively. All of the parameters
must be mutually Comparable, value
and stepSize must be instances of Integer
Long, Float, or Double.
The minimum and maximum parameters
can be null to indicate that the range doesn't
have an upper or lower bound.
If stepSize is null,
or if both minimum and maximum
are specified and mininum > maximum then an
IllegalArgumentException is thrown.
Similarly if (minimum <= value <= maximum) is false,
an IllegalArgumentException is thrown.
minimum - the first number in the sequence or nullmaximum - the last number in the sequence or nullstepSize - the difference between elements of the sequencejava.lang.IllegalArgumentException - if stepSize or value is
null or if the following expression is false:
minimum <= value <= maximumpublic void addRange(double minimum,
double maximum,
double stepSize)
minimum to maximum.minimum - the first number in the sequencemaximum - the last number in the sequencestepSize - the difference between elements of this sequencejava.lang.IllegalArgumentException - if the following expression is false:
minimum <= value <= maximumpublic java.lang.Comparable getMinimum()
getMinimum in class javax.swing.SpinnerNumberModelminimum propertypublic java.lang.Comparable getMaximum()
getMaximum in class javax.swing.SpinnerNumberModelmaximum propertypublic java.lang.Number getStepSize()
getNextValue
and getPreviousValue methods.getStepSize in class javax.swing.SpinnerNumberModelstepSize propertypublic java.lang.Object getNextValue()
getNextValue in interface javax.swing.SpinnerModelgetNextValue in class javax.swing.SpinnerNumberModelvalue + stepSize or null if the sum
exceeds maximum.SpinnerModel.getNextValue(),
getPreviousValue()public java.lang.Object getPreviousValue()
getPreviousValue in interface javax.swing.SpinnerModelgetPreviousValue in class javax.swing.SpinnerNumberModelvalue - stepSize, or
null if the sum is less
than minimum.SpinnerModel.getPreviousValue(),
getNextValue()public java.lang.Number getNumber()
getNumber in class javax.swing.SpinnerNumberModelsetValue(java.lang.Object)public java.lang.Object getValue()
getValue in interface javax.swing.SpinnerModelgetValue in class javax.swing.SpinnerNumberModelsetValue(java.lang.Object),
getNumber()public void setValue(java.lang.Object value)
value is
null, or not a Number, an
IllegalArgumentException is thrown. 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.
setValue in interface javax.swing.SpinnerModelsetValue in class javax.swing.SpinnerNumberModelvalue - the current (non null) Number
for this sequencejava.lang.IllegalArgumentException - if value is
null or not a NumbergetNumber(),
getValue(),
SpinnerModel.addChangeListener(javax.swing.event.ChangeListener)public java.lang.String toString()
toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.toString in class java.lang.Object