Class JaxoSpinnerIntModel

java.lang.Object
javax.swing.AbstractSpinnerModel
javax.swing.SpinnerNumberModel
net.sf.jaxodraw.gui.swing.spinner.JaxoSpinnerIntModel
All Implemented Interfaces:
Serializable, SpinnerModel

public class JaxoSpinnerIntModel extends 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:
  • 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 - 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 Details

    • getIntValue

      public final int getIntValue()
      Returns:
      int
    • setValue

      public void setValue(Object value)
      Specified by:
      setValue in interface SpinnerModel
      Overrides:
      setValue in class 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)
      Parameters:
      newValue - the new step size.
    • setStepSize

      public void setStepSize(Number stepSize)
      Overrides:
      setStepSize in class 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.