org.xith3d.ui.hud.utils
Class WidgetZIndexGroup

java.lang.Object
  extended by org.xith3d.ui.hud.utils.WidgetZIndexGroup
All Implemented Interfaces:
WidgetInputListener

public class WidgetZIndexGroup
extends java.lang.Object
implements WidgetInputListener

This class can be used to logically group some Widgets by their z-index. When one Widget is clicked, it's z-index will be set to the maximum z-index of the group and the ones lying over it are being set a lower z-index.


Constructor Summary
WidgetZIndexGroup()
          Creates a new WidgetZIndexGroup.
WidgetZIndexGroup(int quantum)
          Creates a new WidgetZIndexGroup.
 
Method Summary
 void add(Widget widget)
          Adds a Widget to this logic group.
 int getMaxZIndex()
           
 int getQuantum()
           
 void onControllerAxisChanged(Widget widget, org.jagatoo.input.devices.components.ControllerAxis axis, int axisDelta)
          This event is fired when a ControllerAxis has changed and this Widget is the currently focussed one.
 void onControllerButtonPressed(Widget widget, org.jagatoo.input.devices.components.ControllerButton button)
          This event is fired when a ControllerButton has been pressed and this Widget is the currently focussed one.
 void onControllerButtonReleased(Widget widget, org.jagatoo.input.devices.components.ControllerButton button)
          This event is fired when a ControllerButton has been released and this Widget is the currently focussed one.
 void onInputStateChanged(Widget widget, org.jagatoo.input.devices.components.DeviceComponent comp, int delta, int state, boolean isTopMost, boolean hasFocus)
          This event is fired when the state of any DeviceComponent has changed.
 void onKeyPressed(Widget widget, org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is pressed on a focused Widget.
 void onKeyReleased(Widget widget, org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is released on a focused Widget.
 void onKeyTyped(Widget widget, char ch, long when)
          This event is fired when a key is typed on the keyboard.
 void onMouseButtonPressed(Widget widget, org.jagatoo.input.devices.components.MouseButton button, int x, int 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, int x, int 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 onMouseLeft(Widget widget, boolean isTopMost, boolean hasFocus)
          This method is called when the mouse left the Widget area
 void onMouseMoved(Widget widget, int x, int 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, int x, int 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 onMouseUnbound(Widget widget)
          This event is fired, when the mouse is released.
 void onMouseWheelMoved(Widget widget, int delta, boolean isPageMove, int x, int y, long when, boolean isTopMost)
          This event is fired, when the mouse wheel is moved on a Widget.
 boolean remove(Widget widget)
          Removes a Widget from this logic group.
 void setMaxZIndex(int mzi)
          Sets the maximum z-index, which will be set to the last clicked Widget in the group.
 void setQuantum(int quantum)
          Sets the step the zIndices are altered with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WidgetZIndexGroup

public WidgetZIndexGroup(int quantum)
Creates a new WidgetZIndexGroup.

Parameters:
quantum - the step the zIndices are altered with (default: 1)

WidgetZIndexGroup

public WidgetZIndexGroup()
Creates a new WidgetZIndexGroup.

Method Detail

setMaxZIndex

public void setMaxZIndex(int mzi)
Sets the maximum z-index, which will be set to the last clicked Widget in the group. Call this method, when you change the z-index of a Widget after adding it to this group.

Parameters:
mzi - the new maximum z-index

getMaxZIndex

public int getMaxZIndex()
Returns:
the maximum z-index, which will be set to the last clicked Widget in the group.

setQuantum

public void setQuantum(int quantum)
Sets the step the zIndices are altered with.


getQuantum

public int getQuantum()
Returns:
the step the zIndices are altered with.

onKeyPressed

public void onKeyPressed(Widget widget,
                         org.jagatoo.input.devices.components.Key key,
                         long when)
This event is fired, when a key is pressed on a focused Widget.

Specified by:
onKeyPressed in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
key - the key that was pressed
when - the gameTime of the key event

onKeyReleased

public void onKeyReleased(Widget widget,
                          org.jagatoo.input.devices.components.Key key,
                          long when)
This event is fired, when a key is released on a focused Widget.

Specified by:
onKeyReleased in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
key - the key that was released
when - the gameTime of the key event

onKeyTyped

public void onKeyTyped(Widget widget,
                       char ch,
                       long when)
This event is fired when a key is typed on the keyboard.

Specified by:
onKeyTyped in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
ch - the typed key's character
when - the gameTime of the key event

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 WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseLeft

public void onMouseLeft(Widget widget,
                        boolean isTopMost,
                        boolean hasFocus)
This method is called when the mouse left the Widget area

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

onMouseMoved

public void onMouseMoved(Widget widget,
                         int x,
                         int 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 WidgetInputListener
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,
                           int x,
                           int 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 WidgetInputListener
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

onMouseUnbound

public void onMouseUnbound(Widget widget)
This event is fired, when the mouse is released. onMouseMoved will not be called on the Widget anymore, when the mouse is not over it.

Specified by:
onMouseUnbound in interface WidgetInputListener
Parameters:
widget - the Widget, which was unbound from the mouse

onMouseWheelMoved

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

Specified by:
onMouseWheelMoved in interface WidgetInputListener
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

onMouseButtonPressed

public void onMouseButtonPressed(Widget widget,
                                 org.jagatoo.input.devices.components.MouseButton button,
                                 int x,
                                 int 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 WidgetInputListener
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,
                                  int x,
                                  int 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 WidgetInputListener
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

onControllerButtonPressed

public void onControllerButtonPressed(Widget widget,
                                      org.jagatoo.input.devices.components.ControllerButton button)
This event is fired when a ControllerButton has been pressed and this Widget is the currently focussed one.

Specified by:
onControllerButtonPressed in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
button - the pressed button

onControllerButtonReleased

public void onControllerButtonReleased(Widget widget,
                                       org.jagatoo.input.devices.components.ControllerButton button)
This event is fired when a ControllerButton has been released and this Widget is the currently focussed one.

Specified by:
onControllerButtonReleased in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
button - the released button

onControllerAxisChanged

public void onControllerAxisChanged(Widget widget,
                                    org.jagatoo.input.devices.components.ControllerAxis axis,
                                    int axisDelta)
This event is fired when a ControllerAxis has changed and this Widget is the currently focussed one.

Specified by:
onControllerAxisChanged in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired
axis - the changed axis

onInputStateChanged

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

Specified by:
onInputStateChanged in interface WidgetInputListener
Parameters:
widget - the Widget for which this event was fired

add

public void add(Widget widget)
Adds a Widget to this logic group.

Parameters:
widget - the Widget to add

remove

public boolean remove(Widget widget)
Removes a Widget from this logic group.

Parameters:
widget - the Widget to remove