org.xith3d.ui.hud.base
Interface Widget

All Superinterfaces:
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
All Known Subinterfaces:
AbstractImage, AdvancedTextWidget, BackgroundSettableWidget, ContentPaneWrapper, Menu, MenuGroupWidget, TextWidget, WidgetContainer
All Known Implementing Classes:
AbstractButton, BackgroundSettableRectangularWidget, BevelBorder, BorderWidget, Button, ButtonsLeftMenusCenterMenuGroupWidget, Checkbox, ColoredBorder, ComboBox, DefaultContextMenuItem, Dialog, DynamicLabel, EmptyWidget, FPIHInputBindingsSettingsMenu, FPIHMainSettingsMenu, FPSCounter, Frame, GraphicsMainSettingsMenu, HUD, HUDConsole, Image, InputBindingsSettingsMenu, InputBox, Label, LabeledStateButton, LineWidget, List, MenuBase, MsgBox, NumberLabel, Panel, ProgressBar, QuadDivider, RadioButton, RectangularContentPaneWrapper, RectangularWidget, RoundedCornersBorder, Scrollbar, ScrollPane, Slider, StateButton, TextField, TextList, ToggleButton, Widget3D, WidgetBase, WidgetContainerBase, Window, WindowHeaderWidget

public interface Widget
extends org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Sized2f, org.jagatoo.datatypes.NamableObject

All Widgets to be added to a HUD must implement this interface. Extend WidgetBase for easier work.


Nested Class Summary
static class Widget.DescriptionBase
           
 
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()
           
 float getTransparency()
           
 java.lang.Object getUserObject()
           
 float getWidth()
           
 int getZIndex()
           
 boolean hasFocus()
          Is this Widget focused?
 boolean hasFocus(boolean testLeaf)
          Is this Widget focused?
 boolean hasToolTip()
           
 boolean isClickable()
           
 boolean isDraggable()
           
 boolean isFocussable()
           
 boolean isPickable()
           
 boolean isVisible()
           
 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.
 HUDPickResult pick(int canvasX, int canvasY, HUDPickResult.HUDPickReason pickReason, org.jagatoo.input.devices.components.MouseButton button, long when, long meta, int flags)
          Tests whether a Widget is under the cursor and runs the approriate methods if true.
 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.
 Widget setLocation(float locX, float locY)
          Sets this Widget's location relative to the upper-left corner of it's WidgetContainer
 Widget 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.
 Widget setSize(float width, float height)
          Resizes this Widget to the given width and height.
 Widget setSize(org.openmali.types.twodee.Sized2fRO size)
          Resizes this Widget to the given width and height.
 Widget 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 setZIndex(int zIndex)
          Sets the z-index of this Widget.
 void update()
          Updates the Widget's internals.
 
Methods inherited from interface org.openmali.types.twodee.Sized2f
setHeight, setWidth
 

Method Detail

getSGNode

Node getSGNode()
Returns:
this Widget's Node to be added to the scenegraph

setName

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

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

getName

java.lang.String getName()
Specified by:
getName in interface org.jagatoo.datatypes.NamedObject
Returns:
this widget's name

setUserObject

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

Parameters:
userObject - the new user-Object

getUserObject

java.lang.Object getUserObject()
Returns:
this Widget's user-Object

getHUD

HUD getHUD()
Returns:
the HUD this Widget belongs to

setAssembly

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


getAssembly

Widget getAssembly()
Returns:
the Widget, which uses this one to assemle itself, if any.

detach

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

Parameters:
delayed - if true, the widget is detached with the next frame, but not instantly.

detach

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


onDetached

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


update

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


getContainer

WidgetContainer getContainer()
The Container which contains this Widget


setContainer

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

Parameters:
container - the new Container

getSize

org.openmali.types.twodee.Sized2fRO getSize()
Returns:
the size of this Widget (in container meatures)

getWidth

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

getHeight

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

getAspect

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

setSize

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

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

setSize

Widget 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
Parameters:
size - the new size of this Widget
Returns:
true, if the size actually has changed

setSize

Widget 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
Parameters:
size - the new size of this Widget
Returns:
true, if the size actually has changed

setLocation

Widget 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
Parameters:
locX - the new x-location
locY - the new y-location
Returns:
true, if the location actually has changed

setLocation

Widget 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
Parameters:
loc - the new location
Returns:
true, if the location actually has changed

getLocation

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

getLeft

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

getTop

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

getZIndex

int getZIndex()
Returns:
the z-index of this Widget. Larger values bring are nearer.

setZIndex

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


getSGZPosition

float getSGZPosition()
Returns:
the z-position of this Widget in the scenegraph

setTransparency

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

Parameters:
transparency -

getTransparency

float getTransparency()
Returns:
the whole Widget's Transparency.

setVisible

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

Parameters:
visible - visible?

isVisible

boolean isVisible()
Returns:
wheather this Widget is visible or not

isDraggable

boolean isDraggable()
Returns:
wheather this Widget is draggable.

setDraggable

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.


setClickable

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.


isClickable

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

setPickable

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


isPickable

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

setCursor

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.

Parameters:
cursor -

getCursor

Cursor.Type getCursor()
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

Cursor.Type getInheritedCursor()
Returns:
the "computed" Cursor type to be used when the cursor is over this Widget.

pick

HUDPickResult pick(int canvasX,
                   int canvasY,
                   HUDPickResult.HUDPickReason pickReason,
                   org.jagatoo.input.devices.components.MouseButton button,
                   long when,
                   long meta,
                   int flags)
Tests whether a Widget is under the cursor and runs the approriate methods if true.

Parameters:
canvasX - the x position of the mouse on the Canvas3D
canvasY - the y position of the mouse on the Canvas3D
pickReason - the action which caused this pick operation
button - the mouse-button, that caused the picking
when - the timestamp of the picking
meta - this could be either the lastPressTime, lastReleaseTime, buttonsState mask or the page-move-boolean. (depends on the pickReason)
flags -
Returns:
an instance of HUDPickResult holding the picked Widget and absolute and relative picking positions or null.

setFocussable

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

Parameters:
focussable -

isFocussable

boolean isFocussable()
Returns:
whether this Widget can get the focus or not.

requestFocus

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


hasFocus

boolean hasFocus(boolean testLeaf)
Is this Widget focused?

Parameters:
testLeaf - only returns true, if this Widget is focused and is a Leaf

hasFocus

boolean hasFocus()
Is this Widget focused?


onFocusGained

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


onFocusLost

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


onKeyPressed

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
when - the keyevent's timestamp

onKeyReleased

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
when - the keyevent's timestamp

onKeyTyped

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

onMouseButtonPressed

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.

Parameters:
button - the button that was pressed
x - the current mouse x position
y - the current mouse y position
when -
lastWhen -
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseButtonReleased

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.

Parameters:
button - the button that was released
x - the current mouse x position
y - the current mouse y position
when -
lastWhen -
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseMoved

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.

Parameters:
x - the new X coordinate
y - the new Y coordinate
buttonsState -
when -
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseStopped

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.

Parameters:
x - the new X coordinate
y - the new Y coordinate
when -
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseWheelMoved

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.

Parameters:
delta - a positive value when the wheel was moved up
isPageMove -
x - the current mouse x position
y - the current mouse y position
when -
isTopMost - is this Widget topMost

onMouseEntered

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

Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseLeft

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

Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseUnbound

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.


onControllerButtonPressed

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

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

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 -

onInputStateChanged

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 -

addInputListener

void addInputListener(WidgetInputListener l)
Adds a new WidgetInputListener.

Parameters:
l -

removeInputListener

void removeInputListener(WidgetInputListener l)
Removes a WidgetInputListener.

Parameters:
l -

addFocusListener

void addFocusListener(WidgetFocusListener l)
Adds a new WidgetFocusListener.

Parameters:
l -

removeFocusListener

void removeFocusListener(WidgetFocusListener l)
Removes a WidgetFocusListener.

Parameters:
l -

addLocationListener

void addLocationListener(WidgetLocationListener l)
Adds a new WidgetLocationListener.

Parameters:
l -

removeLocationListener

void removeLocationListener(WidgetLocationListener l)
Removes a WidgetFocusListener.

Parameters:
l -

addSizeListener

void addSizeListener(WidgetSizeListener l)
Adds a new WidgetSizeListener.

Parameters:
l -

removeSizeListener

void removeSizeListener(WidgetSizeListener l)
Removes a WidgetSizeListener.

Parameters:
l -

addVisibilityListener

void addVisibilityListener(WidgetVisibilityListener l)
Adds a new WidgetVisibilityListener.

Parameters:
l -

removeVisibilityListener

void removeVisibilityListener(WidgetVisibilityListener l)
Removes a WidgetVisibilityListener.

Parameters:
l -

addContainerListener

void addContainerListener(WidgetContainerListener l)
Adds a new WidgetContainerListener.

Parameters:
l -

removeContainerListener

void removeContainerListener(WidgetContainerListener l)
Removes a WidgetContainerListener.

Parameters:
l -

setContextMenu

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

Parameters:
contextMenu -

getContextMenu

ContextMenu getContextMenu()
Returns:
the (inherited) ContextMenu.

setToolTip

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

Parameters:
tooltip -

getToolTip

java.lang.String getToolTip()
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

boolean hasToolTip()
Returns:
whether this Widget has a tooltip (!= null and not empty String).

setCachedToolTipWidget

void setCachedToolTipWidget(Widget tooltipWidget)

getCachedToolTipWidget

Widget getCachedToolTipWidget()