org.xith3d.ui.hud.utils
Class ScrollHandler

java.lang.Object
  extended by org.xith3d.ui.hud.utils.ScrollHandler
All Implemented Interfaces:
ScrollbarListener, WidgetContainerListener, WidgetLocationListener, WidgetMouseListener, WidgetSizeListener

public abstract class ScrollHandler
extends java.lang.Object
implements ScrollbarListener, WidgetContainerListener, WidgetLocationListener, WidgetSizeListener, WidgetMouseListener

A ScrollHandler is capable of managing communication between a scrollable Widget and the ScrollBars as well as properly adding the ScrollBars to the Widget on demand.


Constructor Summary
ScrollHandler(Widget widget, WidgetAssembler widgetAssembler, boolean scrollHorizontal, boolean scrollVertical)
           
 
Method Summary
protected  Scrollbar createHorizontalScrollbar(float width)
          Creates the horizontal Scrollbar.
protected  Scrollbar createVerticalScrollbar(float height)
          Creates the vertical Scrollbar.
 int getLineHeight()
           
 ScrollMode getScrollMode()
           
 void onInputStateChanged(Widget widget, org.jagatoo.input.devices.components.DeviceComponent comp, int delta, int state, long when, boolean isTopMost, boolean hasFocus)
          This event is fired when the state of any DeviceComponent has changed.
 void onMouseButtonPressed(Widget widget, 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.
 void onMouseButtonReleased(Widget widget, 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.
 void onMouseEntered(Widget widget, boolean isTopMost, boolean hasFocus)
          This method is called when the mouse entered the Widget area.
 void onMouseExited(Widget widget, boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
 void onMouseMoved(Widget widget, float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
 void onMouseStopped(Widget widget, float x, float y, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse position has not been changed on this Widget for a certain amount of time.
 void onMouseWheelMoved(Widget widget, int delta, boolean isPageMove, float x, float y, long when, boolean isTopMost)
          This event is fired, when the mouse wheel is moved on a Widget.
 void onScrollbarValueChanged(Scrollbar scrollbar, int newValue)
          This event is fired when the value of a Scrollbar has changed.
abstract  void onScrolled(Scrollbar.Direction direction, int newValue)
           
 void onWidgetAttachedToContainer(Widget widget, WidgetContainer container)
          This event is fired, when a Widget is added to a WidgetContainer.
 void onWidgetAttachedToHUD(Widget widget, HUD hud)
          This event is fired, when a Widget is added to a WidgetContainer and the container itself is already added to the HUD or is the HUD itself.
 void onWidgetDetachedFromContainer(Widget widget, WidgetContainer container)
          This event is fired, when a Widget is removed from a WidgetContainer.
 void onWidgetDetachedFromHUD(Widget widget, HUD hud)
          This event is fired, when a Widget is removed from a HUD.
 void onWidgetDragStarted(Widget widget)
          This event is fired when a Widget is started to be dragged.
 void onWidgetDragStopped(Widget widget)
          This event is fired when a Widget is stopped to be dragged.
 void onWidgetLocationChanged(Widget widget, float oldLeft, float oldTop, float newLeft, float newTop)
          This event is fired when a Widget's location has changed.
 void onWidgetSizeChanged(Widget widget, float oldWidth, float oldHeight, float newWidth, float newHeight)
          This event is fired when a Widget's size has changed.
 void setBounds(float maxRight, float maxBottom)
           
 void setLineHeight(int lineHeight)
           
 void setScrollHValue(int value)
           
 void setScrollMode(ScrollMode mode)
           
 void setScrollVValue(int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScrollHandler

public ScrollHandler(Widget widget,
                     WidgetAssembler widgetAssembler,
                     boolean scrollHorizontal,
                     boolean scrollVertical)
Method Detail

onScrolled

public abstract void onScrolled(Scrollbar.Direction direction,
                                int newValue)

onScrollbarValueChanged

public void onScrollbarValueChanged(Scrollbar scrollbar,
                                    int newValue)
This event is fired when the value of a Scrollbar has changed.

Specified by:
onScrollbarValueChanged in interface ScrollbarListener
Parameters:
scrollbar - the Scrollbar, which's value has changed
newValue - the new (current) value of the Scrollbar

setScrollMode

public void setScrollMode(ScrollMode mode)

getScrollMode

public final ScrollMode getScrollMode()

setLineHeight

public void setLineHeight(int lineHeight)

getLineHeight

public final int getLineHeight()

setScrollHValue

public void setScrollHValue(int value)

setScrollVValue

public void setScrollVValue(int value)

setBounds

public void setBounds(float maxRight,
                      float maxBottom)

onWidgetAttachedToContainer

public void onWidgetAttachedToContainer(Widget widget,
                                        WidgetContainer container)
This event is fired, when a Widget is added to a WidgetContainer.

Specified by:
onWidgetAttachedToContainer in interface WidgetContainerListener
Parameters:
widget - the Widget, which is added to a WidgetContainer
container - the WidgetContainer, the Widget is added to

onWidgetDetachedFromContainer

public void onWidgetDetachedFromContainer(Widget widget,
                                          WidgetContainer container)
This event is fired, when a Widget is removed from a WidgetContainer.

Specified by:
onWidgetDetachedFromContainer in interface WidgetContainerListener
Parameters:
widget - the Widget, which is removed from a WidgetContainer
container - the WidgetContainer, the Widget is removed from

onWidgetAttachedToHUD

public void onWidgetAttachedToHUD(Widget widget,
                                  HUD hud)
This event is fired, when a Widget is added to a WidgetContainer and the container itself is already added to the HUD or is the HUD itself.

Specified by:
onWidgetAttachedToHUD in interface WidgetContainerListener
Parameters:
widget - the Widget, which is added to a WidgetContainer
hud - the HUD, the Widget is added to

onWidgetDetachedFromHUD

public void onWidgetDetachedFromHUD(Widget widget,
                                    HUD hud)
This event is fired, when a Widget is removed from a HUD.

Specified by:
onWidgetDetachedFromHUD in interface WidgetContainerListener
Parameters:
widget - the Widget, which is removed from a HUD
hud - the HUD, the Widget is removed from

onWidgetDragStarted

public void onWidgetDragStarted(Widget widget)
This event is fired when a Widget is started to be dragged.

Specified by:
onWidgetDragStarted in interface WidgetLocationListener
Parameters:
widget - the Widget, which is dragged

onWidgetDragStopped

public void onWidgetDragStopped(Widget widget)
This event is fired when a Widget is stopped to be dragged.

Specified by:
onWidgetDragStopped in interface WidgetLocationListener
Parameters:
widget - the Widget, which was dragged

onWidgetLocationChanged

public void onWidgetLocationChanged(Widget widget,
                                    float oldLeft,
                                    float oldTop,
                                    float newLeft,
                                    float newTop)
This event is fired when a Widget's location has changed.

Specified by:
onWidgetLocationChanged in interface WidgetLocationListener
Parameters:
widget - the Widget, which's location has changed
oldLeft - the old left coordinate of the Widget
oldTop - the old top coordinate of the Widget
newLeft - the new left coordinate of the Widget
newTop - the new top coordinate of the Widget

onWidgetSizeChanged

public void onWidgetSizeChanged(Widget widget,
                                float oldWidth,
                                float oldHeight,
                                float newWidth,
                                float newHeight)
This event is fired when a Widget's size has changed.

Specified by:
onWidgetSizeChanged in interface WidgetSizeListener
Parameters:
widget - the Widget, which's size has changed
oldWidth - the new width of the Widget
oldHeight - the new height of the Widget
newWidth - the new width of the Widget
newHeight - the new height of the Widget

onMouseButtonPressed

public void onMouseButtonPressed(Widget widget,
                                 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.

Specified by:
onMouseButtonPressed in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
button - the button that was pressed
x - the current mouse x position
y - the current mouse y position
when - the gameTime of the mouse event
lastWhen - the milli-time when the button has last been pressed
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseButtonReleased

public void onMouseButtonReleased(Widget widget,
                                  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.

Specified by:
onMouseButtonReleased in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
button - the button that was released
x - the current mouse x position
y - the current mouse y position
when - the gameTime of the mouse event
lastWhen - the milli-time when the button has last been released
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseMoved

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

Specified by:
onMouseMoved in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
x - the new X coordinate
y - the new Y coordinate
buttonsState - the buttons' state bitmask
when - the gameTime of the mouse event
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseStopped

public void onMouseStopped(Widget widget,
                           float x,
                           float y,
                           long when,
                           boolean isTopMost,
                           boolean hasFocus)
This event is fired, when the mouse position has not been changed on this Widget for a certain amount of time.

Specified by:
onMouseStopped in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
x - the new X coordinate
y - the new Y coordinate
when - the gameTime of the mouse event
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseWheelMoved

public void onMouseWheelMoved(Widget widget,
                              int delta,
                              boolean isPageMove,
                              float x,
                              float y,
                              long when,
                              boolean isTopMost)
This event is fired, when the mouse wheel is moved on a Widget.

Specified by:
onMouseWheelMoved in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
delta - a positive value when the wheel was moved up
isPageMove - true, if whole pages are to be scrolled with this wheel move
x - the current mouse x position
y - the current mouse y position
when - the gameTime of the mouse event
isTopMost - is this Widget topMost

onMouseEntered

public void onMouseEntered(Widget widget,
                           boolean isTopMost,
                           boolean hasFocus)
This method is called when the mouse entered the Widget area.

Specified by:
onMouseEntered in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseExited

public void onMouseExited(Widget widget,
                          boolean isTopMost,
                          boolean hasFocus)
This method is called when the mouse exited the Widget area.

Specified by:
onMouseExited in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onInputStateChanged

public void onInputStateChanged(Widget widget,
                                org.jagatoo.input.devices.components.DeviceComponent comp,
                                int delta,
                                int state,
                                long when,
                                boolean isTopMost,
                                boolean hasFocus)
This event is fired when the state of any DeviceComponent has changed.

Specified by:
onInputStateChanged in interface WidgetMouseListener
Parameters:
widget - the Widget for which this event was fired
when - the gameTime of the event

createHorizontalScrollbar

protected Scrollbar createHorizontalScrollbar(float width)
Creates the horizontal Scrollbar.

Parameters:
width - the width to cover
Returns:
the horizontal Scrollbar.

createVerticalScrollbar

protected Scrollbar createVerticalScrollbar(float height)
Creates the vertical Scrollbar.

Parameters:
height - the height to cover
Returns:
the vertical Scrollbar.