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

## com.jgoodies.binding.adapter
Class BoundedRangeAdapter

    java.lang.Object
      com.jgoodies.binding.adapter.BoundedRangeAdapter

All Implemented Interfaces:
  Serializable, BoundedRangeModel

    public final class BoundedRangeAdapter

extends Object
implements BoundedRangeModel, Serializable

Converts a ValueModel to the `BoundedRangeModel` interface. Honors an upper and lower bound and returns the adapter's minimum in case the subject value is `null`.

Example:

     int minSaturation = 0;
     int maxSaturation = 255;
     PresentationModel pm = new PresentationModel(settings);
     ValueModel saturationModel = pm.getModel("saturation");
     JSlider saturationSlider = new JSlider(
         new BoundedRangeAdapter(saturationModel,
                                 0,
                                 minSaturation,
                                 maxSaturation));

Version:
  $Revision: 1.11 $
Author:
  Karsten Lentzsch
See Also:
  `JSlider`, Serialized Form

Constructor Summary
`BoundedRangeAdapter(ValueModel subject, int extent, int min, int max)` Constructs a BoundedRangeAdapter on the given subject using the specified extend, minimum and maximum values.

Method Summary
`void` | `addChangeListener(ChangeListener l)` Adds a ChangeListener.
`protected void` | `fireStateChanged()` Runs each ChangeListeners stateChanged() method.
`int` | `getExtent()` Returns this model's extent.
`int` | `getMaximum()` Returns this model's upper bound, the maximum.
`int` | `getMinimum()` Returns this model's lower bound, the minimum.
`int` | `getValue()` Returns the current subject value, or the minimum if the subject value is `null`.
`boolean` | `getValueIsAdjusting()` Returns true if the value is in the process of changing as a result of actions being taken by the user.
`void` | `removeChangeListener(ChangeListener l)` Removes a ChangeListener.
`void` | `setExtent(int n)` Sets the extent to n.
`void` | `setMaximum(int n)` Sets the maximum to n.
`void` | `setMinimum(int n)` Sets the minimum to n.
`void` | `setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)` Sets all of the BoundedRangeModel properties after forcing the arguments to obey the usual constraints: minimum <= value <= value+extent <= maximum At most, one ChangeEvent is generated.
`void` | `setValue(int n)` Sets the current value of the model.
`void` | `setValueIsAdjusting(boolean b)` Sets the valueIsAdjusting property.
`String` | `toString()` Returns a string that displays all of the BoundedRangeModel properties.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### BoundedRangeAdapter

    public BoundedRangeAdapter(ValueModel subject,
                               int extent,
                               int min,
                               int max)

  Constructs a BoundedRangeAdapter on the given subject using the specified extend, minimum and maximum values.

  Parameters:
    `subject` - the underlying ValueModel that provides the value
    `extent` - the extent to be set
    `min` - the minimum to be set
    `max` - the maximum to be set
  Throws:
    `IllegalArgumentException` - if the following constraints aren't satisfied: `min <= initial subject value <= value+extent <= max`

Method Detail

### getExtent

    public int getExtent()

  Returns this model's extent.

  Specified by:
    `getExtent` in interface `BoundedRangeModel`
  Returns:
    the model's extent
  See Also:
    `setExtent(int)`, `BoundedRangeModel.getExtent()`

### getMaximum

    public int getMaximum()

  Returns this model's upper bound, the maximum.

  Specified by:
    `getMaximum` in interface `BoundedRangeModel`
  Returns:
    the model's maximum
  See Also:
    `setMaximum(int)`, `BoundedRangeModel.getMaximum()`

### getMinimum

    public int getMinimum()

  Returns this model's lower bound, the minimum.

  Specified by:
    `getMinimum` in interface `BoundedRangeModel`
  Returns:
    the model's minimum
  See Also:
    `setMinimum(int)`, `BoundedRangeModel.getMinimum()`

### getValue

    public int getValue()

  Returns the current subject value, or the minimum if the subject value is `null`.

  Specified by:
    `getValue` in interface `BoundedRangeModel`
  Returns:
    the model's current value
  See Also:
    `setValue(int)`, `BoundedRangeModel.getValue()`

### getValueIsAdjusting

    public boolean getValueIsAdjusting()

  Returns true if the value is in the process of changing as a result of actions being taken by the user.

  Specified by:
    `getValueIsAdjusting` in interface `BoundedRangeModel`
  Returns:
    the value of the valueIsAdjusting property
  See Also:
    `setValue(int)`, `BoundedRangeModel.getValueIsAdjusting()`

### setExtent

    public void setExtent(int n)

  Sets the extent to n. Ensures that n is greater than or equal to zero and falls within the adapter's constraints:

           minimum <= value <= value+extent <= maximum

  Specified by:
    `setExtent` in interface `BoundedRangeModel`
  Parameters:
    `n` - the new extent before ensuring a non-negative number
  See Also:
    `BoundedRangeModel.setExtent(int)`

### setMaximum

    public void setMaximum(int n)

  Sets the maximum to n. Ensures that n and the other three properties obey this adapter's constraints:

           minimum <= value <= value+extent <= maximum

  Specified by:
    `setMaximum` in interface `BoundedRangeModel`
  Parameters:
    `n` - the new maximum before ensuring this adapter's constraints
  See Also:
    `BoundedRangeModel.setMaximum(int)`

### setMinimum

    public void setMinimum(int n)

  Sets the minimum to n. Ensures that n and the other three properties obey this adapter's constraints:

           minimum <= value <= value+extent <= maximum

  Specified by:
    `setMinimum` in interface `BoundedRangeModel`
  Parameters:
    `n` - the new minimum before ensuring constraints
  See Also:
    `getMinimum()`, `BoundedRangeModel.setMinimum(int)`

### setRangeProperties

    public void setRangeProperties(int newValue,
                                   int newExtent,
                                   int newMin,
                                   int newMax,
                                   boolean adjusting)

  Sets all of the BoundedRangeModel properties after forcing the arguments to obey the usual constraints:

           minimum <= value <= value+extent <= maximum

  At most, one ChangeEvent is generated.

  Specified by:
    `setRangeProperties` in interface `BoundedRangeModel`
  Parameters:
    `newValue` - the value to be set
    `newExtent` - the extent to be set
    `newMin` - the minimum to be set
    `newMax` - the maximum to be set
    `adjusting` - true if there are other pending changes
  See Also:
    `BoundedRangeModel.setRangeProperties(int, int, int, int, boolean)`, `setValue(int)`, `setExtent(int)`, `setMinimum(int)`, `setMaximum(int)`, `setValueIsAdjusting(boolean)`

### setValue

    public void setValue(int n)

  Sets the current value of the model. For a slider, that determines where the knob appears. Ensures that the new value, n falls within the model's constraints:

           minimum <= value <= value+extent <= maximum

  Specified by:
    `setValue` in interface `BoundedRangeModel`
  Parameters:
    `n` - the new value before ensuring constraints
  See Also:
    `BoundedRangeModel.setValue(int)`

### setValueIsAdjusting

    public void setValueIsAdjusting(boolean b)

  Sets the valueIsAdjusting property.

  Specified by:
    `setValueIsAdjusting` in interface `BoundedRangeModel`
  Parameters:
    `b` - the new value
  See Also:
    `getValueIsAdjusting()`, `setValue(int)`, `BoundedRangeModel.setValueIsAdjusting(boolean)`

### addChangeListener

    public void addChangeListener(ChangeListener l)

  Adds a ChangeListener. The change listeners are run each time any one of the Bounded Range model properties changes.

  Specified by:
    `addChangeListener` in interface `BoundedRangeModel`
  Parameters:
    `l` - the ChangeListener to add
  See Also:
    `removeChangeListener(ChangeListener)`, `BoundedRangeModel.addChangeListener(ChangeListener)`

### removeChangeListener

    public void removeChangeListener(ChangeListener l)

  Removes a ChangeListener.

  Specified by:
    `removeChangeListener` in interface `BoundedRangeModel`
  Parameters:
    `l` - the ChangeListener to remove
  See Also:
    `addChangeListener(ChangeListener)`, `BoundedRangeModel.removeChangeListener(ChangeListener)`

### fireStateChanged

    protected void fireStateChanged()

  Runs each ChangeListeners stateChanged() method.

  See Also:
    `setRangeProperties(int, int, int, int, boolean)`, `EventListenerList`

### toString

    public String toString()

  Returns a string that displays all of the BoundedRangeModel properties.

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of the properties

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

Copyright © 2002-2011 JGoodies Karsten Lentzsch. All Rights Reserved.