org.xith3d.ui.hud.base
Class WidgetAssembler

java.lang.Object
  extended by org.xith3d.ui.hud.base.WidgetAssembler

public class WidgetAssembler
extends java.lang.Object

An instance of this class is hold by each Widget. It can be used to add Widgets to to create a new Widget from existing ones.


Field Summary
protected  TransformGroup transformGroup
           
 
Constructor Summary
WidgetAssembler(Widget owner, GroupNode ownerGroup)
           
 
Method Summary
 void addWidget(Widget widget)
          Adds a Widget to this assembler at location(0, 0).
 void addWidget(Widget widget, float locX, float locY)
          Adds a Widget to this assembler.
 void addWidget(Widget widget, org.openmali.vecmath2.Tuple2f location)
          Adds a Widget to this assembler.
 boolean areKeyEventsDispatched()
           
 boolean contains(Widget widget)
           
 Widget getCurrentFocussedWidget()
           
 org.openmali.vecmath2.Tuple2f getPosition(Widget widget)
           
 float getPositionX(Widget widget)
           
 float getPositionY(Widget widget)
           
 java.util.List<Widget> getWidgets()
           
 boolean isPickingDispatched()
           
 void onControllerAxisChanged(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(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(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(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(org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is pressed on a focused Widget.
 void onKeyReleased(org.jagatoo.input.devices.components.Key key, long when)
          This event is fired, when a key is released on a focused Widget.
 void onKeyTyped(char ch, long when)
          This event is fired when a key is typed on the keyboard.
 Widget pick(float relX, float relY)
          Retrieves the SubWidget which is actually picked.
 HUDPickResult pick(int canvasX, int canvasY, HUDPickResult.HUDPickReason pickReason, org.jagatoo.input.devices.components.MouseButton button, long when, long meta, int flags)
          Dispatches the picking to the assembling Widgets.
 void removeWidget(Widget widget)
          Removes a Widget from this assembler.
 void reposition(Widget widget, float posX, float posY)
          Repositions the Widget relative to the owner Widget
 void reposition(Widget widget, org.openmali.vecmath2.Tuple2f position)
          Repositions the Widget relative to the owner Widget
 void setKeyEventsDispatched(boolean b)
          Enables or disables dispatching of key events to the assemble Widgets.
 void setPickDispatched(boolean b)
          Enables or disables dispatching of pickings to the assemble Widgets.
 void setTransparency(float transparency, boolean childrenToo)
          Sets the whole Widget's Transparency.
 void update()
           
 void updateLocation(Widget widget, float ownerLocX, float ownerLocY)
          Update the assembly Widgets' locations
 void updateLocations(float ownerLocX, float ownerLocY)
          Update the assembly Widgets' locations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformGroup

protected TransformGroup transformGroup
Constructor Detail

WidgetAssembler

public WidgetAssembler(Widget owner,
                       GroupNode ownerGroup)
Method Detail

getCurrentFocussedWidget

public final Widget getCurrentFocussedWidget()

setTransparency

public void setTransparency(float transparency,
                            boolean childrenToo)
Sets the whole Widget's Transparency.

Parameters:
transparency -
childrenToo -

setKeyEventsDispatched

public void setKeyEventsDispatched(boolean b)
Enables or disables dispatching of key events to the assemble Widgets.

Parameters:
b -

areKeyEventsDispatched

public boolean areKeyEventsDispatched()
Returns:
whether dispatching of key events to the assemble Widgets is enabled.

onKeyPressed

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

Parameters:
key - the key that was pressed

onKeyReleased

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

Parameters:
key - the key that was released

onKeyTyped

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

Parameters:
ch - the typed key's character
when - the keyevent's timestamp

onControllerButtonPressed

public void onControllerButtonPressed(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.

Parameters:
button - the pressed button

onControllerButtonReleased

public void onControllerButtonReleased(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.

Parameters:
button - the released button

onControllerAxisChanged

public void onControllerAxisChanged(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.

Parameters:
axis - the changed axis
axisDelta -
isTopMost - is this Widget topMost

onInputStateChanged

public void onInputStateChanged(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.

Parameters:
comp -
delta -
state -
isTopMost -
hasFocus -

setPickDispatched

public void setPickDispatched(boolean b)
Enables or disables dispatching of pickings to the assemble Widgets.

Parameters:
b -

isPickingDispatched

public boolean isPickingDispatched()
Returns:
whether dispatching of pickings to the assemble Widgets is enabled.

pick

public HUDPickResult pick(int canvasX,
                          int canvasY,
                          HUDPickResult.HUDPickReason pickReason,
                          org.jagatoo.input.devices.components.MouseButton button,
                          long when,
                          long meta,
                          int flags)
Dispatches the picking to the assembling Widgets.

Parameters:
canvasX - the absolute canvas-x-position of the picking
canvasY - the absolute canvas-y-position of the picking
pickReason - the reson of this picking
button - the mouse-button, that caused the picking
when -
meta -
flags -
Returns:
the picked Widget or null

pick

public Widget pick(float relX,
                   float relY)
Retrieves the SubWidget which is actually picked.

Parameters:
relX - the mouse-x-position relative to the owner Widget's position
relY - the mouse-y-position relative to the owner Widget's position

updateLocation

public void updateLocation(Widget widget,
                           float ownerLocX,
                           float ownerLocY)
Update the assembly Widgets' locations

Parameters:
widget - the Widget, which's location is to be updated
ownerLocX - the owner Widget's x-location
ownerLocY - the owner Widget's y-location

updateLocations

public void updateLocations(float ownerLocX,
                            float ownerLocY)
Update the assembly Widgets' locations

Parameters:
ownerLocX - the owner Widget's x-location
ownerLocY - the owner Widget's y-location

reposition

public void reposition(Widget widget,
                       float posX,
                       float posY)
Repositions the Widget relative to the owner Widget

Parameters:
widget - the Widget to reposition
posX - the new x-position
posY - the new y-position

reposition

public void reposition(Widget widget,
                       org.openmali.vecmath2.Tuple2f position)
Repositions the Widget relative to the owner Widget

Parameters:
widget - the Widget to reposition
position - the new position

getPositionX

public float getPositionX(Widget widget)
Parameters:
widget - the Widget in question
Returns:
the x-position relative to the owner Widget

getPositionY

public float getPositionY(Widget widget)
Parameters:
widget - the Widget in question
Returns:
the y-position relative to the owner Widget

getPosition

public org.openmali.vecmath2.Tuple2f getPosition(Widget widget)
Parameters:
widget - the Widget in question
Returns:
the position relative to the owner Widget

getWidgets

public java.util.List<Widget> getWidgets()
Returns:
an unmodifiable Set of all contained Widgets

contains

public boolean contains(Widget widget)
Returns:
true, if the Widget is in the List of Assemble-Widgets

addWidget

public void addWidget(Widget widget,
                      float locX,
                      float locY)
Adds a Widget to this assembler.

Parameters:
widget - the Widget to add
locX - the x-location to add the Widget at (relative to the owner's position)
locY - the y-location to add the Widget at (relative to the owner's position)

addWidget

public void addWidget(Widget widget,
                      org.openmali.vecmath2.Tuple2f location)
Adds a Widget to this assembler.

Parameters:
widget - the Widget to add
location - the location to add the Widget at (relative to the owner's position)

addWidget

public void addWidget(Widget widget)
Adds a Widget to this assembler at location(0, 0).

Parameters:
widget - the Widget to add

removeWidget

public void removeWidget(Widget widget)
Removes a Widget from this assembler.

Parameters:
widget - the Widget to be removed

update

public void update()