org.xith3d.ui.hud.base
Class WidgetBase

java.lang.Object
  extended by org.xith3d.ui.hud.base.WidgetBase
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, Widget
Direct Known Subclasses:
ColoredBorder, LineWidget, QuadDivider, RectangularWidget

public abstract class WidgetBase
extends java.lang.Object
implements Widget

This class implements a base for a Widget.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
protected  java.util.ArrayList<WidgetContainerListener> containerListeners
           
protected  TransformGroup transformGroup
           
protected  org.openmali.vecmath2.Vector3f translation
           
protected static float Z_INDEX_UNIT
           
protected static float Z_INDEX_UNIT_ASSEMBLER
           
 
Constructor Summary
WidgetBase(float width, float height)
          Creates a new Widget with the given width and height
WidgetBase(float width, float height, int zIndex)
          Creates a new Widget with the given width and height
 
Method Summary
 void addContainerListener(WidgetContainerListener l)
          Adds a new WidgetContainerListener.
 void addFocusListener(WidgetFocusListener l)
          Adds a new WidgetFocusListener.
 void addInputListener(WidgetInputListener l)
          Adds a new WidgetInputListener.
 void addLocationListener(WidgetLocationListener l)
          Adds a new WidgetLocationListener.
 void addSizeListener(WidgetSizeListener l)
          Adds a new WidgetSizeListener.
 void addVisibilityListener(WidgetVisibilityListener l)
          Adds a new WidgetVisibilityListener.
 void detach()
          Instantly removes the Widget from its Container.
 void detach(boolean delayed)
          Removes the Widget from its Container.
 float getAspect()
          
 Widget getAssembly()
          
 Widget getCachedToolTipWidget()
          
 WidgetContainer getContainer()
          The Container which contains this Widget
 ContextMenu getContextMenu()
           
 Cursor.Type getCursor()
          
 float getHeight()
          
 HUD getHUD()
          
 Cursor.Type getInheritedCursor()
          
 float getLeft()
          
 org.openmali.vecmath2.Tuple2f getLocation()
          
 java.lang.String getName()
          
 Node getSGNode()
          
 float getSGZPosition()
          
 org.openmali.types.twodee.Sized2fRO getSize()
          
 java.lang.String getToolTip()
          
 float getTop()
          
 java.lang.Object getUserObject()
          
protected  WidgetAssembler getWidgetAssembler()
           
 float getWidth()
          
 int getZIndex()
          
 boolean hasFocus()
          Is this Widget focused?
 boolean hasFocus(boolean testLeaf)
          Is this Widget focused?
 boolean hasToolTip()
          
protected abstract  void init()
          This method is called when the WidgetContainer is set.
 boolean isClickable()
          
 boolean isDraggable()
          
 boolean isFocussable()
          
protected  boolean isInitialized()
          Has the init method been executed once?
protected  boolean isInitializing()
          Is the init method currently being executed?
 boolean isPickable()
          
 boolean isVisible()
          
protected  void onAddedToContainer(WidgetContainer container)
          This event is fired, when this Widget is added to a WidgetContainer.
protected  void onAddedToHUD(HUD hud)
          This event is fired, when this Widget is added to a WidgetContainer and the container itself is already added to the HUD or is the HUD itself.
 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 onDetached()
          This method is called right before the Widget has been detached from its WidgetContainer.
 void onFocusGained()
          This event is fired, when the focus is gained to a Widget.
 void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
 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.
 void onMouseButtonPressed(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(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(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse entered the Widget area
 void onMouseLeft(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse left the Widget area
 void onMouseMoved(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(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()
          This event is fired, when the mouse is released.
 void onMouseWheelMoved(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.
protected  void onRemovedFromContainer(WidgetContainer container)
          This event is fired, when this Widget is removed from a WidgetContainer.
protected  HUDPickResult pickWidgetAssembler(HUDPickResult hostHPR, 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 WidgetAssembler.
 void removeContainerListener(WidgetContainerListener l)
          Removes a WidgetContainerListener.
 void removeFocusListener(WidgetFocusListener l)
          Removes a WidgetFocusListener.
 void removeInputListener(WidgetInputListener l)
          Removes a WidgetInputListener.
 void removeLocationListener(WidgetLocationListener l)
          Removes a WidgetFocusListener.
 void removeSizeListener(WidgetSizeListener l)
          Removes a WidgetSizeListener.
 void removeVisibilityListener(WidgetVisibilityListener l)
          Removes a WidgetVisibilityListener.
 void requestFocus()
          Requests the focus from the HUD system.
 void setAssembly(Widget assembly)
          Sets the Widget, which uses this one to assemle itself, if any.
 void setCachedToolTipWidget(Widget tooltipWidget)
          
 void setClickable(boolean isClickable)
          Sets wheather this Widget is clickable.
 void setContainer(WidgetContainer container)
          Sets this Widget's container
 void setContextMenu(ContextMenu contextMenu)
          Sets the ContextMenu for this Widget and inherits it to all children, if this is a container.
 void setCursor(Cursor.Type cursor)
          Sets the Cursor type to be used when the cursor is over this Widget and which is inherited to the Children, if this is a container.
 void setDraggable(boolean draggable)
          Sets wheather this Widget is clickable.
 void setFocussable(boolean focussable)
          Sets whether this Widget can get the focus or not.
 void setHeight(float height)
          
 WidgetBase setLocation(float locX, float locY)
          Sets this Widget's location relative to the upper-left corner of it's WidgetContainer
protected  boolean setLocation(float locX, float locY, boolean forced)
           
 WidgetBase setLocation(org.openmali.vecmath2.Tuple2f loc)
          Sets this Widget's location relative to the upper-left corner of it's WidgetContainer
 void setName(java.lang.String name)
          Sets this Widget's name
 void setPickable(boolean isPickable)
          Sets wheather this Widget is pickable.
 WidgetBase setSize(float width, float height)
          Resizes this Widget to the given width and height.
protected  boolean setSize(float width, float height, boolean forced)
           
 WidgetBase setSize(org.openmali.types.twodee.Sized2fRO size)
          Resizes this Widget to the given width and height.
 WidgetBase setSize(org.openmali.vecmath2.Tuple2f size)
          Resizes this Widget to the given width and height.
 void setToolTip(java.lang.String tooltip)
          Sets the tooltip to be displayed when the mouse stopps over this Widget.
 void setTransparency(float transparency)
          Sets the whole Widget's Transparency.
 void setUserObject(java.lang.Object userObject)
          Sets this Widget's user-Object.
 void setVisible(boolean visible)
          Sets wheather this Widget is visible or not
 void setWidth(float width)
          
 void setZIndex(int zIndex)
          Sets the z-index of this Widget.
 java.lang.String toString()
          
 void update()
          Updates the Widget's internals.
protected  void updateTranslation()
          Effectively changes the translation of this Widget (location and z-index)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.ui.hud.base.Widget
getTransparency, pick
 

Field Detail

transformGroup

protected final TransformGroup transformGroup

Z_INDEX_UNIT

protected static final float Z_INDEX_UNIT
See Also:
Constant Field Values

Z_INDEX_UNIT_ASSEMBLER

protected static final float Z_INDEX_UNIT_ASSEMBLER
See Also:
Constant Field Values

translation

protected org.openmali.vecmath2.Vector3f translation

containerListeners

protected final java.util.ArrayList<WidgetContainerListener> containerListeners
Constructor Detail

WidgetBase

public WidgetBase(float width,
                  float height,
                  int zIndex)
Creates a new Widget with the given width and height

Parameters:
width - the new width of this Widget
height - the new height of this Widget
zIndex - the z-index of this Widget

WidgetBase

public WidgetBase(float width,
                  float height)
Creates a new Widget with the given width and height

Parameters:
width - the new width of this Widget
height - the new height of this Widget
Method Detail

addInputListener

public void addInputListener(WidgetInputListener l)
Adds a new WidgetInputListener.

Specified by:
addInputListener in interface Widget

removeInputListener

public void removeInputListener(WidgetInputListener l)
Removes a WidgetInputListener.

Specified by:
removeInputListener in interface Widget

addFocusListener

public void addFocusListener(WidgetFocusListener l)
Adds a new WidgetFocusListener.

Specified by:
addFocusListener in interface Widget

removeFocusListener

public void removeFocusListener(WidgetFocusListener l)
Removes a WidgetFocusListener.

Specified by:
removeFocusListener in interface Widget

addLocationListener

public void addLocationListener(WidgetLocationListener l)
Adds a new WidgetLocationListener.

Specified by:
addLocationListener in interface Widget

removeLocationListener

public void removeLocationListener(WidgetLocationListener l)
Removes a WidgetFocusListener.

Specified by:
removeLocationListener in interface Widget

addSizeListener

public void addSizeListener(WidgetSizeListener l)
Adds a new WidgetSizeListener.

Specified by:
addSizeListener in interface Widget

removeSizeListener

public void removeSizeListener(WidgetSizeListener l)
Removes a WidgetSizeListener.

Specified by:
removeSizeListener in interface Widget

addVisibilityListener

public void addVisibilityListener(WidgetVisibilityListener l)
Adds a new WidgetVisibilityListener.

Specified by:
addVisibilityListener in interface Widget

removeVisibilityListener

public void removeVisibilityListener(WidgetVisibilityListener l)
Removes a WidgetVisibilityListener.

Specified by:
removeVisibilityListener in interface Widget

addContainerListener

public void addContainerListener(WidgetContainerListener l)
Adds a new WidgetContainerListener.

Specified by:
addContainerListener in interface Widget

removeContainerListener

public void removeContainerListener(WidgetContainerListener l)
Removes a WidgetContainerListener.

Specified by:
removeContainerListener in interface Widget

onMouseEntered

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

Specified by:
onMouseEntered in interface Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseLeft

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

Specified by:
onMouseLeft in interface Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseButtonPressed

public void onMouseButtonPressed(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 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

public void onMouseButtonReleased(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 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

public void onMouseMoved(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 Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseStopped

public void onMouseStopped(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 Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseWheelMoved

public void onMouseWheelMoved(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 Widget
Parameters:
delta - a positive value when the wheel was moved up
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost

setFocussable

public void setFocussable(boolean focussable)
Sets whether this Widget can get the focus or not.

Specified by:
setFocussable in interface Widget

isFocussable

public final boolean isFocussable()

Specified by:
isFocussable in interface Widget
Returns:
whether this Widget can get the focus or not.

requestFocus

public void requestFocus()
Requests the focus from the HUD system.
The focus will be gained on next loop iteration.

Specified by:
requestFocus in interface Widget

onFocusGained

public void onFocusGained()
This event is fired, when the focus is gained to a Widget.

Specified by:
onFocusGained in interface Widget

onFocusLost

public void onFocusLost()
This event is fired, when the focus is lost by a Widget.

Specified by:
onFocusLost in interface Widget

hasFocus

public final boolean hasFocus(boolean testLeaf)
Is this Widget focused?

Specified by:
hasFocus in interface Widget
Parameters:
testLeaf - only returns true, if this Widget is focused and is a Leaf

hasFocus

public final boolean hasFocus()
Is this Widget focused?

Specified by:
hasFocus in interface Widget

onMouseUnbound

public void onMouseUnbound()
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 Widget

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.

Specified by:
onKeyPressed in interface Widget
Parameters:
key - the key that was pressed
when - the keyevent's timestamp

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.

Specified by:
onKeyReleased in interface Widget
Parameters:
key - the key that was released
when - the keyevent's timestamp

onKeyTyped

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

Specified by:
onKeyTyped in interface Widget
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.

Specified by:
onControllerButtonPressed in interface Widget
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.

Specified by:
onControllerButtonReleased in interface Widget
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.

Specified by:
onControllerAxisChanged in interface Widget
Parameters:
axis - the changed axis

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.

Specified by:
onInputStateChanged in interface Widget

getSGZPosition

public final float getSGZPosition()

Specified by:
getSGZPosition in interface Widget
Returns:
the z-position of this Widget in the scenegraph

setVisible

public void setVisible(boolean visible)
Sets wheather this Widget is visible or not

Specified by:
setVisible in interface Widget
Parameters:
visible - visible?

isVisible

public final boolean isVisible()

Specified by:
isVisible in interface Widget
Returns:
wheather this Widget is visible or not

setTransparency

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

Specified by:
setTransparency in interface Widget

setClickable

public void setClickable(boolean isClickable)
Sets wheather this Widget is clickable. If it is not clickable, clicks are sent to the next Widget under this one, if any.

Specified by:
setClickable in interface Widget

isClickable

public final boolean isClickable()

Specified by:
isClickable in interface Widget
Returns:
wheather this Widget is clickable. If it is not clickable, clicks are sent to the next Widget under this one, if any.

setDraggable

public void setDraggable(boolean draggable)
Sets wheather this Widget is clickable. If it is not clickable, clicks are sent to the next Widget under this one, if any.

Specified by:
setDraggable in interface Widget

isDraggable

public final boolean isDraggable()

Specified by:
isDraggable in interface Widget
Returns:
wheather this Widget is draggable.

setPickable

public void setPickable(boolean isPickable)
Sets wheather this Widget is pickable. If it is not pickable, the pick() method will always return null.

Specified by:
setPickable in interface Widget

isPickable

public final boolean isPickable()

Specified by:
isPickable in interface Widget
Returns:
wheather this Widget is pickable. If it is not pickable, the pick() method will always return null.

setCursor

public final void setCursor(Cursor.Type cursor)
Sets the Cursor type to be used when the cursor is over this Widget and which is inherited to the Children, if this is a container.

Specified by:
setCursor in interface Widget

getCursor

public final Cursor.Type getCursor()

Specified by:
getCursor in interface Widget
Returns:
the Cursor type to be used when the cursor is over this Widget and which is inherited to the Children, if this is a container.

getInheritedCursor

public final Cursor.Type getInheritedCursor()

Specified by:
getInheritedCursor in interface Widget
Returns:
the "computed" Cursor type to be used when the cursor is over this Widget.

update

public void update()
Updates the Widget's internals.
Called by the Widget system and can be called from outside.

Specified by:
update in interface Widget

updateTranslation

protected void updateTranslation()
Effectively changes the translation of this Widget (location and z-index)


setLocation

protected boolean setLocation(float locX,
                              float locY,
                              boolean forced)

setLocation

public final WidgetBase setLocation(float locX,
                                    float locY)
Sets this Widget's location relative to the upper-left corner of it's WidgetContainer

Specified by:
setLocation in interface org.openmali.types.twodee.Positioned2f
Specified by:
setLocation in interface Widget
Parameters:
locX - the new x-location
locY - the new y-location
Returns:
true, if the location actually has changed

setLocation

public final WidgetBase setLocation(org.openmali.vecmath2.Tuple2f loc)
Sets this Widget's location relative to the upper-left corner of it's WidgetContainer

Specified by:
setLocation in interface org.openmali.types.twodee.Positioned2f
Specified by:
setLocation in interface Widget
Parameters:
loc - the new location
Returns:
true, if the location actually has changed

getLocation

public final org.openmali.vecmath2.Tuple2f getLocation()

Specified by:
getLocation in interface org.openmali.types.twodee.Positioned2fRO
Specified by:
getLocation in interface Widget
Returns:
this Widget's location relative to the upper-left corner of it's WidgetContainer

getLeft

public final float getLeft()

Specified by:
getLeft in interface org.openmali.types.twodee.Positioned2fRO
Specified by:
getLeft in interface Widget
Returns:
this Widget's left location relative to the left borderline of it's WidgetContainer

getTop

public final float getTop()

Specified by:
getTop in interface org.openmali.types.twodee.Positioned2fRO
Specified by:
getTop in interface Widget
Returns:
this Widget's top location relative to the upper borderline of it's WidgetContainer

setSize

protected boolean setSize(float width,
                          float height,
                          boolean forced)

setWidth

public final void setWidth(float width)

Specified by:
setWidth in interface org.openmali.types.twodee.Sized2f

setHeight

public final void setHeight(float height)

Specified by:
setHeight in interface org.openmali.types.twodee.Sized2f

setSize

public final WidgetBase setSize(float width,
                                float height)
Resizes this Widget to the given width and height.

Specified by:
setSize in interface org.openmali.types.twodee.Sized2f
Specified by:
setSize in interface Widget
Parameters:
width - the new width of this Widget
height - the new height of this Widget
Returns:
true, if the size actually has changed

setSize

public final WidgetBase setSize(org.openmali.types.twodee.Sized2fRO size)
Resizes this Widget to the given width and height.

Specified by:
setSize in interface org.openmali.types.twodee.Sized2f
Specified by:
setSize in interface Widget
Parameters:
size - the new size of this Widget
Returns:
true, if the size actually has changed

setSize

public final WidgetBase setSize(org.openmali.vecmath2.Tuple2f size)
Resizes this Widget to the given width and height.

Specified by:
setSize in interface org.openmali.types.twodee.Sized2f
Specified by:
setSize in interface Widget
Parameters:
size - the new size of this Widget
Returns:
true, if the size actually has changed

getWidth

public final float getWidth()

Specified by:
getWidth in interface org.openmali.types.twodee.Sized2fRO
Specified by:
getWidth in interface Widget
Returns:
this Widget's width

getHeight

public final float getHeight()

Specified by:
getHeight in interface org.openmali.types.twodee.Sized2fRO
Specified by:
getHeight in interface Widget
Returns:
this Widget's height

getSize

public final org.openmali.types.twodee.Sized2fRO getSize()

Specified by:
getSize in interface Widget
Returns:
the size of this Widget (in container meatures)

getAspect

public final float getAspect()

Specified by:
getAspect in interface org.openmali.types.twodee.Sized2fRO
Specified by:
getAspect in interface Widget
Returns:
the aspect ratio (width / height) of this Widget

setZIndex

public void setZIndex(int zIndex)
Sets the z-index of this Widget. Larger values bring are nearer.

Specified by:
setZIndex in interface Widget

getZIndex

public final int getZIndex()

Specified by:
getZIndex in interface Widget
Returns:
the z-index of this Widget. Larger values bring are nearer.

init

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


isInitializing

protected final boolean isInitializing()
Is the init method currently being executed?


isInitialized

protected final boolean isInitialized()
Has the init method been executed once?


onAddedToContainer

protected void onAddedToContainer(WidgetContainer container)
This event is fired, when this Widget is added to a WidgetContainer.

Parameters:
container - the WidgetContainer, the Widget is added to

onAddedToHUD

protected void onAddedToHUD(HUD hud)
This event is fired, when this Widget is added to a WidgetContainer and the container itself is already added to the HUD or is the HUD itself.

Parameters:
hud - the HUD, the Widget is added to

onRemovedFromContainer

protected void onRemovedFromContainer(WidgetContainer container)
This event is fired, when this Widget is removed from a WidgetContainer.

Parameters:
container - the WidgetContainer, the Widget is removed from

setContainer

public void setContainer(WidgetContainer container)
Sets this Widget's container

Specified by:
setContainer in interface Widget
Parameters:
container - the new Container

setAssembly

public void setAssembly(Widget assembly)
Sets the Widget, which uses this one to assemle itself, if any.

Specified by:
setAssembly in interface Widget

getAssembly

public final Widget getAssembly()

Specified by:
getAssembly in interface Widget
Returns:
the Widget, which uses this one to assemle itself, if any.

getContainer

public final WidgetContainer getContainer()
The Container which contains this Widget

Specified by:
getContainer in interface Widget

getHUD

public final HUD getHUD()

Specified by:
getHUD in interface Widget
Returns:
the HUD this Widget belongs to

detach

public void detach(boolean delayed)
Removes the Widget from its Container.

Specified by:
detach in interface Widget
Parameters:
delayed - if true, the widget is detached with the next frame, but not instantly.

detach

public final void detach()
Instantly removes the Widget from its Container.

Specified by:
detach in interface Widget

onDetached

public void onDetached()
This method is called right before the Widget has been detached from its WidgetContainer.

Specified by:
onDetached in interface Widget

getSGNode

public final Node getSGNode()

Specified by:
getSGNode in interface Widget
Returns:
this Widget's Node to be added to the scenegraph

setName

public void setName(java.lang.String name)
Sets this Widget's name

Specified by:
setName in interface org.jagatoo.datatypes.NamableObject
Specified by:
setName in interface Widget

getName

public final java.lang.String getName()

Specified by:
getName in interface org.jagatoo.datatypes.NamedObject
Specified by:
getName in interface Widget
Returns:
this widget's name

setUserObject

public void setUserObject(java.lang.Object userObject)
Sets this Widget's user-Object.

Specified by:
setUserObject in interface Widget
Parameters:
userObject - the new user-Object

getUserObject

public final java.lang.Object getUserObject()

Specified by:
getUserObject in interface Widget
Returns:
this Widget's user-Object

setContextMenu

public void setContextMenu(ContextMenu contextMenu)
Sets the ContextMenu for this Widget and inherits it to all children, if this is a container.

Specified by:
setContextMenu in interface Widget

getContextMenu

public ContextMenu getContextMenu()
Specified by:
getContextMenu in interface Widget
Returns:
the (inherited) ContextMenu.

setToolTip

public void setToolTip(java.lang.String tooltip)
Sets the tooltip to be displayed when the mouse stopps over this Widget. Please see HUD.setToolTipFactory(org.xith3d.ui.hud.utils.ToolTipFactory) and HUD.getToolTipFactory().

Specified by:
setToolTip in interface Widget

getToolTip

public final java.lang.String getToolTip()

Specified by:
getToolTip in interface Widget
Returns:
the tooltip to be displayed when the mouse stopps over this Widget. Please see HUD.setToolTipFactory(org.xith3d.ui.hud.utils.ToolTipFactory) and HUD.getToolTipFactory().

hasToolTip

public final boolean hasToolTip()

Specified by:
hasToolTip in interface Widget
Returns:
whether this Widget has a tooltip (!= null and not empty String).

setCachedToolTipWidget

public void setCachedToolTipWidget(Widget tooltipWidget)

Specified by:
setCachedToolTipWidget in interface Widget

getCachedToolTipWidget

public final Widget getCachedToolTipWidget()

Specified by:
getCachedToolTipWidget in interface Widget

getWidgetAssembler

protected final WidgetAssembler getWidgetAssembler()
Returns:
the WidgetAssembler attached to this Widget

pickWidgetAssembler

protected HUDPickResult pickWidgetAssembler(HUDPickResult hostHPR,
                                            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 WidgetAssembler.

Returns:
the pickresult of the WidgetAssembler or null

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object