org.xith3d.ui.hud.base
Class StateButton

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.StateButton
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
Direct Known Subclasses:
LabeledStateButton

public abstract class StateButton
extends Widget
implements org.jagatoo.datatypes.Enableable

This class is a base for all state capable Buttons on a HUD. You can add WidgetActionListeners to it to get notified of a click event.

See Also:
WidgetStateListener

Nested Class Summary
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
StateButton(boolean isHeavyWeight, boolean hasWidgetAssembler, float width, float height)
          Creates a new StateButton.
 
Method Summary
 void addStateListener(WidgetStateListener listener)
          Add a StateListener
protected  void cycleState()
           
 boolean getState()
           
 ButtonGroup getStateGroup()
           
 boolean isEnabled()
          
protected  void notifyListeners()
          Notifies all added listeners about a state event
protected abstract  void onExtendedStateChanged(boolean state, boolean hovered)
           
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 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.
 void removeStateListener(WidgetStateListener listener)
          Remove a StateListener
 void setEnabled(boolean enabled)
          
protected abstract  void setEnabledImpl(boolean enabled)
           
 void setState(boolean state)
          Sets the current state of this StateButton
 void setStateGroup(ButtonGroup sg)
          Assotiates this StateButton with a StateGroup
 
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, drawWidget, drawWidgetAfterWidgetAssembler, 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, init, initSize, 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, onSizeChanged, 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
 

Constructor Detail

StateButton

public StateButton(boolean isHeavyWeight,
                   boolean hasWidgetAssembler,
                   float width,
                   float height)
Creates a new StateButton.

Parameters:
isHeavyWeight -
hasWidgetAssembler -
width - the desired width
height - the desired height
Method Detail

setStateGroup

public void setStateGroup(ButtonGroup sg)
Assotiates this StateButton with a StateGroup

Parameters:
sg - the StateGroup to assotiate this StateButton with

getStateGroup

public final ButtonGroup getStateGroup()
Returns:
the StateGroup this StateButton is assotiated with

notifyListeners

protected final void notifyListeners()
Notifies all added listeners about a state event


onExtendedStateChanged

protected abstract void onExtendedStateChanged(boolean state,
                                               boolean hovered)

setState

public void setState(boolean state)
Sets the current state of this StateButton

Parameters:
state -

getState

public final boolean getState()
Returns:
the current state of this StateButton

onMouseEntered

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

Overrides:
onMouseEntered in class Widget
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.

Overrides:
onMouseExited in class Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

cycleState

protected void cycleState()

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.

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

addStateListener

public void addStateListener(WidgetStateListener listener)
Add a StateListener


removeStateListener

public void removeStateListener(WidgetStateListener listener)
Remove a StateListener


setEnabledImpl

protected abstract void setEnabledImpl(boolean enabled)

setEnabled

public final void setEnabled(boolean enabled)

Specified by:
setEnabled in interface org.jagatoo.datatypes.Enableable

isEnabled

public final boolean isEnabled()

Specified by:
isEnabled in interface org.jagatoo.datatypes.Enableable