Class JaxoSpinnerIntModel
- java.lang.Object
-
- javax.swing.AbstractSpinnerModel
-
- javax.swing.SpinnerNumberModel
-
- net.sf.jaxodraw.gui.swing.spinner.JaxoSpinnerIntModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.SpinnerModel
public class JaxoSpinnerIntModel extends javax.swing.SpinnerNumberModel
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JaxoSpinnerIntModel(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getIntValue()
SpinnerNumberModel.getValue()
as an int.int
getOrigin()
Origin to be used for snapping.boolean
isSnap()
Is 'value' always snapped to 'origin' + multiples of stepSize?void
setIntStepSize(int newValue)
setStepSize(java.lang.Number)
with int argument.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(java.lang.Number stepSize)
void
setValue(java.lang.Object value)
-
Methods inherited from class javax.swing.SpinnerNumberModel
getMaximum, getMinimum, getNextValue, getNumber, getPreviousValue, getStepSize, getValue, setMaximum, setMinimum
-
-
-
-
Constructor Detail
-
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 Detail
-
getIntValue
public final int getIntValue()
SpinnerNumberModel.getValue()
as an int.- Returns:
- int
-
setValue
public void setValue(java.lang.Object value)
- Specified by:
setValue
in interfacejavax.swing.SpinnerModel
- Overrides:
setValue
in classjavax.swing.SpinnerNumberModel
-
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
public void setStepSize(java.lang.Number stepSize)
- Overrides:
setStepSize
in classjavax.swing.SpinnerNumberModel
-
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.
-
-