com.threerings.opengl.gui
Class BoundedRangeModel

java.lang.Object
  extended by com.threerings.opengl.gui.BoundedRangeModel
Direct Known Subclasses:
BoundedSnappingRangeModel

public class BoundedRangeModel
extends Object

Defines the model used by the ScrollBar to communicate with other components and external entities that wish to be manipulated by a scroll bar.

A bounded range model has a minimum and maximum value, a current value and an extent. These are easily visualized by showing how they control a scroll bar:

 +-------------------------------------------------------------------+
 |        +---------------------------------------+                  |
 |        |                                       |                  |
 |        +---------------------------------------+                  |
 +-------------------------------------------------------------------+
 min      value                        value+extent                max
 


Constructor Summary
BoundedRangeModel(int min, int value, int extent, int max)
          Creates a bounded range model with the specified minimum value, current value, extent and maximum value.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a listener to this model.
 MouseWheelListener createWheelListener()
          Creates a mouse wheel listener that will respond to wheel events by adjusting this model up or down accordingly.
 int getExtent()
          Returns the current extent of the model.
 int getMaximum()
          Returns the maximum value this model will allow for value + extent.
 int getMinimum()
          Returns the minimum value this model will allow for its value.
 int getRange()
          Returns the range of this model (the maximum minus the minimum).
 float getRatio()
          Returns the value of the model mapped into the range [0-1]: (value - minumum) / range.
 int getScrollIncrement()
          Returns the increment by which this model should be scrolled when the user presses one of the buttons at the end of the scrollbar.
 int getValue()
          Returns the current value of the model.
 void removeChangeListener(ChangeListener listener)
          Removes the specified listener from the model.
 void setExtent(int extent)
          Configures the extent of this model.
 void setMaximum(int maximum)
          Configures the maximum value of this model, adjusting the value, extent and minimum as necessary to maintain the consistency of the model.
 void setMinimum(int minimum)
          Configures the minimum value of this model, adjusting the value, extent and maximum as necessary to maintain the consistency of the model.
 boolean setRange(int min, int value, int extent, int max)
          Configures this model with a new minimum, maximum, current value and extent.
 void setValue(int value)
          Configures the value of this model.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundedRangeModel

public BoundedRangeModel(int min,
                         int value,
                         int extent,
                         int max)
Creates a bounded range model with the specified minimum value, current value, extent and maximum value.

Method Detail

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener to this model.


removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes the specified listener from the model.


getMinimum

public int getMinimum()
Returns the minimum value this model will allow for its value.


getMaximum

public int getMaximum()
Returns the maximum value this model will allow for value + extent.


getRange

public int getRange()
Returns the range of this model (the maximum minus the minimum).


getValue

public int getValue()
Returns the current value of the model.


getExtent

public int getExtent()
Returns the current extent of the model.


getRatio

public float getRatio()
Returns the value of the model mapped into the range [0-1]: (value - minumum) / range.


getScrollIncrement

public int getScrollIncrement()
Returns the increment by which this model should be scrolled when the user presses one of the buttons at the end of the scrollbar.


setMinimum

public void setMinimum(int minimum)
Configures the minimum value of this model, adjusting the value, extent and maximum as necessary to maintain the consistency of the model.


setMaximum

public void setMaximum(int maximum)
Configures the maximum value of this model, adjusting the value, extent and minimum as necessary to maintain the consistency of the model.


setValue

public void setValue(int value)
Configures the value of this model. The new value will be adjusted if it does not fall within the range of min <= value <= max - extent.


setExtent

public void setExtent(int extent)
Configures the extent of this model. The new value will be adjusted if it does not fall within the range of 0 <= extent <= max - value.


setRange

public boolean setRange(int min,
                        int value,
                        int extent,
                        int max)
Configures this model with a new minimum, maximum, current value and extent.

Returns:
true if the range was modified, false if the values were already set to the requested values.

createWheelListener

public MouseWheelListener createWheelListener()
Creates a mouse wheel listener that will respond to wheel events by adjusting this model up or down accordingly.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.