org.wings
Class SPagingBoundedRangeModel

java.lang.Object
  extended by org.wings.SPagingBoundedRangeModel
All Implemented Interfaces:
BoundedRangeModel, SBoundedRangeModel, SDelayedEventModel

public class SPagingBoundedRangeModel
extends Object
implements SBoundedRangeModel

Paging implementation of SBoundedRangeModel

Author:
Armin Haaf

Field Summary
protected  ChangeEvent changeEvent
          Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.
protected  int extent
           
protected  boolean gotDelayedEvent
          got a delayed Event?
protected  boolean isAdjusting
           
protected  EventListenerList listenerList
          The listeners waiting for model changes.
protected  int max
           
protected  int min
           
protected  int value
           
 
Constructor Summary
SPagingBoundedRangeModel()
           
SPagingBoundedRangeModel(int value, int extent, int min, int max)
           
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener.
 void fireDelayedFinalEvents()
          fire remaining delayed events.
 void fireDelayedIntermediateEvents()
          fire event with isValueIsAdjusting true
protected  void fireStateChanged()
          Runs each ChangeListener's componentChanged method.
 ChangeListener[] getChangeListeners()
          Returns an array of all the change listeners registered on this DefaultBoundedRangeModel.
 boolean getDelayEvents()
           
 int getExtent()
          Returns the model's extent.
 EventListener[] getListeners(Class listenerType)
          Returns an array of all the objects currently registered as FooListeners upon this model.
 int getMaximum()
          Returns the model's maximum.
 int getMinimum()
          Returns the model's minimum.
 int getValue()
          Returns the model's current value.
 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 setDelayEvents(boolean b)
          if this is set to true, events are not fired immediately.
 void setExtent(int n)
          Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints:
 void setMaximum(int n)
          Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:
 void setMinimum(int n)
          Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints:
 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:
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".


listenerList

protected EventListenerList listenerList
The listeners waiting for model changes.


value

protected int value

extent

protected int extent

min

protected int min

max

protected int max

isAdjusting

protected boolean isAdjusting

gotDelayedEvent

protected boolean gotDelayedEvent
got a delayed Event?

Constructor Detail

SPagingBoundedRangeModel

public SPagingBoundedRangeModel()

SPagingBoundedRangeModel

public SPagingBoundedRangeModel(int value,
                                int extent,
                                int min,
                                int max)
Method Detail

getValue

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

Specified by:
getValue in interface BoundedRangeModel
Returns:
the model's current value
See Also:
setValue(int), BoundedRangeModel.getValue()

getExtent

public int getExtent()
Returns the model's extent.

Specified by:
getExtent in interface BoundedRangeModel
Returns:
the model's extent
See Also:
setExtent(int), BoundedRangeModel.getExtent()

getMinimum

public int getMinimum()
Returns the model's minimum.

Specified by:
getMinimum in interface BoundedRangeModel
Returns:
the model's minimum
See Also:
setMinimum(int), BoundedRangeModel.getMinimum()

getMaximum

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

Specified by:
getMaximum in interface BoundedRangeModel
Returns:
the model's maximum
See Also:
setMaximum(int), BoundedRangeModel.getMaximum()

setValue

public void setValue(int n)
Sets the current value of the model. For a slider, that determines where the knob appears. Ensures that the new value, n falls within the model's constraints:
     minimum <= value <= maximum
 

Specified by:
setValue in interface BoundedRangeModel
See Also:
BoundedRangeModel.setValue(int)

setExtent

public void setExtent(int n)
Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints:
     minimum <= value <= maximum
 

Specified by:
setExtent in interface BoundedRangeModel
See Also:
BoundedRangeModel.setExtent(int)

setMinimum

public void setMinimum(int n)
Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints:
     minimum <= value <= maximum
 

Specified by:
setMinimum in interface BoundedRangeModel
See Also:
getMinimum(), BoundedRangeModel.setMinimum(int)

setMaximum

public void setMaximum(int n)
Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:
     minimum <= value <= maximum
 

Specified by:
setMaximum in interface BoundedRangeModel
See Also:
BoundedRangeModel.setMaximum(int)

setValueIsAdjusting

public void setValueIsAdjusting(boolean b)
Sets the valueIsAdjusting property.

Specified by:
setValueIsAdjusting in interface BoundedRangeModel
See Also:
getValueIsAdjusting(), setValue(int), BoundedRangeModel.setValueIsAdjusting(boolean)

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns true if the value is in the process of changing as a result of actions being taken by the user.

Specified by:
getValueIsAdjusting in interface BoundedRangeModel
Returns:
the value of the valueIsAdjusting property
See Also:
setValue(int), BoundedRangeModel.getValueIsAdjusting()

setRangeProperties

public 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 <= maximum
 

At most, one ChangeEvent is generated.

Specified by:
setRangeProperties in interface BoundedRangeModel
See Also:
BoundedRangeModel.setRangeProperties(int, int, int, int, boolean), setValue(int), setExtent(int), setMinimum(int), setMaximum(int), setValueIsAdjusting(boolean)

getDelayEvents

public boolean getDelayEvents()
Specified by:
getDelayEvents in interface SDelayedEventModel

setDelayEvents

public void setDelayEvents(boolean b)
Description copied from interface: SDelayedEventModel
if this is set to true, events are not fired immediately. They are collected and fired after setting this to false...

Specified by:
setDelayEvents in interface SDelayedEventModel

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener. The change listeners are run each time any one of the Bounded Range model properties changes.

Specified by:
addChangeListener in interface BoundedRangeModel
Parameters:
l - the ChangeListener to add
See Also:
removeChangeListener(javax.swing.event.ChangeListener), BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener.

Specified by:
removeChangeListener in interface BoundedRangeModel
Parameters:
l - the ChangeListener to remove
See Also:
addChangeListener(javax.swing.event.ChangeListener), BoundedRangeModel.removeChangeListener(javax.swing.event.ChangeListener)

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on this DefaultBoundedRangeModel.

Returns:
all of this model's ChangeListeners or an empty array if no change listeners are currently registered
Since:
1.4
See Also:
addChangeListener(javax.swing.event.ChangeListener), removeChangeListener(javax.swing.event.ChangeListener)

fireStateChanged

protected void fireStateChanged()
Runs each ChangeListener's componentChanged method.

See Also:
setRangeProperties(int, int, int, int, boolean), EventListenerList

toString

public String toString()
Returns a string that displays all of the BoundedRangeModel properties.

Overrides:
toString in class Object

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners upon this model. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultBoundedRangeModel instance m for its change listeners with the following code:

ChangeListener[] cls = (ChangeListener[])(m.getListeners(ChangeListener.class));

If no such listeners exist, this method returns an empty array.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added
Throws:
ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since:
1.3
See Also:
getChangeListeners()

fireDelayedIntermediateEvents

public void fireDelayedIntermediateEvents()
fire event with isValueIsAdjusting true

Specified by:
fireDelayedIntermediateEvents in interface SDelayedEventModel

fireDelayedFinalEvents

public void fireDelayedFinalEvents()
Description copied from interface: SDelayedEventModel
fire remaining delayed events. In this level all events, which are important to an application should be fired. All listeners, which are notified in this level can assume that the components are in a consistent (considering user interaction) state.

Specified by:
fireDelayedFinalEvents in interface SDelayedEventModel


wingS Swings ;-)