public final class BoundedRangeAdapter extends Object implements BoundedRangeModel, Serializable
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));
JSlider,
Serialized Form| Constructor and Description |
|---|
BoundedRangeAdapter(ValueModel subject,
int extent,
int min,
int max)
Constructs a BoundedRangeAdapter on the given subject
using the specified extend, minimum and maximum values.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public BoundedRangeAdapter(ValueModel subject, int extent, int min, int max)
subject - the underlying ValueModel that provides the valueextent - the extent to be setmin - the minimum to be setmax - the maximum to be setIllegalArgumentException - if the following constraints aren't
satisfied: min <= initial subject value <= value+extent <= maxpublic int getExtent()
getExtent in interface BoundedRangeModelsetExtent(int),
BoundedRangeModel.getExtent()public int getMaximum()
getMaximum in interface BoundedRangeModelsetMaximum(int),
BoundedRangeModel.getMaximum()public int getMinimum()
getMinimum in interface BoundedRangeModelsetMinimum(int),
BoundedRangeModel.getMinimum()public int getValue()
null.getValue in interface BoundedRangeModelsetValue(int),
BoundedRangeModel.getValue()public boolean getValueIsAdjusting()
getValueIsAdjusting in interface BoundedRangeModelsetValue(int),
BoundedRangeModel.getValueIsAdjusting()public void setExtent(int n)
minimum <= value <= value+extent <= maximum
setExtent in interface BoundedRangeModeln - the new extent before ensuring a non-negative numberBoundedRangeModel.setExtent(int)public void setMaximum(int n)
minimum <= value <= value+extent <= maximum
setMaximum in interface BoundedRangeModeln - the new maximum before ensuring this adapter's constraintsBoundedRangeModel.setMaximum(int)public void setMinimum(int n)
minimum <= value <= value+extent <= maximum
setMinimum in interface BoundedRangeModeln - the new minimum before ensuring constraintsgetMinimum(),
BoundedRangeModel.setMinimum(int)public void setRangeProperties(int newValue,
int newExtent,
int newMin,
int newMax,
boolean adjusting)
minimum <= value <= value+extent <= maximum
At most, one ChangeEvent is generated.
setRangeProperties in interface BoundedRangeModelnewValue - 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 changesBoundedRangeModel.setRangeProperties(int, int, int, int, boolean),
setValue(int),
setExtent(int),
setMinimum(int),
setMaximum(int),
setValueIsAdjusting(boolean)public void setValue(int n)
minimum <= value <= value+extent <= maximum
setValue in interface BoundedRangeModeln - the new value before ensuring constraintsBoundedRangeModel.setValue(int)public void setValueIsAdjusting(boolean b)
setValueIsAdjusting in interface BoundedRangeModelb - the new valuegetValueIsAdjusting(),
setValue(int),
BoundedRangeModel.setValueIsAdjusting(boolean)public void addChangeListener(ChangeListener l)
addChangeListener in interface BoundedRangeModell - the ChangeListener to addremoveChangeListener(ChangeListener),
BoundedRangeModel.addChangeListener(ChangeListener)public void removeChangeListener(ChangeListener l)
removeChangeListener in interface BoundedRangeModell - the ChangeListener to removeaddChangeListener(ChangeListener),
BoundedRangeModel.removeChangeListener(ChangeListener)protected void fireStateChanged()
Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.