Class JaxoSpinnerIntModel
java.lang.Object
javax.swing.AbstractSpinnerModel
javax.swing.SpinnerNumberModel
net.sf.jaxodraw.gui.swing.spinner.JaxoSpinnerIntModel
- All Implemented Interfaces:
Serializable
,SpinnerModel
Specialization of SpinnerNumberModel that a) only allows integers (to avoid
rounding issues) and has some convenience methods for them;
b) optionally allows snapping the 'value' to only a subset of the integers.
- Since:
- 2.0
- See Also:
-
Field Summary
Fields inherited from class javax.swing.AbstractSpinnerModel
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionJaxoSpinnerIntModel
(int minimum, int maximum, int stepSize) With the given properties.JaxoSpinnerIntModel
(int minimum, int maximum, int stepSize, int orig) With the given properties. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
SpinnerNumberModel.getValue()
as an int.final int
Origin to be used for snapping.final boolean
isSnap()
Is 'value' always snapped to 'origin' + multiples of stepSize?void
setIntStepSize
(int newValue) setStepSize(java.lang.Number)
with int argument.final void
setIntValue
(int newValue) setValue(java.lang.Object)
with int argument.void
setOrigin
(int newValue) Set origin property (potentially changing also 'value').void
setSnap
(boolean newValue) Set snap property (potentially changing also 'value').void
setStepSize
(Number stepSize) void
Methods inherited from class javax.swing.SpinnerNumberModel
getMaximum, getMinimum, getNextValue, getNumber, getPreviousValue, getStepSize, getValue, setMaximum, setMinimum
Methods inherited from class javax.swing.AbstractSpinnerModel
addChangeListener, fireStateChanged, getChangeListeners, getListeners, removeChangeListener
-
Constructor Details
-
JaxoSpinnerIntModel
public JaxoSpinnerIntModel(int minimum, int maximum, int stepSize) With the given properties. 'value' and 'origin' are set to the 'minimum', 'snap' to false.- Parameters:
minimum
- minimummaximum
- maximumstepSize
- stepSize
-
JaxoSpinnerIntModel
public JaxoSpinnerIntModel(int minimum, int maximum, int stepSize, int orig) With the given properties. 'snap' is set to true, 'value' is set to the snapped 'minimum'.- Parameters:
minimum
- minimummaximum
- maximumstepSize
- stepSizeorig
- origin
-
-
Method Details
-
getIntValue
public final int getIntValue()SpinnerNumberModel.getValue()
as an int.- Returns:
- int
-
setValue
- Specified by:
setValue
in interfaceSpinnerModel
- Overrides:
setValue
in classSpinnerNumberModel
-
setIntValue
public final void setIntValue(int newValue) setValue(java.lang.Object)
with int argument.- Parameters:
newValue
- the new int value.
-
setIntStepSize
public void setIntStepSize(int newValue) setStepSize(java.lang.Number)
with int argument.- Parameters:
newValue
- the new step size.
-
setStepSize
- Overrides:
setStepSize
in classSpinnerNumberModel
-
getOrigin
public final int getOrigin()Origin to be used for snapping. If 'snap' is true, the only allowed values areorigin + n * stepSize
, with 'n' an integer.- Returns:
- int
-
setOrigin
public void setOrigin(int newValue) Set origin property (potentially changing also 'value').- Parameters:
newValue
- the new origin.
-
isSnap
public final boolean isSnap()Is 'value' always snapped to 'origin' + multiples of stepSize?- Returns:
- boolean
-
setSnap
public void setSnap(boolean newValue) Set snap property (potentially changing also 'value').- Parameters:
newValue
- the new snap.
-