com.sun.lwuit
Class Slider

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Label
          extended by com.sun.lwuit.Slider
All Implemented Interfaces:
Animation, StyleListener

public class Slider
extends Label

The slider component serves both as a slider widget to allow users to select a value on a scale via touch/arrows and also to indicate progress. The slider defaults to percentage display but can represent any positive set of values.


Field Summary
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
Slider()
          The default constructor uses internal rendering to draw its state
 
Method Summary
 void addDataChangedListener(DataChangedListener l)
          Adds a listener to data changed events
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
protected  Dimension calcPreferredSize()
          Return the size we would generally like for the component
static Slider createInfinite()
          Creates an infinite progress slider
 void deinitialize()
          Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
protected  void fireClicked()
          When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly.
 int getIncrements()
          The increments when the user presses a key to the left/right/up/down etc.
 int getMaxValue()
           
 int getMinValue()
           
 int getProgress()
          Indicates the value of progress made
 Style getStyle()
          Returns the Component Style allowing us to manipulate the look of the component
 Image getThumbImage()
          The thumb image is drawn on top of the current progress
 void initComponent()
          Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
 boolean isEditable()
          Indicates the slider is modifyable
 boolean isInfinite()
          The infinite slider functionality is used to animate progress for which there is no defined value.
 boolean isRenderPercentageOnTop()
          Indicates that the value of the slider should be rendered with a percentage sign on top of the slider.
 boolean isRenderValueOnTop()
           
protected  boolean isSelectableInteraction()
          This method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device.
 boolean isVertical()
          Indicates the slider is vertical
 void keyPressed(int code)
          If this Component is focused, the key pressed event will call this method
 void paintBackground(Graphics g)
          Paint the progress indicator
 void pointerDragged(int x, int y)
          If this Component is focused, the pointer dragged event will call this method
 void pointerPressed(int x, int y)
          If this Component is focused, the pointer pressed event will call this method
 void pointerReleased(int x, int y)
          If this Component is focused, the pointer released event will call this method
 void refreshTheme()
          Makes sure the component is up to date with the current style object
 void removeDataChangedListener(DataChangedListener l)
          Removes a listener from data changed events
 void setEditable(boolean editable)
          Indicates the slider is modifyable
 void setIncrements(int increments)
          The increments when the user presses a key to the left/right/up/down etc.
 void setInfinite(boolean i)
          Activates/disables the infinite slider functionality used to animate progress for which there is no defined value.
 void setMaxValue(int maxValue)
           
 void setMinValue(int minValue)
           
 void setProgress(int value)
          Indicates the value of progress made, this method is thread safe and can be invoked from any thread although discression should still be kept so one thread doesn't regress progress made by another thread...
 void setRenderPercentageOnTop(boolean renderPercentageOnTop)
          Indicates that the value of the slider should be rendered with a percentage sign on top of the slider.
 void setRenderValueOnTop(boolean renderValueOnTop)
           
 void setThumbImage(Image thumbImage)
          The thumb image is drawn on top of the current progress
 void setUIID(java.lang.String id)
          This method sets the Component the Unique identifier.
 void setVertical(boolean vertical)
          Indicates the slider is vertical
 
Methods inherited from class com.sun.lwuit.Label
getAlignment, getBaselineResizeBehavior, getGap, getIcon, getShiftText, getText, getTextPosition, getVerticalAlignment, isDefaultTickerEnabled, isEndsWith3Points, isTickerEnabled, isTickerRunning, paint, paramString, setAlignment, setDefaultTickerEnabled, setEndsWith3Points, setGap, setIcon, setShiftText, setText, setTextPosition, setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, calcScrollSize, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, dragInitiated, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setCellRenderer, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Slider

public Slider()
The default constructor uses internal rendering to draw its state

Method Detail

setUIID

public void setUIID(java.lang.String id)
Description copied from class: Component
This method sets the Component the Unique identifier. This method should be used before a component has been initialized

Overrides:
setUIID in class Component
Parameters:
id - UIID unique identifier for component type

initComponent

public void initComponent()
Description copied from class: Component
Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state

Overrides:
initComponent in class Component

deinitialize

public void deinitialize()
Description copied from class: Component
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

Overrides:
deinitialize in class Component

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the Display class.

Specified by:
animate in interface Animation
Overrides:
animate in class Label
Returns:
true if a repaint is desired or false if no repaint is necessary

isInfinite

public boolean isInfinite()
The infinite slider functionality is used to animate progress for which there is no defined value.

Returns:
true for infinite progress

setInfinite

public void setInfinite(boolean i)
Activates/disables the infinite slider functionality used to animate progress for which there is no defined value.

Parameters:
i - true for infinite progress

createInfinite

public static Slider createInfinite()
Creates an infinite progress slider

Returns:
a slider instance that has no end value

refreshTheme

public void refreshTheme()
Description copied from class: Component
Makes sure the component is up to date with the current style object

Overrides:
refreshTheme in class Component

getProgress

public int getProgress()
Indicates the value of progress made

Returns:
the progress on the slider

setProgress

public void setProgress(int value)
Indicates the value of progress made, this method is thread safe and can be invoked from any thread although discression should still be kept so one thread doesn't regress progress made by another thread...

Parameters:
value - new value for progress

getStyle

public Style getStyle()
Description copied from class: Component
Returns the Component Style allowing us to manipulate the look of the component

Overrides:
getStyle in class Component
Returns:
the component Style object

calcPreferredSize

protected Dimension calcPreferredSize()
Return the size we would generally like for the component

Overrides:
calcPreferredSize in class Label
Returns:
the calculated preferred size based on component content

paintBackground

public void paintBackground(Graphics g)
Paint the progress indicator

Overrides:
paintBackground in class Component
Parameters:
g - the component graphics

isVertical

public boolean isVertical()
Indicates the slider is vertical

Returns:
true if the slider is vertical

setVertical

public void setVertical(boolean vertical)
Indicates the slider is vertical

Parameters:
vertical - true if the slider is vertical

isEditable

public boolean isEditable()
Indicates the slider is modifyable

Returns:
true if the slider is editable

setEditable

public void setEditable(boolean editable)
Indicates the slider is modifyable

Parameters:
editable - true if the slider is editable

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method

Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerDragged

public void pointerDragged(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer dragged event will call this method

Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

fireClicked

protected void fireClicked()
Description copied from class: Component
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. When overriding this method you should also override isSelectableInteraction to indicate that a command is placed appropriately on top of the fire key for 3 soft button phones.

Overrides:
fireClicked in class Component

isSelectableInteraction

protected boolean isSelectableInteraction()
Description copied from class: Component
This method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device.

Overrides:
isSelectableInteraction in class Component
Returns:
true if this is a selectable interaction

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method

Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

keyPressed

public void keyPressed(int code)
Description copied from class: Component
If this Component is focused, the key pressed event will call this method

Overrides:
keyPressed in class Component
Parameters:
code - the key code value to indicate a physical key.

getIncrements

public int getIncrements()
The increments when the user presses a key to the left/right/up/down etc.

Returns:
increment value

setIncrements

public void setIncrements(int increments)
The increments when the user presses a key to the left/right/up/down etc.

Parameters:
increments - increment value

addDataChangedListener

public void addDataChangedListener(DataChangedListener l)
Adds a listener to data changed events

Parameters:
l - new listener

removeDataChangedListener

public void removeDataChangedListener(DataChangedListener l)
Removes a listener from data changed events

Parameters:
l - listener to remove

isRenderPercentageOnTop

public boolean isRenderPercentageOnTop()
Indicates that the value of the slider should be rendered with a percentage sign on top of the slider.

Returns:
true if so

setRenderPercentageOnTop

public void setRenderPercentageOnTop(boolean renderPercentageOnTop)
Indicates that the value of the slider should be rendered with a percentage sign on top of the slider.

Parameters:
renderPercentageOnTop - true to render percentages

isRenderValueOnTop

public boolean isRenderValueOnTop()
Returns:
the renderValueOnTop

setRenderValueOnTop

public void setRenderValueOnTop(boolean renderValueOnTop)
Parameters:
renderValueOnTop - the renderValueOnTop to set

getMaxValue

public int getMaxValue()
Returns:
the maxValue

setMaxValue

public void setMaxValue(int maxValue)
Parameters:
maxValue - the maxValue to set

getMinValue

public int getMinValue()
Returns:
the minValue

setMinValue

public void setMinValue(int minValue)
Parameters:
minValue - the minValue to set

getThumbImage

public Image getThumbImage()
The thumb image is drawn on top of the current progress

Returns:
the thumbImage

setThumbImage

public void setThumbImage(Image thumbImage)
The thumb image is drawn on top of the current progress

Parameters:
thumbImage - the thumbImage to set