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.


Constructor Summary
WidgetAssembler(Widget owner)
           
 
Method Summary
 void addUnmanagedWidget(Widget widget)
          Adds an unmanaged Widget to this assembler.
 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.
 boolean areKeyEventsDispatched()
           
 boolean contains(Widget widget)
           
protected  void draw(Texture2DCanvas texCanvas, int offsetX, int offsetY)
           
 int getAdditionalContentHeight()
           
 int getAdditionalContentLeft()
           
 int getAdditionalContentTop()
           
 int getAdditionalContentWidth()
           
 Widget getCurrentFocussedWidget()
           
 float getPositionX(Widget widget)
           
 float getPositionY(Widget widget)
           
 boolean isPickingDispatched()
           
 void onControllerAxisChanged(org.jagatoo.input.devices.components.ControllerAxis axis, int axisDelta, long when)
          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, long when)
          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, long when)
          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, long when, 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, int modifierMask, long when)
          This event is fired, when a key is pressed on a focused Widget.
 void onKeyReleased(org.jagatoo.input.devices.components.Key key, int modifierMask, long when)
          This event is fired, when a key is released on a focused Widget.
 void onKeyTyped(char ch, int modifierMask, long when)
          This event is fired when a key is typed on the keyboard.
 void onOwnerMoved(float deltaX, float deltaY, boolean needsTextureRefresh)
          Called by the owner when its location has changed.
 Widget pick(float relX, float relY)
          Retrieves the SubWidget which is actually picked.
 boolean pick(int canvasX, int canvasY, float widgetX, float widgetY, 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 setAdditionalContentSize(int additionalContentLeft, int additionalContentTop, int additionalContentWidth, int additionalContentHeight)
           
 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.
protected  void setWidgetsDirty()
           
 void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WidgetAssembler

public WidgetAssembler(Widget owner)
Method Detail

setAdditionalContentSize

public void setAdditionalContentSize(int additionalContentLeft,
                                     int additionalContentTop,
                                     int additionalContentWidth,
                                     int additionalContentHeight)

getAdditionalContentLeft

public final int getAdditionalContentLeft()

getAdditionalContentTop

public final int getAdditionalContentTop()

getAdditionalContentWidth

public final int getAdditionalContentWidth()

getAdditionalContentHeight

public final int getAdditionalContentHeight()

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 final 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,
                         int modifierMask,
                         long when)
This event is fired, when a key is pressed on a focused Widget.

Parameters:
key - the key that was pressed
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onKeyReleased

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

Parameters:
key - the key that was released
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onKeyTyped

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

Parameters:
ch - the typed key's character
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onControllerButtonPressed

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

Parameters:
button - the pressed button
when -

onControllerButtonReleased

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

Parameters:
button - the released button
when -

onControllerAxisChanged

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

Parameters:
axis - the changed axis
axisDelta -
when -

onInputStateChanged

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

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

setPickDispatched

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

Parameters:
b -

isPickingDispatched

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

pick

public boolean pick(int canvasX,
                    int canvasY,
                    float widgetX,
                    float widgetY,
                    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
widgetX -
widgetY -
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

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

onOwnerMoved

public void onOwnerMoved(float deltaX,
                         float deltaY,
                         boolean needsTextureRefresh)
Called by the owner when its location has changed.

Parameters:
deltaX -
deltaY -

getPositionX

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

getPositionY

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

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 final void addWidget(Widget widget)
Adds a Widget to this assembler at location(0, 0).

Parameters:
widget - the Widget to add

addUnmanagedWidget

public void addUnmanagedWidget(Widget widget)
Adds an unmanaged Widget to this assembler.

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()

setWidgetsDirty

protected void setWidgetsDirty()

draw

protected void draw(Texture2DCanvas texCanvas,
                    int offsetX,
                    int offsetY)