lt.monarch.chart.swing
Class BoundedRangeModelAdapter

java.lang.Object
  extended by lt.monarch.chart.swing.BoundedRangeModelAdapter
All Implemented Interfaces:
java.io.Serializable, javax.swing.BoundedRangeModel, AxisMapperRangeListener

public class BoundedRangeModelAdapter
extends java.lang.Object
implements javax.swing.BoundedRangeModel, AxisMapperRangeListener, java.io.Serializable

Adapter adapts a AxisMapperRange object to a swing BoundedRangeModel interface. Thus mapper range objects can be manipulated by swing controls. For example a swing JScrollBar can be used to scroll chart contents
Mapper range has no notion of the count of steps in the range. Mapper range bounds are always [0,1], while BoundedRangeModel bounds can be changed. For best results one should set the BoundedRangeModelAdapter bounds to some reasonable number by calling setMaximum and setMinimum.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  javax.swing.event.ChangeEvent changeEvent
          ChangeEvent used to notify listeners that state has changed
protected  javax.swing.event.EventListenerList listenerList
          the list of model listeners
protected  AxisMapperRange range
          the axis mapper range
 
Constructor Summary
Constructor and Description
BoundedRangeModelAdapter(AxisMapperRange range)
          Constructs a new BoundedRangeModelAdapter with the specified axis mapper range.
 
Method Summary
Modifier and Type Method and Description
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the model's listener list.
protected  void fireStateChanged()
          Notifies all model listeners that model state has changed.
 int getExtent()
          Returns the model's extent, the length of the inner range that begins at the model's value.
 int getMaximum()
          Returns the model's maximum.
 int getMinimum()
          Returns the minimum acceptable value.
 int getValue()
          Returns the model's current value.
 boolean getValueIsAdjusting()
          Returns true is the inner axis mapper range is being changed and has not been finalized yet.
 void rangeAdjusting(AxisMapperRange range)
          Invoked when the axis mapper range has entered or exited the adjusting mode.
 void rangeChanged(AxisMapperRange range)
          Invoked when axis mapper range has changed.
 void rangeShifted(AxisMapperRange range)
          Invoked when axis mapper range was shifted.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the model's listener list.
protected  void setBounds(int min, int max)
          Sets minimum and maximum entityStyle for the data model.
 void setExtent(int n)
          Sets the model's extent.
 void setMaximum(int newMaximum)
          Sets the model's maximum to newMaximum.
 void setMinimum(int newMinimum)
          Sets the model's minimum to newMinimum.
 void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)
          Sets range entityStyle for the model.
 void setValue(int newValue)
          Sets the model's current value to newValue.
 void setValueIsAdjusting(boolean b)
          Sets/unsets adjustment mode for inner axis mapper range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

range

protected final AxisMapperRange range
the axis mapper range


changeEvent

protected transient javax.swing.event.ChangeEvent changeEvent
ChangeEvent used to notify listeners that state has changed


listenerList

protected final javax.swing.event.EventListenerList listenerList
the list of model listeners

Constructor Detail

BoundedRangeModelAdapter

public BoundedRangeModelAdapter(AxisMapperRange range)
Constructs a new BoundedRangeModelAdapter with the specified axis mapper range.

Parameters:
range - the axis mapper range
Method Detail

getValue

public int getValue()
Returns the model's current value.

Specified by:
getValue in interface javax.swing.BoundedRangeModel
Returns:
the model's value

getExtent

public int getExtent()
Returns the model's extent, the length of the inner range that begins at the model's value.

Specified by:
getExtent in interface javax.swing.BoundedRangeModel
Returns:
the value of the model's extent property

getMinimum

public int getMinimum()
Returns the minimum acceptable value.

Specified by:
getMinimum in interface javax.swing.BoundedRangeModel
Returns:
the value of the minimum property

getMaximum

public int getMaximum()
Returns the model's maximum.

Specified by:
getMaximum in interface javax.swing.BoundedRangeModel
Returns:
the value of the maximum property

setValue

public void setValue(int newValue)
Sets the model's current value to newValue.

Specified by:
setValue in interface javax.swing.BoundedRangeModel
Parameters:
newValue - the model's new value

setExtent

public void setExtent(int n)
Sets the model's extent.

Specified by:
setExtent in interface javax.swing.BoundedRangeModel
Parameters:
n - the model's new extent

setMinimum

public void setMinimum(int newMinimum)
Sets the model's minimum to newMinimum.

Specified by:
setMinimum in interface javax.swing.BoundedRangeModel
Parameters:
newMinimum - the model's new minimum

setMaximum

public void setMaximum(int newMaximum)
Sets the model's maximum to newMaximum.

Specified by:
setMaximum in interface javax.swing.BoundedRangeModel
Parameters:
newMaximum - the model's new maximum

setBounds

protected void setBounds(int min,
                         int max)
Sets minimum and maximum entityStyle for the data model.

Parameters:
min - minimum of the range
max - maximum of the range

setValueIsAdjusting

public void setValueIsAdjusting(boolean b)
Sets/unsets adjustment mode for inner axis mapper range.

Specified by:
setValueIsAdjusting in interface javax.swing.BoundedRangeModel
Parameters:
b - true, if values are final. false otherwise
See Also:
AxisMapperRange.setIsAdjusting(boolean)

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns true is the inner axis mapper range is being changed and has not been finalized yet.

Specified by:
getValueIsAdjusting in interface javax.swing.BoundedRangeModel
Returns:
is axis mapper range still adjusting

setRangeProperties

public void setRangeProperties(int newValue,
                               int newExtent,
                               int newMin,
                               int newMax,
                               boolean adjusting)
Sets range entityStyle for the model.

Specified by:
setRangeProperties in interface javax.swing.BoundedRangeModel
Parameters:
newValue - new model value
newExtent - new model extent
newMin - new model minimum
newMax - new model maximum
adjusting - true, if values are final. false otherwise

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the model's listener list.

Specified by:
addChangeListener in interface javax.swing.BoundedRangeModel
Parameters:
l - the ChangeListener to add

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the model's listener list.

Specified by:
removeChangeListener in interface javax.swing.BoundedRangeModel
Parameters:
l - the ChangeListener to remove

fireStateChanged

protected void fireStateChanged()
Notifies all model listeners that model state has changed.


rangeShifted

public void rangeShifted(AxisMapperRange range)
Invoked when axis mapper range was shifted. Triggers fireStateChanged method.

Specified by:
rangeShifted in interface AxisMapperRangeListener
Parameters:
range - range that has shifted

rangeChanged

public void rangeChanged(AxisMapperRange range)
Invoked when axis mapper range has changed. Triggers fireStateChanged method.

Specified by:
rangeChanged in interface AxisMapperRangeListener
Parameters:
range - range that has changed

rangeAdjusting

public void rangeAdjusting(AxisMapperRange range)
Invoked when the axis mapper range has entered or exited the adjusting mode. Triggers fireStateChanged method.

Specified by:
rangeAdjusting in interface AxisMapperRangeListener
Parameters:
range - mapper range, which has changed