de.pxlab.gui
Class AxisModel

java.lang.Object
  extended by de.pxlab.gui.AxisModel
Direct Known Subclasses:
LinearAxisModel, LogAxisModel, PowerAxisModel

public abstract class AxisModel
extends java.lang.Object

This class describes a very general model for a bounded range of numbers which may be viewed by a Axis. An essential property of the model is that it does not fix the scale type and the corresponding operation which is used to construct standard sequences on the scale. The mapping of the model to the axis view is a two-step process: First the model's range is mapped onto the interval [0.0, 1.0] and then this interval is mapped onto the view. This is a graphic illustration of the the mapping of the axis model:

Model         Minimum ------------ Value ------------Maximum
                 |                   |                  |
                 V                   V                  V
MappedScale     0.0 ---------------------------------- 1.0
                 |                   |                  |
                 V                   V                  V
View          ScaleX --------------- x ---------- (ScaleX + RangeX)


getMappedValue(x):  Model -> MappedScale

setValueFromMap(x): MappedScale -> Model

Version:
0.2.0
See Also:
AxisListener, Slider

Field Summary
protected  AxisListener axisListener
           
protected  double maximum
           
protected  double minimum
           
protected  double value
           
 
Constructor Summary
AxisModel()
           
 
Method Summary
protected abstract  double getMappedValue(double x)
          Map a value from the axis model into the range [0.0, 1.0] on the MappedScale
 double getMaximum()
          Return the upper bound of the axis model.
 double getMinimum()
          Return the lower bound of the axis model.
protected abstract  double getStepSizeValue(int n)
          Return the size of a single step on the model's scale when the range [min, max] is divided by n equally spaced steps.
 double getValue()
          Return the current value of the axis model.
protected abstract  double getValueForSteps(int n, double step)
          Get the position on the scale where we arrive when moving from position start by n steps of size step.
protected abstract  double getValueFromMap(double v)
          Get a value on the model's scale from a value on the MappedScale in the range [0.0, 1.0]
 void removeAxisListener()
           
 void setAxisListener(AxisListener ax)
           
 void setMaximum(double x)
          Set the upper bound of the axis model.
 void setMinimum(double x)
          Set the lower bound of the range of values.
 void setValue(double v)
          Set the current value of the axis model.
protected  boolean setValueFromMap(double v)
          Set the model's value from a value on the MappedScale in the range [0.0, 1.0].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minimum

protected double minimum

maximum

protected double maximum

value

protected double value

axisListener

protected AxisListener axisListener
Constructor Detail

AxisModel

public AxisModel()
Method Detail

setMinimum

public void setMinimum(double x)
Set the lower bound of the range of values.


getMinimum

public double getMinimum()
Return the lower bound of the axis model.


setMaximum

public void setMaximum(double x)
Set the upper bound of the axis model.


getMaximum

public double getMaximum()
Return the upper bound of the axis model.


getValue

public double getValue()
Return the current value of the axis model.


setValue

public void setValue(double v)
Set the current value of the axis model. This method is used to position the model indenpendent of the axis listener. It usually requires the the model's view be repainted in order to correctly reflect the model's state.


getMappedValue

protected abstract double getMappedValue(double x)
Map a value from the axis model into the range [0.0, 1.0] on the MappedScale


setValueFromMap

protected boolean setValueFromMap(double v)
Set the model's value from a value on the MappedScale in the range [0.0, 1.0].


setAxisListener

public void setAxisListener(AxisListener ax)

removeAxisListener

public void removeAxisListener()

getValueFromMap

protected abstract double getValueFromMap(double v)
Get a value on the model's scale from a value on the MappedScale in the range [0.0, 1.0]


getStepSizeValue

protected abstract double getStepSizeValue(int n)
Return the size of a single step on the model's scale when the range [min, max] is divided by n equally spaced steps.


getValueForSteps

protected abstract double getValueForSteps(int n,
                                           double step)
Get the position on the scale where we arrive when moving from position start by n steps of size step.