net.sf.jaxodraw.gui.swing.spinner
Class JaxoSpinnerIntModel

java.lang.Object
  extended by javax.swing.AbstractSpinnerModel
      extended by javax.swing.SpinnerNumberModel
          extended by 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

Field Summary
 
Fields inherited from class javax.swing.AbstractSpinnerModel
listenerList
 
Constructor Summary
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
 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
 
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
 

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 - minimum
maximum - maximum
stepSize - 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 - minimum
maximum - maximum
stepSize - stepSize
orig - 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 interface javax.swing.SpinnerModel
Overrides:
setValue in class javax.swing.SpinnerNumberModel

setIntValue

public 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 class javax.swing.SpinnerNumberModel

getOrigin

public final int getOrigin()
Origin to be used for snapping. If 'snap' is true, the only allowed values are origin + 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.


Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.