|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cosylab.gui.components.range2.RangedValueController
public class RangedValueController
RangedValue is used as pasive data representation, where each change to the
RangedValue is reported via RangedValueListener. This ensures centralized
handling of all changes and modifications.
This is also the central class to be used when working with ranged value.
Typical use can be shown as:
class Example implements RangedValueListener {
...
RangedValue value = new RangedValue();
value.addRangeValueListener(this);
value.addChangePolicy(new RescalingValuePolicy()); value.setRange(new
LogarithmicRange()); ... void valueChanged(RangedValueEvent event) { if
(event.minOrMaxChanged()) { // repaint scale } if (event.valueChanged()) {
// repaint value }}
RangedValue will ensure that value vill always be consistant within min, max in range and policies.
Constructor Summary | |
---|---|
RangedValueController()
|
Method Summary | |
---|---|
void |
addPolicy(RangedValuePolicy p)
Adds a policy to this controller. |
void |
addRangedValueListener(RangedValueListener listener)
Adds a RangedValueListener to the the controller. |
Tick[] |
calculateTicks(int width)
Calculates ticks using default the given width and default measurer. |
Tick[] |
calculateTicks(int w,
TickParameters measurer)
Calculates ticks using the given measurer and width. |
protected Range |
createDefaultRange()
Creates default range implementation. |
protected void |
firePolicyAdded()
|
protected void |
firePolicyRemoved()
|
protected void |
fireValueChange(boolean min,
boolean max,
boolean val,
boolean raw)
|
protected void |
fireValueChange(RangedValueEvent event)
Notify listeners of the change. |
double |
getMaximum()
Returns current maximum the value can take. |
double |
getMinimum()
Returns current minimum the value can take. |
RangedValuePolicy |
getPolicy()
Returns the currently employed policy. |
Range |
getRange()
Returns current range definition. |
RangedValue |
getRangedValue()
Returns the RangedValue employed by this controller. |
double |
getRawValue()
Returns the actual value. |
double |
getRelativeValue()
Returns the relative value between min and max. |
double |
getScalingFactor()
Returns the scalingFactor. |
TickCalculator |
getTickCalculator()
Returns the ManualTickProvider which is used to calculated ticks for this controller. |
double |
getValue()
Returns current value. |
boolean |
isSnapToTicks()
Returns true if snap to ticks is turned on. |
void |
removePolicy(RangedValuePolicy p)
Removes the policy from the controller. |
void |
removePolicyByType(java.lang.Class<? extends RangedValuePolicy> c)
Removes all policies of the given type. |
void |
removeRangedValueListener(RangedValueListener listener)
Removes RangedValueListener from this controller. |
void |
setMaximum(double value)
Sets new maximum. |
void |
setMinimum(double value)
Sets new minimum. |
void |
setPolicy(RangedValuePolicy policy)
Adds new RangedValuePolicy . |
void |
setRange(Range newRange)
Sets the new definition of Range . |
void |
setRangedValue(RangedValue v)
Sets the RangedValue to this controller. |
void |
setRelativeValue(double value)
Sets relative value according to min and max. |
void |
setScalingFactor(double scalingFactor)
Sets new scalingFactor. |
void |
setSnapToTicks(boolean snapToTicks)
Sets the snap to ticks property. |
void |
setTickCalculator(TickCalculator calculator)
Sets the TickCalculator which overrides any default settings for this controller. |
void |
setValue(double value)
Sets new value. |
void |
setValue(double minimum,
double maximum,
double value)
Initializes all values to new values. |
double |
toAbsolute(double proportional)
Converts proportional value to the absolute. |
double |
toRelative(double d)
Converts the given value to the relative value according to the bounds. |
double |
validate(double value)
Validates the value according to the bounds and policies. |
RangedValue |
validatePolicies(RangedValue values)
Checks all policies to give them oportunity to modify the values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RangedValueController()
Method Detail |
---|
protected Range createDefaultRange()
LinearRange
class is created.
public Range getRange()
getRange()
public void setRange(Range newRange)
Range
.
setRange(Range)
public void setRangedValue(RangedValue v)
v
- new ranged valuepublic RangedValue getRangedValue()
public double getMinimum()
getMinimum()
public double getMaximum()
getMaximum()
public double getValue()
getValue()
public void setValue(double value)
com.cosylab.gui.components.range2.RangedValueController#setValue()
public void setMinimum(double value)
value
- doublepublic void setMaximum(double value)
value
- doublepublic RangedValue validatePolicies(RangedValue values)
values
- holder of values.public void setValue(double minimum, double maximum, double value)
minimum
- doublemaximum
- doublevalue
- double
InvalidBoundException
- In case the parameters do not conform with
policies defined by this range.protected void fireValueChange(RangedValueEvent event)
event
- protected void fireValueChange(boolean min, boolean max, boolean val, boolean raw)
protected void firePolicyAdded()
protected void firePolicyRemoved()
public void setPolicy(RangedValuePolicy policy)
RangedValuePolicy
. Polices will be checked in the
same order they are added.
com.cosylab.gui.components.range2.RangedValueController#addChangePolicy(RangedValuePolicy)
public void addRangedValueListener(RangedValueListener listener)
listener
- public void removeRangedValueListener(RangedValueListener listener)
listener
- public double getRelativeValue()
public void setRelativeValue(double value)
value
- new valuepublic double getRawValue()
public double validate(double value)
value
- value to be validated
public double getScalingFactor()
public void setScalingFactor(double scalingFactor)
scalingFactor
- The scalingFactor to set.public RangedValuePolicy getPolicy()
public void addPolicy(RangedValuePolicy p)
p
- public void removePolicy(RangedValuePolicy p)
p
- public void removePolicyByType(java.lang.Class<? extends RangedValuePolicy> c)
c
- public double toRelative(double d)
d
- value to be converted
public Tick[] calculateTicks(int w, TickParameters measurer)
w
- measurer
-
public double toAbsolute(double proportional)
proportional
- value to be converted
public Tick[] calculateTicks(int width)
width
-
public void setTickCalculator(TickCalculator calculator)
provider
- public TickCalculator getTickCalculator()
public void setSnapToTicks(boolean snapToTicks)
snapToTicks
- true if thumb should snap to tickspublic boolean isSnapToTicks()
setSnapToTicks(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |