org.xith3d.ui.hud.base
Class AbstractButton

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

public abstract class AbstractButton
extends Widget
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 class 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.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
AbstractButton(boolean isHeavyWeight, boolean hasWidgetAssembler, float width, float height)
          Creates a new Button for the HUD.
 
Method Summary
 void addButtonListener(ButtonListener l)
          Adds a ButtonListener.
static void bindAccessor(org.jagatoo.input.devices.components.DeviceComponent comp)
          Binds a DeviceComponent to ALL Buttons, that works as an accessor.
protected  void fireButtonClickedEvent()
           
 AbstractButton.ButtonState getButtonState()
           
abstract
<Dim2f_ extends org.openmali.types.twodee.Dim2f>
Dim2f_
getOptimalSize(Dim2f_ buffer)
          Calculates implementation dependent optimal size for this Button.
static boolean isDefaultFocusResponsive()
           
 boolean isEnabled()
          
 boolean isFocusResponsive()
           
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 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.
 void removeButtonListener(ButtonListener l)
          Removes a ButtonListener.
 boolean setButtonState(AbstractButton.ButtonState buttonState)
          Sets the new AbstractButton.ButtonState for this Button.
static void setDefaultFocusResponsive(boolean resp)
          Sets whether the Button Widget is focus-responsive by default.
 void setEnabled(boolean enabled)
          
protected abstract  void setEnabledImpl(boolean enabled)
           
 void setFocusResponsive(boolean resp)
          Sets whether this Button Widget is focus-responsive.
static void unbindAccessor(org.jagatoo.input.devices.components.DeviceComponent comp)
          Unbinds a DeviceComponent from ALL Buttons.
 
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, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, 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
 

Field Detail

buttonState

protected AbstractButton.ButtonState buttonState

isStateChangable

protected boolean isStateChangable
Constructor Detail

AbstractButton

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

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

setDefaultFocusResponsive

public static final void setDefaultFocusResponsive(boolean resp)
Sets whether the Button Widget is focus-responsive by default.

Parameters:
resp -
See Also:
setFocusResponsive(boolean)

isDefaultFocusResponsive

public static final boolean isDefaultFocusResponsive()
Returns:
whether the Button Widget is focus-responsive by default.
See Also:
isFocusResponsive()

setFocusResponsive

public final void setFocusResponsive(boolean resp)
Sets whether this Button Widget is focus-responsive. This means, that it displays the HOVERED-state-picture when it holds the focus.

Parameters:
resp -
See Also:
isFocusResponsive(), setDefaultFocusResponsive(boolean), isDefaultFocusResponsive()

isFocusResponsive

public final boolean isFocusResponsive()
Returns:
whether this Button Widget is focus-responsive. This means, that it displays the HOVERED-state-picture when it holds the focus.
See Also:
setFocusResponsive(boolean), setDefaultFocusResponsive(boolean), isDefaultFocusResponsive()

bindAccessor

public static void bindAccessor(org.jagatoo.input.devices.components.DeviceComponent comp)
Binds a DeviceComponent to ALL Buttons, that works as an accessor. This means, that a focussed Button is pressed on a positive state-change on this DeviceComponent.

Parameters:
comp -

unbindAccessor

public static void unbindAccessor(org.jagatoo.input.devices.components.DeviceComponent comp)
Unbinds a DeviceComponent from ALL Buttons.

Parameters:
comp -

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

setButtonState

public boolean setButtonState(AbstractButton.ButtonState buttonState)
Sets the new AbstractButton.ButtonState for this Button.

Parameters:
buttonState -
Returns:
has state changed?

getButtonState

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

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

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

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.

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

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.

Overrides:
onInputStateChanged in class Widget
when - the gameTime of the event

getOptimalSize

public abstract <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getOptimalSize(Dim2f_ buffer)
Calculates implementation dependent optimal size for this Button.

Parameters:
buffer -
Returns:
the buffer back again.