Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ka2ddo.yaac.gui
Class MultiRangeSpinnerNumberModel

    java.lang.Object
      javax.swing.AbstractSpinnerModel
          javax.swing.SpinnerNumberModel
              org.ka2ddo.yaac.gui.MultiRangeSpinnerNumberModel

All Implemented Interfaces:
  java.io.Serializable, javax.swing.SpinnerModel

    public class MultiRangeSpinnerNumberModel

extends javax.swing.SpinnerNumberModel

This class implements a spinner model that handles multiple disjoint ranges of numbers. Its initial intent was for the frequency ranges on repeater objects (formatted for Kenwood 1-button QSY), but it can be used for any other similar purpose.

See Also:
  Serialized Form

Field Summary

Fields inherited from class javax.swing.AbstractSpinnerModel
`listenerList`

Constructor Summary
`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`.

Method Summary
`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.

Methods inherited from class javax.swing.SpinnerNumberModel
`setMaximum, setMinimum, setStepSize`

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, wait, wait, wait`

Constructor Detail

### MultiRangeSpinnerNumberModel

    public 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`. 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.

  Parameters:
    `value` - the current (non `null`) value of the model
    `minimum` - the first number in the sequence or `null`
    `maximum` - the last number in the sequence or `null`
    `stepSize` - the difference between elements of the sequence
  Throws:
    `java.lang.IllegalArgumentException` - if stepSize or value is `null` or if the following expression is false: `minimum <= value <= maximum`

### MultiRangeSpinnerNumberModel

    public MultiRangeSpinnerNumberModel(int value,
                                        int minimum,
                                        int maximum,
                                        int stepSize)

  Constructs a `MultiRangeSpinnerNumberModel` with the specified `value`, `minimum`/`maximum` bounds, and `stepSize`.

  Parameters:
    `value` - the current value of the model
    `minimum` - the first number in the sequence
    `maximum` - the last number in the sequence
    `stepSize` - the difference between elements of the sequence
  Throws:
    `java.lang.IllegalArgumentException` - if the following expression is false: `minimum <= value <= maximum`

### MultiRangeSpinnerNumberModel

    public MultiRangeSpinnerNumberModel(double value,
                                        double minimum,
                                        double maximum,
                                        double stepSize)

  Constructs a `MultiRangeSpinnerNumberModel` with the specified `value`, `minimum`/`maximum` bounds, and `stepSize`.

  Parameters:
    `value` - the current value of the model
    `minimum` - the first number in the sequence
    `maximum` - the last number in the sequence
    `stepSize` - the difference between elements of the sequence
  Throws:
    `java.lang.IllegalArgumentException` - if the following expression is false: `minimum <= value <= maximum`

### MultiRangeSpinnerNumberModel

    public MultiRangeSpinnerNumberModel()

  Constructs a `MultiRangeSpinnerNumberModel` with no `minimum` or `maximum` value, `stepSize` equal to one, and an initial value of zero.

Method Detail

### addRange

    public void addRange(java.lang.Comparable minimum,
                         java.lang.Comparable maximum,
                         java.lang.Number stepSize)

  Add another 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 `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.

  Parameters:
    `minimum` - the first number in the sequence or `null`
    `maximum` - the last number in the sequence or `null`
    `stepSize` - the difference between elements of the sequence
  Throws:
    `java.lang.IllegalArgumentException` - if stepSize or value is `null` or if the following expression is false: `minimum <= value <= maximum`

### addRange

    public void addRange(double minimum,
                         double maximum,
                         double stepSize)

  Add another closed sequence of numbers from `minimum` to `maximum`.

  Parameters:
    `minimum` - the first number in the sequence
    `maximum` - the last number in the sequence
    `stepSize` - the difference between elements of this sequence
  Throws:
    `java.lang.IllegalArgumentException` - if the following expression is false: `minimum <= value <= maximum`

### getMinimum

    public java.lang.Comparable getMinimum()

  Returns the first number in this sequence.

  Overrides:
    `getMinimum` in class `javax.swing.SpinnerNumberModel`
  Returns:
    the value of the `minimum` property

### getMaximum

    public java.lang.Comparable getMaximum()

  Returns the last number in the sequence.

  Overrides:
    `getMaximum` in class `javax.swing.SpinnerNumberModel`
  Returns:
    the value of the `maximum` property

### getStepSize

    public java.lang.Number getStepSize()

  Returns the size of the value change computed by the `getNextValue` and `getPreviousValue` methods.

  Overrides:
    `getStepSize` in class `javax.swing.SpinnerNumberModel`
  Returns:
    the value of the `stepSize` property

### getNextValue

    public java.lang.Object getNextValue()

  Returns the next number in the sequence.

  Specified by:
    `getNextValue` in interface `javax.swing.SpinnerModel`
  Overrides:
    `getNextValue` in class `javax.swing.SpinnerNumberModel`
  Returns:
    `value + stepSize` or `null` if the sum exceeds `maximum`.
  See Also:
    `SpinnerModel.getNextValue()`, `getPreviousValue()`

### getPreviousValue

    public java.lang.Object getPreviousValue()

  Returns the previous number in the sequence.

  Specified by:
    `getPreviousValue` in interface `javax.swing.SpinnerModel`
  Overrides:
    `getPreviousValue` in class `javax.swing.SpinnerNumberModel`
  Returns:
    `value - stepSize`, or `null` if the sum is less than `minimum`.
  See Also:
    `SpinnerModel.getPreviousValue()`, `getNextValue()`

### getNumber

    public java.lang.Number getNumber()

  Returns the value of the current element of the sequence.

  Overrides:
    `getNumber` in class `javax.swing.SpinnerNumberModel`
  Returns:
    the value property
  See Also:
    `setValue(java.lang.Object)`

### getValue

    public java.lang.Object getValue()

  Returns the value of the current element of the sequence.

  Specified by:
    `getValue` in interface `javax.swing.SpinnerModel`
  Overrides:
    `getValue` in class `javax.swing.SpinnerNumberModel`
  Returns:
    the value property
  See Also:
    `setValue(java.lang.Object)`, `getNumber()`

### setValue

    public void setValue(java.lang.Object value)

  Sets the current value for this sequence. If `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.

  Specified by:
    `setValue` in interface `javax.swing.SpinnerModel`
  Overrides:
    `setValue` in class `javax.swing.SpinnerNumberModel`
  Parameters:
    `value` - the current (non `null`) `Number` for this sequence
  Throws:
    `java.lang.IllegalArgumentException` - if `value` is `null` or not a `Number`
  See Also:
    `getNumber()`, `getValue()`, `SpinnerModel.addChangeListener(javax.swing.event.ChangeListener)`

### toString

    public java.lang.String toString()

  Returns a string representation of the object. In general, the `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.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of the object.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD