org.xith3d.ui.hud.widgets
Class Slider

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.widgets.Slider
All Implemented Interfaces:
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

public class Slider
extends Widget

A simple Slider implementation used to select a certain value from a range.


Nested Class Summary
static class Slider.Description
          This class is used to describe a (set of) Slider Widget(s).
 
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
Slider(float width)
          Creates a new Slider.
Slider(float width, float height)
          Creates a new Slider.
Slider(float width, float height, Slider.Description desc)
          Creates a new Slider.
Slider(float width, Slider.Description desc)
          Creates a new Slider.
 
Method Summary
 void addSliderListener(SliderListener l)
          Adds a SliderListener to the List to be notified, when the value has changed.
protected  int drawHandle(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, Texture2D handleTex, int forcedHandlePos)
           
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
 int getHandleYOffset()
           
 int getMaxValue()
           
 int getMinValue()
           
protected  int getMousePosition(int currentHandlePosPx, int mouseX, int mouseY)
          Checks, if the mouse is over the handle.
 boolean getSmoothSliding()
           
 int getValue()
           
protected  void init()
          This method is called when the WidgetContainer is set.
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 onMouseMoved(float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
protected  void onSliderValueChanged(int oldValue, int newValue)
           
 boolean removeSliderListener(SliderListener l)
          Removes a SliderListener from the List.
 void setHandleYOffset(int yOffset)
           
 void setMaxValue(int maxValue)
          Sets the upper bound of scroll values.
 void setMinAndMax(int minValue, int maxValue)
          Sets the lower bound of scroll values.
 void setMinMaxAndValue(int minValue, int maxValue, int value)
          Sets the lower bound of scroll values.
 void setMinValue(int minValue)
          Sets the lower bound of scroll values.
 void setSmoothSliding(boolean b)
          If true, the handle doesn't snap to discrete positiones depending on the available slide values.
 boolean setValue(int value)
          Sets the current slide value
 
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, 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, 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, onMouseEntered, onMouseExited, 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

Slider

public Slider(float width,
              float height,
              Slider.Description desc)
Creates a new Slider.

Parameters:
width - the width of the Scrollbar
height - the height of the Scrollbar
desc - a Slider.Description instance holding information about this new Slider

Slider

public Slider(float width,
              Slider.Description desc)
Creates a new Slider.

Parameters:
width - the width of the Slider
desc - a Slider.Description instance holding information about this new Slider

Slider

public Slider(float width,
              float height)
Creates a new Slider.

Parameters:
width - the width of the Slider
height - the height of the Slider

Slider

public Slider(float width)
Creates a new Slider.

Parameters:
width - the width of the slider
Method Detail

setHandleYOffset

public void setHandleYOffset(int yOffset)

getHandleYOffset

public final int getHandleYOffset()

getMousePosition

protected int getMousePosition(int currentHandlePosPx,
                               int mouseX,
                               int mouseY)
Checks, if the mouse is over the handle.

Parameters:
currentHandlePosPx -
mouseX - widget local mouse-x
mouseY - widget local mouse-y
Returns:
-1, if the mouse is on the smaller side of the handle, +1, if it is on the greater side, 0 if it is over the handle.

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

onMouseMoved

protected void onMouseMoved(float x,
                            float y,
                            int buttonsState,
                            long when,
                            boolean isTopMost,
                            boolean hasFocus)
This event is fired, when the mouse is moved on a Widget.

Overrides:
onMouseMoved in class Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

setMinValue

public void setMinValue(int minValue)
Sets the lower bound of scroll values.


getMinValue

public final int getMinValue()
Returns:
the lower bound of scroll values

setMaxValue

public void setMaxValue(int maxValue)
Sets the upper bound of scroll values.


getMaxValue

public final int getMaxValue()
Returns:
the upper bound of scroll values

setMinAndMax

public void setMinAndMax(int minValue,
                         int maxValue)
Sets the lower bound of scroll values.

Parameters:
minValue -
maxValue -

setMinMaxAndValue

public void setMinMaxAndValue(int minValue,
                              int maxValue,
                              int value)
Sets the lower bound of scroll values.

Parameters:
minValue -
maxValue -
value -

onSliderValueChanged

protected void onSliderValueChanged(int oldValue,
                                    int newValue)
Parameters:
oldValue -
newValue -

setValue

public boolean setValue(int value)
Sets the current slide value

Parameters:
value -

getValue

public final int getValue()
Returns:
the current slide value

addSliderListener

public void addSliderListener(SliderListener l)
Adds a SliderListener to the List to be notified, when the value has changed.

Parameters:
l - the new SliderListener

removeSliderListener

public boolean removeSliderListener(SliderListener l)
Removes a SliderListener from the List.

Parameters:
l - the SliderListener to be removed

setSmoothSliding

public void setSmoothSliding(boolean b)
If true, the handle doesn't snap to discrete positiones depending on the available slide values.

Parameters:
b - enable/disable

getSmoothSliding

public final boolean getSmoothSliding()
Returns:
true, if the handle doesn't snap to discrete positiones depending on the available slide values.

drawHandle

protected int drawHandle(Texture2DCanvas texCanvas,
                         int offsetX,
                         int offsetY,
                         int width,
                         int height,
                         Texture2D handleTex,
                         int forcedHandlePos)

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)
Specified by:
drawWidget in class Widget

init

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

Specified by:
init in class Widget