org.xith3d.ui.hud.base
Class StateButton

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

public abstract class StateButton
extends RectangularWidget
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
static class StateButton.State
          All states of a StateButton
 
Nested classes/interfaces inherited from interface org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.WidgetBase
containerListeners, transformGroup, translation, Z_INDEX_UNIT, Z_INDEX_UNIT_ASSEMBLER
 
Constructor Summary
StateButton(float width, float height)
          Creates a new StateButton
StateButton(float width, float height, int zIndex)
          Creates a new StateButton
 
Method Summary
 void addStateListener(WidgetStateListener listener)
          Add a StateListener
protected  void cycleState()
           
 boolean getBooleanState()
           
 StateButton.State getState()
           
 ButtonGroup getStateGroup()
           
 boolean isEnabled()
          
protected  void notifyListeners()
          Notifies all added listeners about a state event
 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 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
protected abstract  void onStateChanged(StateButton.State state)
           
 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 setState(StateButton.State 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.RectangularWidget
getPickHeight, getPickSGZPosition, getPickWidth, pick
 
Methods inherited from class org.xith3d.ui.hud.base.WidgetBase
addContainerListener, addFocusListener, addInputListener, addLocationListener, addSizeListener, addVisibilityListener, detach, detach, getAspect, getAssembly, getCachedToolTipWidget, getContainer, getContextMenu, getCursor, getHeight, getHUD, getInheritedCursor, getLeft, getLocation, getName, getSGNode, getSGZPosition, getSize, getToolTip, getTop, getUserObject, getWidgetAssembler, getWidth, getZIndex, hasFocus, hasFocus, hasToolTip, init, isClickable, isDraggable, isFocussable, isInitialized, isInitializing, isPickable, isVisible, onAddedToContainer, onAddedToHUD, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetached, onFocusGained, onFocusLost, onInputStateChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseButtonReleased, onMouseMoved, onMouseStopped, onMouseUnbound, onMouseWheelMoved, onRemovedFromContainer, pickWidgetAssembler, removeContainerListener, removeFocusListener, removeInputListener, removeLocationListener, removeSizeListener, removeVisibilityListener, requestFocus, setAssembly, setCachedToolTipWidget, setClickable, setContainer, setContextMenu, setCursor, setDraggable, setFocussable, setHeight, setLocation, setLocation, setLocation, setName, setPickable, setSize, setSize, setSize, setSize, setToolTip, setTransparency, setUserObject, setVisible, setWidth, setZIndex, toString, update, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xith3d.ui.hud.base.Widget
getTransparency
 

Constructor Detail

StateButton

public StateButton(float width,
                   float height,
                   int zIndex)
Creates a new StateButton

Parameters:
width - the desired width
height - the desired height
zIndex - the desired z-index

StateButton

public StateButton(float width,
                   float height)
Creates a new StateButton

Parameters:
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


onStateChanged

protected abstract void onStateChanged(StateButton.State state)

setState

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

Parameters:
state -

getState

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

setState

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

Parameters:
state -

getBooleanState

public final boolean getBooleanState()
Returns:
the current boolean state.

onMouseEntered

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

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

onMouseLeft

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

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

cycleState

protected void cycleState()

onMouseButtonPressed

public void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button,
                                 int x,
                                 int y,
                                 long when,
                                 long lastWhen,
                                 boolean isTopMost,
                                 boolean hasFocus)
This event is fired, when a mouse button is pressed on a focused Widget.

Specified by:
onMouseButtonPressed in interface Widget
Overrides:
onMouseButtonPressed in class WidgetBase
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