com.jgoodies.binding.adapter
Class BoundedRangeAdapter
java.lang.Object
com.jgoodies.binding.adapter.BoundedRangeAdapter
- BoundedRangeModel, Serializable
public final class BoundedRangeAdapter
extends java.lang.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));
BoundedRangeAdapter(ValueModel subject, int extent, int min, int max) - Constructs a BoundedRangeAdapter on the given subject
using the specified extend, minimum and maximum values.
|
@Override | String toString() - Returns a string that displays all of the BoundedRangeModel properties.
|
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.
|
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.
subject
- the underlying ValueModel that provides the valueextent
- the extent to be setmin
- the minimum to be setmax
- the maximum to be set
String toString
public @Override String toString()
Returns a string that displays all of the BoundedRangeModel properties.
- a string representation of the properties
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.
l
- the ChangeListener to add
fireStateChanged
protected void fireStateChanged()
Runs each ChangeListeners stateChanged() method.
getExtent
public int getExtent()
Returns this model's extent.
getMaximum
public int getMaximum()
Returns this model's upper bound, the maximum.
getMinimum
public int getMinimum()
Returns this model's lower bound, the minimum.
getValue
public int getValue()
Returns the current subject value, or the minimum if
the subject value is null
.
- the model's current value
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.
- the value of the valueIsAdjusting property
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes a ChangeListener.
l
- the ChangeListener to remove
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
n
- the new extent before ensuring a non-negative number
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
n
- the new maximum before ensuring this adapter's constraints
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
n
- the new minimum before ensuring constraints
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.
newValue
- the value to be setnewExtent
- the extent to be setnewMin
- the minimum to be setnewMax
- the maximum to be setadjusting
- true if there are other pending changes
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
n
- the new value before ensuring constraints
BoundedRangeModel.setValue(int)
setValueIsAdjusting
public void setValueIsAdjusting(boolean b)
Sets the valueIsAdjusting property.
Copyright © 2002-2007 JGoodies Karsten Lentzsch. All Rights Reserved.