org.xith3d.ui.hud.base
Class AbstractButton

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.AbstractButton
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:
Button

public abstract class AbstractButton
extends RectangularWidget
implements org.jagatoo.datatypes.Enableable

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

See Also:
ButtonListener

Nested Class Summary
static class AbstractButton.ButtonState
           
 
Nested classes/interfaces inherited from interface org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
protected  AbstractButton.ButtonState buttonState
           
protected  boolean isStateChangable
           
 
Fields inherited from class org.xith3d.ui.hud.base.WidgetBase
containerListeners, transformGroup, translation, Z_INDEX_UNIT, Z_INDEX_UNIT_ASSEMBLER
 
Constructor Summary
AbstractButton(float width, float height)
          Creates a new Button for the HUD.
AbstractButton(float width, float height, int zIndex)
          Creates a new Button for the HUD.
 
Method Summary
 void addButtonListener(ButtonListener l)
          Adds a ButtonListener.
protected  void fireButtonClickedEvent()
           
 AbstractButton.ButtonState getButtonState()
           
 boolean isEnabled()
          
 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 removeButtonListener(ButtonListener l)
          Removes a ButtonListener.
 void setEnabled(boolean enabled)
          
protected abstract  void setEnabledImpl(boolean enabled)
           
 
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, 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
 

Field Detail

buttonState

protected AbstractButton.ButtonState buttonState

isStateChangable

protected boolean isStateChangable
Constructor Detail

AbstractButton

public AbstractButton(float width,
                      float height,
                      int zIndex)
Creates a new Button for the HUD.

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

AbstractButton

public AbstractButton(float width,
                      float height)
Creates a new Button for the HUD.

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

addButtonListener

public void addButtonListener(ButtonListener l)
Adds a ButtonListener.


removeButtonListener

public void removeButtonListener(ButtonListener l)
Removes a ButtonListener.


fireButtonClickedEvent

protected void fireButtonClickedEvent()

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

getButtonState

public AbstractButton.ButtonState getButtonState()
Returns:
the current ButtonState of this Button

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

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

onMouseButtonReleased

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

Specified by:
onMouseButtonReleased in interface Widget
Overrides:
onMouseButtonReleased in class WidgetBase
Parameters:
button - the button that was released
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