brf.j2me.dynaworks.ui
Class Slider

java.lang.Object
  |
  +--brf.j2me.dynaworks.ui.BasicWidget
        |
        +--brf.j2me.dynaworks.ui.Slider
All Implemented Interfaces:
UserWidget

public class Slider
extends BasicWidget

Custom user control widget for a slider.

Implements a horizontally oriented slider control.

Version:
1.0
Author:
Bernd R. Fix
See Also:
BasicWidget, UserWidget

Field Summary
private  int max
          range values (maximum).
private  int min
          range values (minimum).
private  int pos
          position of the slider.
private  int r
          current visible range.
private  int xr
          x-coordinate of upper-right corner.
private  int yb
          y-coordinate of lower-left corner.
 
Fields inherited from class brf.j2me.dynaworks.ui.BasicWidget
g, h, w, x, y
 
Constructor Summary
Slider(int x, int y, int w, int h)
          constructor.
 
Method Summary
 int getPosition()
          get the current position.
 ActionEvent handlePenDown(int xc, int yc)
          Handle a "pen down" event.
 ActionEvent handlePenMove(int xc, int yc)
          Handle a "pen move" event.
 void paint()
          Paint the user control.
 int setPosition(int pos)
          set the position of the slider.
 void setRange(int min, int max, int pos)
          set the range for the slider.
 void update(int lastPos)
          update the slider representation.
 
Methods inherited from class brf.j2me.dynaworks.ui.BasicWidget
, contains, handleKeyDown, handlePenUp, handleSysKeyDown, hasFocus, loseFocus, setFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

min

private int min
range values (minimum).


max

private int max
range values (maximum).


r

private int r
current visible range.


pos

private int pos
position of the slider.


xr

private int xr
x-coordinate of upper-right corner.

yb

private int yb
y-coordinate of lower-left corner.
Constructor Detail

Slider

public Slider(int x,
              int y,
              int w,
              int h)
constructor.

Parameters:
x - int - x coordinate of upper-left corner.
y - int - y coordinate of upper-left corner.
w - int - width of the control.
h - int - height of the control.
Method Detail

setRange

public void setRange(int min,
                     int max,
                     int pos)
set the range for the slider.

Parameters:
min - int - minimum value for slider.
max - int - maximum value for slider.
pos - int - start position for marker.

setPosition

public int setPosition(int pos)
set the position of the slider.

Parameters:
pos - int - new position of slider.
Returns:
int - old position of slider.

getPosition

public int getPosition()
get the current position.

Returns:
int - current position of slider.

handlePenDown

public ActionEvent handlePenDown(int xc,
                                 int yc)
Handle a "pen down" event. Return an ActionEvent if neccessary.

Overrides:
handlePenDown in class BasicWidget
Parameters:
xc - int - x coordinate of hit point.
yc - int - y coordinate of hit point.
Returns:
ActionEvent - event triggered by PenDown (or null).
See Also:
ActionEvent

handlePenMove

public ActionEvent handlePenMove(int xc,
                                 int yc)
Handle a "pen move" event. Return an ActionEvent if neccessary.

Overrides:
handlePenMove in class BasicWidget
Parameters:
xc - int - x coordinate of pen point.
yc - int - y coordinate of pen point.
Returns:
ActionEvent - event triggered by PenMove (or null).
See Also:
ActionEvent

paint

public void paint()
Paint the user control.

Overrides:
paint in class BasicWidget

update

public void update(int lastPos)
update the slider representation.

Just repaint the changed parts of the control.

Parameters:
lastPos - int - fast repaint based on last position.