org.xith3d.ui.hud.base
Class LabeledStateButton

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.StateButton
          extended by org.xith3d.ui.hud.base.LabeledStateButton
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, 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, AutoSizable, TextWidget
Direct Known Subclasses:
Checkbox, RadioButton

public abstract class LabeledStateButton
extends StateButton
implements TextWidget, AutoSizable

This class serves as a base for all StateButtons with an Image and a Label.


Nested Class Summary
static class LabeledStateButton.Description
          This class is used to describe a LabeledStateButton Widget.
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
protected static boolean DEFAULT_HEAVYWEIGHT
           
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
LabeledStateButton(boolean isHeavyWeight, float width, float height, java.lang.String text, LabeledStateButton.Description desc)
          Creates a new LabeledStateButton
 
Method Summary
protected  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.
 TextAlignment getAlignment()
          
 org.openmali.vecmath2.Colorf getBackgroundColor()
           
 Texture2D getBackgroundTexture()
           
 TileMode getBackgroundTileMode()
           
 HUDFont getFont()
          
 org.openmali.vecmath2.Colorf getFontColor()
          
 org.openmali.vecmath2.Colorf getFontColorDisabled()
          
 HUDFont getFontDisabled()
          
 float getMinimalHeight()
          Gets the state-button's minimum height.
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getMinimalSize(Dim2f_ buffer)
          Gets the state-button's minimum size.
 float getMinimalWidth()
          Gets the state-button's minimum width.
 java.lang.String getText()
          
protected  void init()
          This method is called when the WidgetContainer is set.
protected  void initSize()
          
 boolean isAutoSizeEnabled()
           
protected  boolean isMouseOverStateImage(float mouseX, float mouseY)
           
protected  void onExtendedStateChanged(boolean state, boolean hovered)
          
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
          
 void setAlignment(TextAlignment alignment)
          Sets the horizontal and vertical alignment of the text
 void setAutoSizeEnabled(boolean enabled)
          Enables or disables auto-sizing.
 void setBackground(org.openmali.vecmath2.Colorf color, java.lang.String texture)
          Sets background color and texture at once.
 void setBackground(org.openmali.vecmath2.Colorf color, Texture2D texture, TileMode tileMode)
          Sets background color and texture at once.
 void setBackgroundColor(org.openmali.vecmath2.Colorf color)
          Sets the background color of the Widget.
 void setBackgroundTexture(java.lang.String texture)
          Sets the background Texture of the Widget.
 void setBackgroundTexture(Texture2D texture)
          Sets the background texture of the Widget.
 void setBackgroundTileMode(TileMode mode)
          Sets the background tile mode (null for no tiling)
protected  void setEnabledImpl(boolean enabled)
          
 void setFont(HUDFont font)
          Sets the new Font to be used
 void setFontColor(org.openmali.vecmath2.Colorf color)
          Sets the new color to be used
 void setFontColorDisabled(org.openmali.vecmath2.Colorf color)
          
 void setFontDisabled(HUDFont font)
          
 void setMinimalSize()
          Resizes this LabeledStateButton to the minimum Size needed to contain the whole caption.
 void setNoBackground()
          Sets background color and texture to nothing at once.
 void setText(java.lang.String text)
          Sets the new text to be displayed
 
Methods inherited from class org.xith3d.ui.hud.base.StateButton
addStateListener, cycleState, getState, getStateGroup, isEnabled, notifyListeners, onMouseButtonPressed, onMouseEntered, onMouseExited, removeStateListener, setEnabled, setState, setStateGroup
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, blocksFocusMoveDeviceComponent, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBackground, drawBorder, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getMinHeight, getMinWidth, getName, getParentWindow, getPickHeight, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onAttachedToHUD, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onDetachedFromHUD, onFocusGained, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, onMouseButtonReleased, onMouseMoved, onMouseStopped, onMouseWheelMoved, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, toString, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_HEAVYWEIGHT

protected static final boolean DEFAULT_HEAVYWEIGHT
See Also:
Constant Field Values
Constructor Detail

LabeledStateButton

public LabeledStateButton(boolean isHeavyWeight,
                          float width,
                          float height,
                          java.lang.String text,
                          LabeledStateButton.Description desc)
Creates a new LabeledStateButton

Parameters:
isHeavyWeight -
width - the desired width
height - the desired height
desc - the Description object for this Widget
text - the text to be displayed
Method Detail

setBackgroundColor

public void setBackgroundColor(org.openmali.vecmath2.Colorf color)
Sets the background color of the Widget.

Parameters:
color - the color to use

getBackgroundColor

public final org.openmali.vecmath2.Colorf getBackgroundColor()
Returns:
the background color of the Widget.

setBackgroundTexture

public void setBackgroundTexture(Texture2D texture)
Sets the background texture of the Widget.

Parameters:
texture - the texture resource to use

setBackgroundTexture

public void setBackgroundTexture(java.lang.String texture)
Sets the background Texture of the Widget.

Parameters:
texture - the texture resource to use

setBackground

public final void setBackground(org.openmali.vecmath2.Colorf color,
                                Texture2D texture,
                                TileMode tileMode)
Sets background color and texture at once.

Parameters:
color -
texture -
tileMode -

setBackground

public final void setBackground(org.openmali.vecmath2.Colorf color,
                                java.lang.String texture)
Sets background color and texture at once.

Parameters:
color -
texture -

setNoBackground

public final void setNoBackground()
Sets background color and texture to nothing at once.


getBackgroundTexture

public final Texture2D getBackgroundTexture()
Returns:
the background Texture of the Widget.

setBackgroundTileMode

public void setBackgroundTileMode(TileMode mode)
Sets the background tile mode (null for no tiling)

Parameters:
mode -

getBackgroundTileMode

public final TileMode getBackgroundTileMode()
Returns:
the background tile mode (null for no tiling).

setText

public void setText(java.lang.String text)
Sets the new text to be displayed

Specified by:
setText in interface TextWidget
Parameters:
text - the new Text

getText

public final java.lang.String getText()

Specified by:
getText in interface TextWidget
Returns:
the text that is displayed

setAlignment

public void setAlignment(TextAlignment alignment)
Sets the horizontal and vertical alignment of the text

Specified by:
setAlignment in interface TextWidget

getAlignment

public final TextAlignment getAlignment()

Specified by:
getAlignment in interface TextWidget
Returns:
the horizontal and vertical alignment of the text

setFont

public void setFont(HUDFont font)
Sets the new Font to be used

Specified by:
setFont in interface TextWidget
Parameters:
font - the new Font

getFont

public final HUDFont getFont()

Specified by:
getFont in interface TextWidget
Returns:
the used Font

setFontDisabled

public void setFontDisabled(HUDFont font)


getFontDisabled

public final HUDFont getFontDisabled()


setFontColor

public void setFontColor(org.openmali.vecmath2.Colorf color)
Sets the new color to be used

Specified by:
setFontColor in interface TextWidget
Parameters:
color - the new color

getFontColor

public final org.openmali.vecmath2.Colorf getFontColor()

Specified by:
getFontColor in interface TextWidget
Returns:
the used color

setFontColorDisabled

public void setFontColorDisabled(org.openmali.vecmath2.Colorf color)


getFontColorDisabled

public final org.openmali.vecmath2.Colorf getFontColorDisabled()


setEnabledImpl

protected void setEnabledImpl(boolean enabled)

Specified by:
setEnabledImpl in class StateButton

onExtendedStateChanged

protected void onExtendedStateChanged(boolean state,
                                      boolean hovered)

Specified by:
onExtendedStateChanged in class StateButton

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)

Overrides:
onSizeChanged in class Widget

setAutoSizeEnabled

public void setAutoSizeEnabled(boolean enabled)
Enables or disables auto-sizing.
If enabled, the Label's size will always be the minimal size to wrap the whole text content.

Specified by:
setAutoSizeEnabled in interface AutoSizable
Parameters:
enabled -

isAutoSizeEnabled

public final boolean isAutoSizeEnabled()
Specified by:
isAutoSizeEnabled in interface AutoSizable
Returns:
if auto-sizing is enabled.
If enabled, the Label's size will always be the minimal size to wrap the whole text content.

getMinimalSize

public final <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getMinimalSize(Dim2f_ buffer)
Gets the state-button's minimum size.

Specified by:
getMinimalSize in interface AutoSizable
Returns:
the buffer back again.

setMinimalSize

public final void setMinimalSize()
Resizes this LabeledStateButton to the minimum Size needed to contain the whole caption.

Specified by:
setMinimalSize in interface AutoSizable

getMinimalWidth

public final float getMinimalWidth()
Gets the state-button's minimum width.

Specified by:
getMinimalWidth in interface AutoSizable
Returns:
the minimum width.

getMinimalHeight

public final float getMinimalHeight()
Gets the state-button's minimum height.

Specified by:
getMinimalHeight in interface AutoSizable
Returns:
the minimum height.

isMouseOverStateImage

protected boolean isMouseOverStateImage(float mouseX,
                                        float mouseY)

drawWidget

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

Specified by:
drawWidget in class Widget

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.

Overrides:
drawWidgetAfterWidgetAssembler in class Widget

initSize

protected void initSize()

Overrides:
initSize in class Widget

init

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

Specified by:
init in class Widget