org.xith3d.ui.hud.widgets
Class Scrollbar

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.BackgroundSettableWidget
          extended by org.xith3d.ui.hud.widgets.Scrollbar
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Positioned2fRO, org.openmali.types.twodee.Sized2f, org.openmali.types.twodee.Sized2fRO

public class Scrollbar
extends BackgroundSettableWidget

A simple Scrollbar implementation used to scroll content on the HUD.


Nested Class Summary
static class Scrollbar.Description
          This class is used to describe a (set of) Scrollbar Widget(s).
static class Scrollbar.Direction
          Scrolldirection of the Scrollbar
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
BackgroundSettableWidget.BackgroundSettableDescriptionBase
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
Scrollbar(float width, float height, Scrollbar.Description sbDesc)
          Creates a new Scrollbar.
Scrollbar(float width, float height, Scrollbar.Direction direction)
          Creates a new Scrollbar.
Scrollbar(float length, Scrollbar.Description sbDesc)
          Creates a new Scrollbar.
Scrollbar(float length, Scrollbar.Direction direction)
          Creates a new Scrollbar.
 
Method Summary
 void addScrollbarListener(ScrollbarListener l)
          Adds a ScrollbarListener to the List to be notified, when the value has changed.
protected  int drawHandle(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, Texture2D handleLTTex, Texture2D handleRBTex, Texture2D handleBodyTex, Texture2D handleDecoTex, int forcedHandlePos)
           
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
 Scrollbar.Direction getDirection()
           
 int getMaxValue()
           
 int getMinValue()
           
protected  int getMousePosition(int currentHandlePosPx, int mouseX, int mouseY)
          Checks, if the mouse is over the handle.
 int getPageSize()
          Gets the page size, which indirectly defines the size of the handle.
 int getSmallIncrement()
           
 boolean getSmoothScrolling()
           
 int getValue()
           
 int getWidthOrHeightInPixels()
          If this Scrollbar's Direction is Horizontal, the height in pixels is returned.
protected  void init()
          This method is called when the WidgetContainer is set.
protected  void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is pressed on a focused Widget.
protected  void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is released on a focused Widget.
protected  void onMouseMoved(float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
protected  void onScrollbarValueChanged(int oldValue, int newValue)
           
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
          
 boolean removeScrollbarListener(ScrollbarListener l)
          Removes a ScrollbarListener from the List.
 void setMaxValue(int maxValue)
          Sets the upper bound of scroll values.
 void setMinAndMax(int minValue, int maxValue)
          Sets the lower bound of scroll values.
 void setMinMaxAndValue(int minValue, int maxValue, int value)
          Sets the lower bound of scroll values.
 void setMinMaxAndValue(int minValue, int maxValue, int value, int pageSize)
          Sets the lower bound of scroll values.
 void setMinValue(int minValue)
          Sets the lower bound of scroll values.
 void setPageSize(int pageSize)
          Sets the page size, which indirectly defines the size of the handle.
 void setSmallIncrement(int value)
          Sets the step to increment the Scrollbar's value by when the increment button is clicked.
 void setSmoothScrolling(boolean b)
          If true, the handle doesn't snap to discrete positiones depending on the available scroll values.
 boolean setValue(int value)
          Sets the current scroll value
 
Methods inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
drawBackground, getBackgroundColor, getBackgroundTexture, getBackgroundTileMode, setBackground, setBackground, setBackground, setBackgroundColor, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTileMode, setNoBackground
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, blocksFocusMoveDeviceComponent, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBorder, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getMinHeight, getMinWidth, getName, getParentWindow, getPickHeight, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, initSize, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onAttachedToHUD, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onDetachedFromHUD, onFocusGained, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, onMouseEntered, onMouseExited, onMouseStopped, onMouseWheelMoved, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, toString, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scrollbar

public Scrollbar(float width,
                 float height,
                 Scrollbar.Description sbDesc)
Creates a new Scrollbar.

Parameters:
width - the width of the Scrollbar
height - the height of the Scrollbar
sbDesc - a Scrollbar.Description instance holding information about this new Scrollbar

Scrollbar

public Scrollbar(float length,
                 Scrollbar.Description sbDesc)
Creates a new Scrollbar.

Parameters:
length - the length of the Scrollbar
zIndex - the z-index of the Scrollbar
sbDesc - a Scrollbar.Description instance holding information about this new Scrollbar

Scrollbar

public Scrollbar(float width,
                 float height,
                 Scrollbar.Direction direction)
Creates a new Scrollbar.

Parameters:
width - the width of the Scrollbar
height - the height of the Scrollbar
direction - the scroll-direction

Scrollbar

public Scrollbar(float length,
                 Scrollbar.Direction direction)
Creates a new Scrollbar.

Parameters:
length - if (direction == HORIZONTAL), this is the width of the Scrollbar. if (direction == VERTICAL), this is the height of the Scrollbar.
direction - the scroll-direction
Method Detail

getDirection

public final Scrollbar.Direction getDirection()
Returns:
the direction in which the Scrollbar scrolls

getMousePosition

protected int getMousePosition(int currentHandlePosPx,
                               int mouseX,
                               int mouseY)
Checks, if the mouse is over the handle.

Parameters:
currentHandlePosPx -
mouseX - widget local mouse-x
mouseY - widget local mouse-y
Returns:
-1, if the mouse is on the smaller side of the handle, +1, if it is on the greater side, 0 if it is over the handle.

onMouseButtonPressed

protected void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button,
                                    float x,
                                    float y,
                                    long when,
                                    long lastWhen,
                                    boolean isTopMost,
                                    boolean hasFocus)
This event is fired, when a mouse button is pressed on a focused Widget.

Overrides:
onMouseButtonPressed in class Widget
Parameters:
button - the button that was pressed
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseButtonReleased

protected void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button,
                                     float x,
                                     float y,
                                     long when,
                                     long lastWhen,
                                     boolean isTopMost,
                                     boolean hasFocus)
This event is fired, when a mouse button is released on a focused Widget.

Overrides:
onMouseButtonReleased in class Widget
Parameters:
button - the button that was released
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseMoved

protected void onMouseMoved(float x,
                            float y,
                            int buttonsState,
                            long when,
                            boolean isTopMost,
                            boolean hasFocus)
This event is fired, when the mouse is moved on a Widget.

Overrides:
onMouseMoved in class Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

setMinValue

public void setMinValue(int minValue)
Sets the lower bound of scroll values.


getMinValue

public final int getMinValue()
Returns:
the lower bound of scroll values

setMaxValue

public void setMaxValue(int maxValue)
Sets the upper bound of scroll values.


getMaxValue

public final int getMaxValue()
Returns:
the upper bound of scroll values

setMinAndMax

public void setMinAndMax(int minValue,
                         int maxValue)
Sets the lower bound of scroll values.

Parameters:
minValue -
maxValue -

setPageSize

public void setPageSize(int pageSize)
Sets the page size, which indirectly defines the size of the handle.

Parameters:
pageSize -

getPageSize

public final int getPageSize()
Gets the page size, which indirectly defines the size of the handle.

Returns:
the page size.

setSmallIncrement

public void setSmallIncrement(int value)
Sets the step to increment the Scrollbar's value by when the increment button is clicked.


getSmallIncrement

public final int getSmallIncrement()
Returns:
the step to increment the Scrollbar's value by when the increment button is clicked

setMinMaxAndValue

public void setMinMaxAndValue(int minValue,
                              int maxValue,
                              int value,
                              int pageSize)
Sets the lower bound of scroll values.

Parameters:
minValue -
maxValue -
value -
pageSize -

setMinMaxAndValue

public final void setMinMaxAndValue(int minValue,
                                    int maxValue,
                                    int value)
Sets the lower bound of scroll values.

Parameters:
minValue -
maxValue -
value -

onScrollbarValueChanged

protected void onScrollbarValueChanged(int oldValue,
                                       int newValue)
Parameters:
oldValue -
newValue -

setValue

public boolean setValue(int value)
Sets the current scroll value

Parameters:
value -

getValue

public final int getValue()
Returns:
the current scroll value

addScrollbarListener

public void addScrollbarListener(ScrollbarListener l)
Adds a ScrollbarListener to the List to be notified, when the value has changed.

Parameters:
l - the new ScrollbarListener

removeScrollbarListener

public boolean removeScrollbarListener(ScrollbarListener l)
Removes a ScrollbarListener from the List.

Parameters:
l - the ScrollbarListener to be removed

setSmoothScrolling

public void setSmoothScrolling(boolean b)
If true, the handle doesn't snap to discrete positiones depending on the available scroll values.

Parameters:
b - enable/disable

getSmoothScrolling

public final boolean getSmoothScrolling()
Returns:
true, if the handle doesn't snap to discrete positiones depending on the available scroll values.

getWidthOrHeightInPixels

public final int getWidthOrHeightInPixels()
If this Scrollbar's Direction is Horizontal, the height in pixels is returned. If this Scrollbar's Direction is Vertical, the width in pixels is returned.

Returns:
the width or height in pixels.

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)

Overrides:
onSizeChanged in class Widget

drawHandle

protected int drawHandle(Texture2DCanvas texCanvas,
                         int offsetX,
                         int offsetY,
                         int width,
                         int height,
                         Texture2D handleLTTex,
                         Texture2D handleRBTex,
                         Texture2D handleBodyTex,
                         Texture2D handleDecoTex,
                         int forcedHandlePos)

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)
Specified by:
drawWidget in class Widget

init

protected void init()
This method is called when the WidgetContainer is set.

Specified by:
init in class Widget