org.wings
Class SAbstractAdjustable

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.SAbstractAdjustable
All Implemented Interfaces:
Adjustable, Serializable, Cloneable, LowLevelEventListener, Renderable
Direct Known Subclasses:
SPageScroller, SScrollBar

public abstract class SAbstractAdjustable
extends SComponent
implements Adjustable, LowLevelEventListener

Base class for adjustable elements like SScrollBar and SPageScroller

Author:
Armin Haaf
See Also:
Serialized Form

Field Summary
static int BLOCK
           
protected  int blockIncrement
           
protected  boolean changeFromEvent
           
static int MARGIN
           
protected  SBoundedRangeModel model
          The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value.
protected  int orientation
           
static int UNIT
           
protected  int unitIncrement
           
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Fields inherited from interface java.awt.Adjustable
HORIZONTAL, NO_ORIENTATION, VERTICAL
 
Constructor Summary
SAbstractAdjustable()
          Creates a scrollbar with the specified orientation and the following initial values:
SAbstractAdjustable(int value, int extent, int min, int max)
          Creates a scrollbar with the specified orientation, value, extent, mimimum, and maximum.
SAbstractAdjustable(SBoundedRangeModel model)
           
 
Method Summary
 void addAdjustmentListener(AdjustmentListener l)
          Adds an AdjustmentListener.
protected abstract  void adjust()
           
protected  void fireAdjustmentValueChanged(int id, int type, int value)
           
 void fireFinalEvents()
          Internal event trigger used by CGs.
 void fireIntermediateEvents()
          fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...
 int getBlockIncrement()
          For backwards compatibility with java.awt.Scrollbar.
 int getBlockIncrement(int direction)
          Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request.
 int getExtent()
           
 int getMaximum()
          The maximum value of the scrollbar is maximum - extent.
 int getMinimum()
          Returns the minimum value supported by the scrollbar (usually zero).
 SBoundedRangeModel getModel()
          Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
 int getOrientation()
          Returns the adjustable's orientation (horizontal or vertical).
 int getUnitIncrement()
          For backwards compatibility with java.awt.Scrollbar.
 int getUnitIncrement(int direction)
          Returns the amount to change the scrollbar's value by, given a unit up/down request.
 int getValue()
          Returns the scrollbar's value.
 boolean getValueIsAdjusting()
          True if the scrollbar knob is being dragged.
 int getVisibleAmount()
          Returns the scrollbar's extent, aka its "visibleAmount".
 boolean isChangeFromEvent()
           
 boolean isEpochCheckEnabled()
          Asks the low-level event listener if epoch checking should be perfomed on it.
 void processLowLevelEvent(String action, String[] values)
          Deliver low level/http events (parameters).
 void removeAdjustmentListener(AdjustmentListener l)
          Removes an AdjustmentEvent listener.
 void setBlockIncrement(int blockIncrement)
          Sets the blockIncrement property.
 void setEpochCheckEnabled(boolean epochCheckEnabled)
           
 void setExtent(int value)
           
 void setMaximum(int maximum)
          Sets the model's maximum property.
 void setMinimum(int minimum)
          Sets the scrollbar's minimum value..
 void setModel(SBoundedRangeModel newModel)
          Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
 void setOrientation(int orientation)
          Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.
 void setUnitIncrement(int unitIncrement)
          Sets the unitIncrement property.
 void setValue(int value)
          Sets the scrollbar's value.
 void setValueIsAdjusting(boolean b)
          Sets the model's valueIsAdjusting property.
 void setValues(int newValue, int newExtent, int newMin, int newMax)
          Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints:
 void setVisibleAmount(int extent)
          Set the model's extent property: The amount of the view that is currently visible.
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addNotify, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, clone, fireComponentChangeEvent, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getResidesInForm, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, invite, isDifferent, isEnabled, isFocusOwner, isRecursivelyVisible, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeNotify, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setEnabled, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setParent, setParentFrame, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, updateCG, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.wings.LowLevelEventListener
getLowLevelEventId, getName, isEnabled
 

Field Detail

UNIT

public static final int UNIT
See Also:
Constant Field Values

BLOCK

public static final int BLOCK
See Also:
Constant Field Values

MARGIN

public static final int MARGIN
See Also:
Constant Field Values

changeFromEvent

protected boolean changeFromEvent

model

protected SBoundedRangeModel model
The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value.

See Also:
setModel(org.wings.SBoundedRangeModel)

unitIncrement

protected int unitIncrement
See Also:
setUnitIncrement(int)

blockIncrement

protected int blockIncrement
See Also:
setBlockIncrement(int)

orientation

protected int orientation
See Also:
setBlockIncrement(int)
Constructor Detail

SAbstractAdjustable

public SAbstractAdjustable(int value,
                           int extent,
                           int min,
                           int max)
Creates a scrollbar with the specified orientation, value, extent, mimimum, and maximum. The "extent" is the size of the viewable area. It is also known as the "visible amount".

Note: Use setBlockIncrement to set the block increment to a size slightly smaller than the view's extent. That way, when the user jumps the knob to an adjacent position, one or two lines of the original contents remain in view.

Throws:
IllegalArgumentException - if orientation is not one of VERTICAL, HORIZONTAL
See Also:
setOrientation(int), setValue(int), setVisibleAmount(int), setMinimum(int), setMaximum(int)

SAbstractAdjustable

public SAbstractAdjustable(SBoundedRangeModel model)

SAbstractAdjustable

public SAbstractAdjustable()
Creates a scrollbar with the specified orientation and the following initial values:
 minimum = 0
 maximum = 100
 value = 0
 extent = 10
 

Method Detail

getModel

public final SBoundedRangeModel getModel()
Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

See Also:
setModel(org.wings.SBoundedRangeModel)

setModel

public void setModel(SBoundedRangeModel newModel)
Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

See Also:
getModel()

getUnitIncrement

public int getUnitIncrement(int direction)
Returns the amount to change the scrollbar's value by, given a unit up/down request. A ScrollBarUI implementation typically calls this method when the user clicks on a scrollbar up/down arrow and uses the result to update the scrollbar's value. Subclasses my override this method to compute a value, e.g. the change required to scroll up or down one (variable height) line text or one row in a table.

The JScrollPane component creates scrollbars (by default) that override this method and delegate to the viewports Scrollable view, if it has one. The Scrollable interface provides a more specialized version of this method.

Parameters:
direction - is -1 or 1 for up/down respectively
Returns:
the value of the unitIncrement property
See Also:
setUnitIncrement(int), setValue(int)

setUnitIncrement

public void setUnitIncrement(int unitIncrement)
Sets the unitIncrement property.

Specified by:
setUnitIncrement in interface Adjustable
See Also:
getUnitIncrement(int)

getBlockIncrement

public int getBlockIncrement(int direction)
Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request. A ScrollBarUI implementation typically calls this method when the user clicks above or below the scrollbar "knob" to change the value up or down by large amount. Subclasses my override this method to compute a value, e.g. the change required to scroll up or down one paragraph in a text document.

The JScrollPane component creates scrollbars (by default) that override this method and delegate to the viewports Scrollable view, if it has one. The Scrollable interface provides a more specialized version of this method.

Parameters:
direction - is -1 or 1 for up/down respectively
Returns:
the value of the blockIncrement property
See Also:
setBlockIncrement(int), setValue(int)

setBlockIncrement

public void setBlockIncrement(int blockIncrement)
Sets the blockIncrement property. The scrollbar's block increment.

Specified by:
setBlockIncrement in interface Adjustable
See Also:
getBlockIncrement()

getUnitIncrement

public final int getUnitIncrement()
For backwards compatibility with java.awt.Scrollbar.

Specified by:
getUnitIncrement in interface Adjustable
See Also:
Adjustable.getUnitIncrement(), getUnitIncrement(int)

getBlockIncrement

public final int getBlockIncrement()
For backwards compatibility with java.awt.Scrollbar.

Specified by:
getBlockIncrement in interface Adjustable
See Also:
Adjustable.getBlockIncrement(), getBlockIncrement(int)

getValue

public final int getValue()
Returns the scrollbar's value.

Specified by:
getValue in interface Adjustable
Returns:
the model's value property
See Also:
setValue(int)

setValue

public void setValue(int value)
Sets the scrollbar's value. This method just forwards the value to the model.

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

getExtent

public final int getExtent()

setExtent

public void setExtent(int value)

getVisibleAmount

public final int getVisibleAmount()
Returns the scrollbar's extent, aka its "visibleAmount". In many scrollbar look and feel implementations the size of the scrollbar "knob" or "thumb" is proportional to the extent.

Specified by:
getVisibleAmount in interface Adjustable
Returns:
the value of the model's extent property
See Also:
setVisibleAmount(int)

setVisibleAmount

public void setVisibleAmount(int extent)
Set the model's extent property: The amount of the view that is currently visible.

Specified by:
setVisibleAmount in interface Adjustable
See Also:
getVisibleAmount(), BoundedRangeModel.setExtent(int)

getMinimum

public final int getMinimum()
Returns the minimum value supported by the scrollbar (usually zero).

Specified by:
getMinimum in interface Adjustable
Returns:
the value of the model's minimum property
See Also:
setMinimum(int)

setMinimum

public void setMinimum(int minimum)
Sets the scrollbar's minimum value..

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

getMaximum

public final int getMaximum()
The maximum value of the scrollbar is maximum - extent.

Specified by:
getMaximum in interface Adjustable
Returns:
the value of the model's maximum property
See Also:
setMaximum(int)

setMaximum

public void setMaximum(int maximum)
Sets the model's maximum property. Note that the scrollbar's value can only be set to maximum - extent. The scrollbar's maximum value.

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

getOrientation

public final int getOrientation()
Returns the adjustable's orientation (horizontal or vertical).

Specified by:
getOrientation in interface Adjustable
Returns:
VERTICAL or HORIZONTAL
See Also:
setOrientation(int), Adjustable.getOrientation()

setOrientation

public void setOrientation(int orientation)
Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.

Throws:
IllegalArgumentException - if orientation is not one of VERTICAL, HORIZONTAL
See Also:
getOrientation()

getValueIsAdjusting

public final boolean getValueIsAdjusting()
True if the scrollbar knob is being dragged.

Returns:
the value of the model's valueIsAdjusting property
See Also:
setValueIsAdjusting(boolean)

setValueIsAdjusting

public void setValueIsAdjusting(boolean b)
Sets the model's valueIsAdjusting property. Scrollbar look and feel implementations should set this property to true when a knob drag begins, and to false when the drag ends. The scrollbar model will not generate ChangeEvents while valueIsAdjusting is true. True if the scrollbar thumb is being dragged.

See Also:
getValueIsAdjusting(), BoundedRangeModel.setValueIsAdjusting(boolean)

setValues

public void setValues(int newValue,
                      int newExtent,
                      int newMin,
                      int newMax)
Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints:
 minimum <= value <= value+extent <= maximum
 

See Also:
BoundedRangeModel.setRangeProperties(int, int, int, int, boolean), setValue(int), setVisibleAmount(int), setMinimum(int), setMaximum(int)

processLowLevelEvent

public void processLowLevelEvent(String action,
                                 String[] values)
Description copied from interface: LowLevelEventListener
Deliver low level/http events (parameters). The name-value-pairs of the HTTPRequest are considered low level events.

Specified by:
processLowLevelEvent in interface LowLevelEventListener
Overrides:
processLowLevelEvent in class SComponent
Parameters:
action - the name-value-pair's name
values - the name-value-pair's values

fireIntermediateEvents

public void fireIntermediateEvents()
Description copied from interface: LowLevelEventListener
fire events which describes a "in progress" state change, like TreeWillExpand, or ListSelectionEvent with getIsAdjusting() true, ...

Specified by:
fireIntermediateEvents in interface LowLevelEventListener

fireFinalEvents

public void fireFinalEvents()
Description copied from class: SComponent
Internal event trigger used by CGs. This Method is called internal and should not be called directly

Specified by:
fireFinalEvents in interface LowLevelEventListener
Overrides:
fireFinalEvents in class SComponent

isChangeFromEvent

public boolean isChangeFromEvent()

addAdjustmentListener

public void addAdjustmentListener(AdjustmentListener l)
Adds an AdjustmentListener. Adjustment listeners are notified each time the scrollbar's model changes. Adjustment events are provided for backwards compatability with java.awt.Scrollbar.

Note that the AdjustmentEvents type property will always have a placeholder value of AdjustmentEvent.TRACK because all changes to a BoundedRangeModels value are considered equivalent. To change the value of a BoundedRangeModel one just sets its value property, i.e. model.setValue(123). No information about the origin of the change, e.g. it's a block decrement, is provided. We don't try fabricate the origin of the change here.

Specified by:
addAdjustmentListener in interface Adjustable
Parameters:
l - the AdjustmentLister to add
See Also:
removeAdjustmentListener(java.awt.event.AdjustmentListener), BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)

removeAdjustmentListener

public void removeAdjustmentListener(AdjustmentListener l)
Removes an AdjustmentEvent listener.

Specified by:
removeAdjustmentListener in interface Adjustable
Parameters:
l - the AdjustmentLister to remove
See Also:
addAdjustmentListener(java.awt.event.AdjustmentListener)

fireAdjustmentValueChanged

protected void fireAdjustmentValueChanged(int id,
                                          int type,
                                          int value)

adjust

protected abstract void adjust()

isEpochCheckEnabled

public boolean isEpochCheckEnabled()
Description copied from interface: LowLevelEventListener
Asks the low-level event listener if epoch checking should be perfomed on it. If true the Dispatcher will ignore request originating from old views (typically iniated by triggering browser back and clicking somewhere.)

Specified by:
isEpochCheckEnabled in interface LowLevelEventListener
Returns:
true if epoch checking should be perfomed, false if all request for this component should be processed.
See Also:
LowLevelEventListener.isEpochCheckEnabled()

setEpochCheckEnabled

public void setEpochCheckEnabled(boolean epochCheckEnabled)
See Also:
LowLevelEventListener.isEpochCheckEnabled()


wingS Swings ;-)