org.xith3d.ui.hud.base
Class Widget

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
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
Direct Known Subclasses:
AbstractButton, BackgroundSettableWidget, ColorChooser, EmptyWidget, Image, QuadDivider, Slider, StateButton, Widget3D, Window

public abstract class Widget
extends java.lang.Object
implements org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Sized2f, org.jagatoo.datatypes.NamableObject

All Widgets to be added to a HUD must extend this class.


Nested Class Summary
protected static class Widget.DescriptionBase
           
 
Field Summary
protected  float transformHeight_Pixels2HUD
           
protected  float transformWidth_Pixels2HUD
           
 
Constructor Summary
protected Widget(boolean isHeavyWeight, boolean hasWidgetAssembler)
          Creates a new Widget.
protected Widget(boolean isHeavyWeight, boolean hasWidgetAssembler, float width, float height)
          Creates a new Widget with the given width and height.
 
Method Summary
 void addContainerListener(WidgetContainerListener l)
          Adds a new WidgetContainerListener.
 void addControllerListener(WidgetControllerListener l)
          Adds a new WidgetControllerListener.
 void addFocusListener(WidgetFocusListener l)
          Adds a new WidgetFocusListener.
 void addInputListener(WidgetInputListener l)
          Adds a new WidgetInputListener.
 void addKeyboardListener(WidgetKeyboardListener l)
          Adds a new WidgetKeyboardListener.
 void addLocationListener(WidgetLocationListener l)
          Adds a new WidgetLocationListener.
 void addMouseListener(WidgetMouseListener l)
          Adds a new WidgetMouseListener.
 void addSizeListener(WidgetSizeListener l)
          Adds a new WidgetSizeListener.
 void addVisibilityListener(WidgetVisibilityListener l)
          Adds a new WidgetVisibilityListener.
protected  void bindToGlobalMouseMovement()
           
protected  boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
          Checks, if this Widget blocks the given DeviceComponent for focus-moves.
protected  float calculateTransformHeight_Pixels2HUD(float contentHeight)
           
protected  float calculateTransformWidth_Pixels2HUD(float contentWidth)
           
 int compareAbsZIndex(Widget widget2)
           
protected  void createShape()
           
 void detach()
          Removes the Widget from its Container.
 void drawAndUpdateWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
protected  void drawBackground(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
          Draws the Widget's background.
protected  void drawBorder(Border border, Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
           
protected abstract  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
protected  void drawWidgetAfterWidgetAssembler(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
          Draws the part of the Widget, that needs to be drawn after the WidgetAssembler.
protected  void drawWidgetContents(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
protected
<Tuple2f_ extends org.openmali.vecmath2.Tuple2f>
Tuple2f_
getAbsoluteLocationOnHUD_(Tuple2f_ buffer)
          Computes the absolute position of the given Widget on the HUD.
 float getAspect()
           
protected  Widget getAssembly()
           
 Border getBorder()
           
 WidgetContainer getContainer()
          The Container which contains this Widget
 float getContentAspect()
           
 float getContentHeight()
           
protected  int getContentHeightPX()
          Gets the height of the widget's content area (minus border and padding) (in pixels).
protected  int getContentLeftPX()
          Gets the left coordinate of where content (0, 0) is (in pixels).
protected
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getContentOffset(Dim2f_ buffer)
           
protected  int getContentTopPX()
          Gets the top coordinate of where content (0, 0) is (in pixels).
 float getContentWidth()
           
protected  int getContentWidthPX()
          Gets the width of the widget's content area (minus border and padding) (in pixels).
 ContextMenu getContextMenu()
           
 Cursor.Type getCursor()
           
protected  float getEqualHeight_(float width)
          Calculates a height that's visually equal to the given width.
protected  float getEqualWidth_(float height)
           
 float getForcedRedrawFrequency()
          Gets the forced frequency, at which a Widget is redrawn.
 float getHeight()
           
protected  int getHeightPX()
          Gets the height of the widget's area (in pixels).
 HUD getHUD()
           
 float getLeft()
           
protected  int getLevel()
           
 org.openmali.vecmath2.Tuple2f getLocation()
           
<Tuple2f_ extends org.openmali.vecmath2.Tuple2f>
Tuple2f_
getLocation(Tuple2f_ loc)
           
protected
<Tuple2i_ extends org.openmali.vecmath2.Tuple2i>
Tuple2i_
getLocationHUD2Pixels_(float x, float y, Tuple2i_ buffer)
          Calculates pixel location from these HUD-values.
protected
<Tuple2f_ extends org.openmali.vecmath2.Tuple2f>
Tuple2f_
getLocationHUD2SG_(float x, float y, Tuple2f_ buffer)
          Calculates scenegraph location from these HUD-values.
protected
<Tuple2f_ extends org.openmali.vecmath2.Tuple2f>
Tuple2f_
getLocationPixels2HUD_(int x, int y, Tuple2f_ buffer)
          Calculates HUD location from these pixel-values.
protected
<Tuple2f_ extends org.openmali.vecmath2.Tuple2f>
Tuple2f_
getLocationSG2HUD_(float x, float y, Tuple2f_ buffer)
          Calculates HUD location from these scenegraph-values.
static float getMaxRedrawFrequency()
          Gets the maximum frequency, at which a Widget can be redrawn.
protected  float getMinHeight()
           
protected  float getMinWidth()
           
 java.lang.String getName()
           
 Window getParentWindow()
          Gets, the Window, of which this is the content pane.
protected  float getPickHeight()
           
protected  float getPickWidth()
           
protected
<Tuple2i_ extends org.openmali.vecmath2.Tuple2i>
Tuple2i_
getRelLocationHUD2Pixels_(float x, float y, Tuple2i_ buffer)
          Calculates pixel size from these HUD-values.
protected  Widget getRootHostWidget()
          Returns the Widget, that this lightweight Widget draws on.
 Shape3D getShape()
          Returns the untilized Shape3D to display the Widget.
 org.openmali.types.twodee.Sized2fRO getSize()
           
protected
<Dim2i_ extends org.openmali.types.twodee.Dim2i>
Dim2i_
getSizeHUD2Pixels_(float x, float y, Dim2i_ buffer)
          Calculates pixel size from these HUD-values.
protected
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getSizeHUD2SG_(float x, float y, Dim2f_ buffer)
          Calculates scenegraph width and height from these HUD-values.
protected
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getSizeOfPixels_(int x, int y, Dim2f_ buffer)
          Retrieves the size these pixels have on this WidgetContainer.
protected
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getSizePixels2HUD_(int x, int y, Dim2f_ buffer)
          Calculates HUD size from these pixel-values.
protected
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getSizeSG2HUD_(float x, float y, Dim2f_ buffer)
          Calculates HUD size from these scenegraph-values.
 java.lang.String getToolTip()
           
 float getTop()
           
 float getTransparency()
          Gets the whole Widget's transparency.
 java.lang.Object getUserObject()
           
protected  WidgetAssembler getWidgetAssembler()
           
 float getWidth()
           
protected  int getWidthPX()
          Gets the width of the widget's area (in pixels).
 int getZIndex()
           
 boolean hasDropShadow()
          Gets, if this Widget has a drop shadow.
 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.
protected  void initSize()
           
protected  boolean isAHostedWidgetDirty()
           
 boolean isClickable()
           
 boolean isDraggable()
           
 boolean isFocussable()
           
 boolean isHeavyWeight()
          Returns true, if the widget has a TransformGroup and DrawTexture.
protected  boolean isHovered()
           
protected  boolean isInitialized()
          Has the init method been executed once?
protected  boolean isInitializing()
          Is the init method currently being executed?
 boolean isPickable()
           
protected  boolean isThisWidgetDirty()
           
 boolean isVisible()
           
protected  void notifyOnDragStopped()
          This method is called to notify all atteched WidgetLocationListeners about this event.
protected  void onAttachedToContainer(WidgetContainer container)
          This event is fired, when this Widget is added to a WidgetContainer.
protected  void onAttachedToHUD(HUD hud)
          This event is fired, when this Widget is added to the HUD live Widget hierarchy.
protected  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.
protected  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.
protected  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.
protected  void onDetachedFromContainer(WidgetContainer container)
          This event is fired, when this Widget is removed from a WidgetContainer.
protected  void onDetachedFromHUD(HUD hud)
          This event is fired, when this Widget is removed from the HUD live Widget hierarchy.
protected  void onFocusGained()
          This event is fired, when the focus is gained to a Widget.
protected  void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
protected  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.
protected  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.
protected  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.
protected  void onKeyTyped(char ch, int modifierMask, long when)
          This event is fired when a key is typed on the keyboard.
protected  void onLocationChanged(float oldLeft, float oldTop, float newLeft, float newTop)
           
protected  void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is pressed on a focused Widget.
protected  void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is released on a focused Widget.
protected  void onMouseEntered(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse entered the Widget area.
protected  void onMouseExited(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
protected  void onMouseMoved(float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
protected  void onMouseStopped(float x, float 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.
protected  void onMouseWheelMoved(int delta, boolean isPageMove, float x, float y, long when, boolean isTopMost)
          This event is fired, when the mouse wheel is moved on a Widget.
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
           
protected  void onVisibilityChanged(boolean visible)
          This method is triggered when the visibility state has eeffectively changed.
protected  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.
protected  boolean pickConditionsMatch(HUDPickResult.HUDPickReason pickReason)
           
 void removeContainerListener(WidgetContainerListener l)
          Removes a WidgetContainerListener.
 void removeControllerListener(WidgetControllerListener l)
          Removes a WidgetControllerListener.
 void removeFocusListener(WidgetFocusListener l)
          Removes a WidgetFocusListener.
 void removeInputListener(WidgetInputListener l)
          Removes a WidgetInputListener.
 void removeKeyboardListener(WidgetKeyboardListener l)
          Removes a WidgetKeyboardListener.
 void removeLocationListener(WidgetLocationListener l)
          Removes a WidgetFocusListener.
 void removeMouseListener(WidgetMouseListener l)
          Removes a WidgetMouseListener.
 void removeSizeListener(WidgetSizeListener l)
          Removes a WidgetSizeListener.
 void removeVisibilityListener(WidgetVisibilityListener l)
          Removes a WidgetVisibilityListener.
 void requestFocus()
          Requests the focus from the HUD system.
protected  void resetWidgetDirty()
           
 void setBorder(Border.Description borderDesc)
          Creates a new Border from the given Border.Desctiption and invokes setBorder(Border).
 void setBorder(Border border)
          Sets the Border to use for this BorderSettable Widget.
 void setClickable(boolean isClickable)
          Sets wheather this Widget is clickable.
protected  void setContentClipRect(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
           
 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 setForcedRedrawFrequency(float freq)
          Sets the forced frequency, at which a Widget is redrawn.
 void setHasDropShadow(boolean b)
          Sets, if this Widgets has a drop shadow.
 void setHeight(float height)
          
protected  void setHostedWidgetDirty()
           
protected  void setHostTextureDirty()
           
protected  void setHostTextureDirty(int flags)
           
protected  void setHostWidget(Widget widget)
           
 Widget 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, boolean needsTextureRefresh)
           
 Widget setLocation(org.openmali.vecmath2.Tuple2f loc)
          Sets this Widget's location relative to the upper-left corner of it's WidgetContainer
static void setMaxRedrawFrequency(float freq)
          Sets the maximum frequency, at which a Widget can be redrawn.
 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.
protected  boolean setSize(float width, float height, boolean forced)
           
 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.
protected  void setTextureDirty()
           
protected  void setTextureDirty(int flags)
           
 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.
protected  void setTransparency(float transparency, boolean childrenToo)
          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
protected  void setWidgetDirty()
           
 void setWidth(float width)
          
 void setZIndex(int zIndex)
          Sets the z-index of this Widget.
protected  void startDragging(int canvasX, int canvasY, float widgetX, float widgetY)
           
 java.lang.String toString()
          
 void update()
          Updates the Widget's internals.
protected  void updateAbsZIndex()
           
protected  void updateSizeFactors()
           
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
 

Field Detail

transformWidth_Pixels2HUD

protected float transformWidth_Pixels2HUD

transformHeight_Pixels2HUD

protected float transformHeight_Pixels2HUD
Constructor Detail

Widget

protected Widget(boolean isHeavyWeight,
                 boolean hasWidgetAssembler)
Creates a new Widget.

Parameters:
isHeavyWeight -
hasWidgetAssembler -

Widget

protected Widget(boolean isHeavyWeight,
                 boolean hasWidgetAssembler,
                 float width,
                 float height)
Creates a new Widget with the given width and height.

Parameters:
isHeavyWeight -
hasWidgetAssembler -
width - the new width of this Widget
height - the new height of this Widget
zIndex - the z-index of this Widget
Method Detail

isHeavyWeight

public final boolean isHeavyWeight()
Returns true, if the widget has a TransformGroup and DrawTexture.
Lightweight Widgets can only be use to add to heavyweight WidgetContainers or to containers, that are added to heavyweight containers, etc.

Returns:
is this Widget heavyweight or lightweight.

getParentWindow

public Window getParentWindow()
Gets, the Window, of which this is the content pane.

Returns:
the parent Window.

setName

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

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

getName

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

setUserObject

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

Parameters:
userObject - the new user-Object

getUserObject

public final java.lang.Object getUserObject()
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.

Parameters:
contextMenu -

getContextMenu

public ContextMenu getContextMenu()
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().

Parameters:
tooltip -

getToolTip

public final 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

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

setHasDropShadow

public void setHasDropShadow(boolean b)
Sets, if this Widgets has a drop shadow.

Parameters:
b -
See Also:
DropShadowFactory, HUD.setDropShadowFactory(DropShadowFactory), HUD.getDropShadowFactory()

hasDropShadow

public final boolean hasDropShadow()
Gets, if this Widget has a drop shadow.

Returns:
if this Widget has a drop shadow.
See Also:
DropShadowFactory, HUD.setDropShadowFactory(DropShadowFactory), HUD.getDropShadowFactory()

getWidgetAssembler

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

getEqualWidth_

protected final float getEqualWidth_(float height)
Parameters:
height - the height to calculate a visually equal height
Returns:
a width that's visually equal to the given height

getEqualHeight_

protected final float getEqualHeight_(float width)
Calculates a height that's visually equal to the given width.

Parameters:
width - the width to calculate a visually equal height
Returns:
the buffer back again

getSizePixels2HUD_

protected final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getSizePixels2HUD_(int x,
                                                                                           int y,
                                                                                           Dim2f_ buffer)
Calculates HUD size from these pixel-values.

Parameters:
x - the canvas-x-value to transform
y - the canvas-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getLocationPixels2HUD_

protected final <Tuple2f_ extends org.openmali.vecmath2.Tuple2f> Tuple2f_ getLocationPixels2HUD_(int x,
                                                                                                 int y,
                                                                                                 Tuple2f_ buffer)
Calculates HUD location from these pixel-values.

Parameters:
x - the canvas-x-value to transform
y - the canvas-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getSizeHUD2Pixels_

protected final <Dim2i_ extends org.openmali.types.twodee.Dim2i> Dim2i_ getSizeHUD2Pixels_(float x,
                                                                                           float y,
                                                                                           Dim2i_ buffer)
Calculates pixel size from these HUD-values.

Parameters:
x - the HUD-x-value to transform
y - the HUD-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getRelLocationHUD2Pixels_

protected final <Tuple2i_ extends org.openmali.vecmath2.Tuple2i> Tuple2i_ getRelLocationHUD2Pixels_(float x,
                                                                                                    float y,
                                                                                                    Tuple2i_ buffer)
Calculates pixel size from these HUD-values.

Parameters:
x - the HUD-x-value to transform
y - the HUD-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getLocationHUD2Pixels_

protected final <Tuple2i_ extends org.openmali.vecmath2.Tuple2i> Tuple2i_ getLocationHUD2Pixels_(float x,
                                                                                                 float y,
                                                                                                 Tuple2i_ buffer)
Calculates pixel location from these HUD-values.

Parameters:
x - the HUD-x-value to transform
y - the HUD-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getSizeHUD2SG_

protected final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getSizeHUD2SG_(float x,
                                                                                       float y,
                                                                                       Dim2f_ buffer)
Calculates scenegraph width and height from these HUD-values.

Parameters:
x - the HUD-x-value to transform
y - the HUD-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getLocationHUD2SG_

protected final <Tuple2f_ extends org.openmali.vecmath2.Tuple2f> Tuple2f_ getLocationHUD2SG_(float x,
                                                                                             float y,
                                                                                             Tuple2f_ buffer)
Calculates scenegraph location from these HUD-values.

Parameters:
x - the HUD-x-value to transform
y - the HUD-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getSizeSG2HUD_

protected final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getSizeSG2HUD_(float x,
                                                                                       float y,
                                                                                       Dim2f_ buffer)
Calculates HUD size from these scenegraph-values.

Parameters:
x - the scenegraph-x-value to transform
y - the scenegraph-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getLocationSG2HUD_

protected final <Tuple2f_ extends org.openmali.vecmath2.Tuple2f> Tuple2f_ getLocationSG2HUD_(float x,
                                                                                             float y,
                                                                                             Tuple2f_ buffer)
Calculates HUD location from these scenegraph-values.

Parameters:
x - the scenegraph-x-value to transform
y - the scenegraph-y-value to transform
buffer - the buffer to write the values to
Returns:
the buffer back again

getSizeOfPixels_

protected final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getSizeOfPixels_(int x,
                                                                                         int y,
                                                                                         Dim2f_ buffer)
Retrieves the size these pixels have on this WidgetContainer.

Parameters:
x - the x-count of pixels
y - the y-count of pixels
buffer - the buffer to write the values to
Returns:
the buffer back again

getAbsoluteLocationOnHUD_

protected final <Tuple2f_ extends org.openmali.vecmath2.Tuple2f> Tuple2f_ getAbsoluteLocationOnHUD_(Tuple2f_ buffer)
Computes the absolute position of the given Widget on the HUD.

Parameters:
buffer -

addKeyboardListener

public void addKeyboardListener(WidgetKeyboardListener l)
Adds a new WidgetKeyboardListener.

Parameters:
l -

removeKeyboardListener

public void removeKeyboardListener(WidgetKeyboardListener l)
Removes a WidgetKeyboardListener.

Parameters:
l -

addMouseListener

public void addMouseListener(WidgetMouseListener l)
Adds a new WidgetMouseListener.

Parameters:
l -

removeMouseListener

public void removeMouseListener(WidgetMouseListener l)
Removes a WidgetMouseListener.

Parameters:
l -

addControllerListener

public void addControllerListener(WidgetControllerListener l)
Adds a new WidgetControllerListener.

Parameters:
l -

removeControllerListener

public void removeControllerListener(WidgetControllerListener l)
Removes a WidgetControllerListener.

Parameters:
l -

addInputListener

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

Parameters:
l -

removeInputListener

public final void removeInputListener(WidgetInputListener l)
Removes a WidgetInputListener.

Parameters:
l -

addFocusListener

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

Parameters:
l -

removeFocusListener

public void removeFocusListener(WidgetFocusListener l)
Removes a WidgetFocusListener.

Parameters:
l -

addLocationListener

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

Parameters:
l -

removeLocationListener

public void removeLocationListener(WidgetLocationListener l)
Removes a WidgetFocusListener.

Parameters:
l -

addSizeListener

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

Parameters:
l -

removeSizeListener

public void removeSizeListener(WidgetSizeListener l)
Removes a WidgetSizeListener.

Parameters:
l -

addVisibilityListener

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

Parameters:
l -

removeVisibilityListener

public void removeVisibilityListener(WidgetVisibilityListener l)
Removes a WidgetVisibilityListener.

Parameters:
l -

addContainerListener

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

Parameters:
l -

removeContainerListener

public void removeContainerListener(WidgetContainerListener l)
Removes a WidgetContainerListener.

Parameters:
l -

setFocussable

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

Parameters:
focussable -

isFocussable

public final boolean isFocussable()
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.


onFocusGained

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


onFocusLost

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


hasFocus

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

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

hasFocus

public final boolean hasFocus()
Is this Widget focused?


blocksFocusMoveDeviceComponent

protected boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
Checks, if this Widget blocks the given DeviceComponent for focus-moves.

Parameters:
dc -
Returns:
Widget blocks the queried DeviceComponent?

bindToGlobalMouseMovement

protected final void bindToGlobalMouseMovement()

onMouseEntered

protected 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

onMouseExited

protected void onMouseExited(boolean isTopMost,
                             boolean hasFocus)
This method is called when the mouse exited the Widget area.

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

startDragging

protected void startDragging(int canvasX,
                             int canvasY,
                             float widgetX,
                             float widgetY)
Parameters:
canvasX -
canvasY -
widgetX -
widgetY -

onMouseButtonPressed

protected void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button,
                                    float x,
                                    float 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

notifyOnDragStopped

protected void notifyOnDragStopped()
This method is called to notify all atteched WidgetLocationListeners about this event.


onMouseButtonReleased

protected void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button,
                                     float x,
                                     float 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

protected void onMouseMoved(float x,
                            float 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

protected void onMouseStopped(float x,
                              float 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

protected void onMouseWheelMoved(int delta,
                                 boolean isPageMove,
                                 float x,
                                 float 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

onKeyPressed

protected 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

protected 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

protected 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

protected 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 - the gameTime of the event

onControllerButtonReleased

protected 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 - the gameTime of the event

onControllerAxisChanged

protected 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 - the gameTime of the event

onInputStateChanged

protected 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 - the gameTime of the event
isTopMost -
hasFocus -

isHovered

protected final boolean isHovered()

onVisibilityChanged

protected void onVisibilityChanged(boolean visible)
This method is triggered when the visibility state has eeffectively changed.

Parameters:
visible -

setVisible

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

Parameters:
visible - visible?

isVisible

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

setTransparency

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

Parameters:
transparency -
childrenToo -

setTransparency

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

Parameters:
transparency -

getTransparency

public final float getTransparency()
Gets the whole Widget's transparency.

Returns:
the transparency.

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.


isClickable

public final 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.

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.


isDraggable

public final boolean isDraggable()
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.


isPickable

public final boolean isPickable()
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.

Parameters:
cursor -

getCursor

public final 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.

setBorder

public void setBorder(Border border)
Sets the Border to use for this BorderSettable Widget.

Parameters:
border - the new Border (null for no border)

setBorder

public final void setBorder(Border.Description borderDesc)
Creates a new Border from the given Border.Desctiption and invokes setBorder(Border).

Parameters:
borderDesc - the Border.Description to create the new Border from (null for no border)
See Also:
setBorder(Border)

getBorder

public final Border getBorder()
Returns:
the Border used for this BorderSettable Widget

getContentLeftPX

protected int getContentLeftPX()
Gets the left coordinate of where content (0, 0) is (in pixels).

Returns:
the content left.

getContentTopPX

protected int getContentTopPX()
Gets the top coordinate of where content (0, 0) is (in pixels).

Returns:
the content left.

getContentOffset

protected final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getContentOffset(Dim2f_ buffer)

getContentWidthPX

protected int getContentWidthPX()
Gets the width of the widget's content area (minus border and padding) (in pixels).

Returns:
the content width.

getContentHeightPX

protected int getContentHeightPX()
Gets the height of the widget's content area (minus border and padding) (in pixels).

Returns:
the content width.

getContentWidth

public final float getContentWidth()
Returns:
the width without the Border (if any) and padding

getContentHeight

public final float getContentHeight()
Returns:
the height without the Border (if any) and padding

getContentAspect

public final float getContentAspect()
Returns:
the aspect ratio of the inner size

getLevel

protected final int getLevel()

update

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


updateAbsZIndex

protected void updateAbsZIndex()

calculateTransformWidth_Pixels2HUD

protected float calculateTransformWidth_Pixels2HUD(float contentWidth)
Parameters:
contentWidth -

calculateTransformHeight_Pixels2HUD

protected float calculateTransformHeight_Pixels2HUD(float contentHeight)
Parameters:
contentHeight -

updateSizeFactors

protected void updateSizeFactors()

updateTranslation

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


onLocationChanged

protected void onLocationChanged(float oldLeft,
                                 float oldTop,
                                 float newLeft,
                                 float newTop)
Parameters:
oldLeft -
oldTop -
newLeft -
newTop -

setLocation

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

setLocation

public final 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

public final 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

public final 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

getLocation

public <Tuple2f_ extends org.openmali.vecmath2.Tuple2f> Tuple2f_ getLocation(Tuple2f_ loc)
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

public final 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

public final 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

getMinWidth

protected float getMinWidth()

getMinHeight

protected float getMinHeight()

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)
Parameters:
oldWidth -
oldHeight -
newWidth -
newHeight -

setSize

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

setSize

public final 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

public final 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

public final 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

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

getWidth

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

getWidthPX

protected final int getWidthPX()
Gets the width of the widget's area (in pixels).

Returns:
the width.

getHeight

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

getHeightPX

protected final int getHeightPX()
Gets the height of the widget's area (in pixels).

Returns:
the width.

getSize

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

getAspect

public final float getAspect()
Specified by:
getAspect in interface org.openmali.types.twodee.Sized2fRO
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.


getZIndex

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

compareAbsZIndex

public final int compareAbsZIndex(Widget widget2)

getPickWidth

protected float getPickWidth()
Returns:
the width on which to pick. By default this is exactly getWidth().

getPickHeight

protected float getPickHeight()
Returns:
the height on which to pick. By default this is exactly getHeight().

pickConditionsMatch

protected boolean pickConditionsMatch(HUDPickResult.HUDPickReason pickReason)

pick

protected 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.

isInitializing

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


isInitialized

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


initSize

protected void initSize()

createShape

protected void createShape()

init

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


onAttachedToHUD

protected void onAttachedToHUD(HUD hud)
This event is fired, when this Widget is added to the HUD live Widget hierarchy.

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

onDetachedFromHUD

protected void onDetachedFromHUD(HUD hud)
This event is fired, when this Widget is removed from the HUD live Widget hierarchy.

Parameters:
hud - the HUD, the Widget is removed from

getHUD

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

onAttachedToContainer

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

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

onDetachedFromContainer

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

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

getContainer

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


getAssembly

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

detach

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


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getShape

public Shape3D getShape()
Returns the untilized Shape3D to display the Widget.
For most widget types, this will be a DrawRectangle.
If this Widget is lightweight, this method will return null.

Returns:
the untilized Shape3D to display the Widget.

setHostWidget

protected void setHostWidget(Widget widget)

getRootHostWidget

protected final Widget getRootHostWidget()
Returns the Widget, that this lightweight Widget draws on.

Returns:
the host Widget.

setHostedWidgetDirty

protected void setHostedWidgetDirty()

setWidgetDirty

protected void setWidgetDirty()

resetWidgetDirty

protected void resetWidgetDirty()

isThisWidgetDirty

protected final boolean isThisWidgetDirty()

isAHostedWidgetDirty

protected final boolean isAHostedWidgetDirty()

setHostTextureDirty

protected void setHostTextureDirty(int flags)
Parameters:
flags -

setHostTextureDirty

protected final void setHostTextureDirty()

setTextureDirty

protected void setTextureDirty(int flags)
Parameters:
flags -

setTextureDirty

protected final void setTextureDirty()

drawBackground

protected void drawBackground(Texture2DCanvas texCanvas,
                              int offsetX,
                              int offsetY,
                              int width,
                              int height)
Draws the Widget's background.

Parameters:
texCanvas -
offsetX -
offsetY -
width -
height -
needsClearForNullBackground -

drawWidget

protected abstract void drawWidget(Texture2DCanvas texCanvas,
                                   int offsetX,
                                   int offsetY,
                                   int width,
                                   int height,
                                   boolean drawsSelf)
Parameters:
texCanvas -
offsetX -
offsetY -
width -
height -
drawsSelf -

drawWidgetAfterWidgetAssembler

protected void drawWidgetAfterWidgetAssembler(Texture2DCanvas texCanvas,
                                              int offsetX,
                                              int offsetY,
                                              int width,
                                              int height,
                                              boolean drawsSelf)
Draws the part of the Widget, that needs to be drawn after the WidgetAssembler.

Parameters:
texCanvas -
offsetX -
offsetY -
width -
height -
drawsSelf -

drawBorder

protected void drawBorder(Border border,
                          Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height)

setContentClipRect

protected void setContentClipRect(Texture2DCanvas texCanvas,
                                  int offsetX,
                                  int offsetY,
                                  int width,
                                  int height)

drawWidgetContents

protected void drawWidgetContents(Texture2DCanvas texCanvas,
                                  int offsetX,
                                  int offsetY,
                                  int width,
                                  int height,
                                  boolean drawsSelf)

drawAndUpdateWidget

public void drawAndUpdateWidget(Texture2DCanvas texCanvas,
                                int offsetX,
                                int offsetY,
                                int width,
                                int height,
                                boolean drawsSelf)

setMaxRedrawFrequency

public static final void setMaxRedrawFrequency(float freq)
Sets the maximum frequency, at which a Widget can be redrawn.

Parameters:
freq - frequency in Hz

getMaxRedrawFrequency

public static final float getMaxRedrawFrequency()
Gets the maximum frequency, at which a Widget can be redrawn.

Returns:
the frequency in Hz.

setForcedRedrawFrequency

public void setForcedRedrawFrequency(float freq)
Sets the forced frequency, at which a Widget is redrawn.

Parameters:
freq - frequency in Hz (-1 for off)

getForcedRedrawFrequency

public final float getForcedRedrawFrequency()
Gets the forced frequency, at which a Widget is redrawn.

Returns:
the frequency in Hz (-1 for off).