com.sun.kjava
Class Slider

java.lang.Object
  |
  +--com.sun.kjava.Slider

public class Slider
extends java.lang.Object

Slider: A graphical valuator object. Allows user to select a value by sliding a marker on a scale. This class isn't very graceful about handling conditions where the width of the slider is less than the interval of the maximum and minimum values. It calculates a "skip" value in these cases to increment the value for each pixel on the screen, e.g. Slider s1 = new Slider(5, 100, 100, 0, 1000, 0) creates a slider 100 pixels wide to handle the interval 0->1000. It then treats each pixel as being 10 units, and the user can only generate values in multiples of 10.


Constructor Summary
Slider()
          Create a new Slider object.
Slider(int x, int y, int w, int mn, int mx, int initVal)
          Create a Slider object.
 
Method Summary
 boolean contains(int x, int y)
          Is this point within the Slider's bounds?
 void drawMarker(int drawStyle)
          Draw the Slider's marker.
 void handlePenDown(int x, int y)
          Deal with the fact that the pen went down.
 void handlePenMove(int x, int y)
          Deal with the fact that the pen moved.
 void paint()
          Draw the Slider.
 void setLocation(int x, int y)
          Set the position of the Slider.
 void setSizeRange(int w, int mn, int mx, int val)
          Reset the width, limits, and value of the Slider.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Slider

public Slider(int x,
              int y,
              int w,
              int mn,
              int mx,
              int initVal)
Create a Slider object.
Parameters:
x - the X coordinate of the Slider's position
y - the Y coordinate of the Slider's position
w - the width
mn - the minimum value
mx - the maximum value
initVal - the initial value

Slider

public Slider()
Create a new Slider object.
Method Detail

setLocation

public void setLocation(int x,
                        int y)
Set the position of the Slider.
Parameters:
x - the new X coordinate
y - the new Y coordinate

setSizeRange

public void setSizeRange(int w,
                         int mn,
                         int mx,
                         int val)
Reset the width, limits, and value of the Slider.
Parameters:
w - the new width
mn - the new minimum value
mx - the new maximum value
val - the new current value

paint

public void paint()
Draw the Slider.

drawMarker

public void drawMarker(int drawStyle)
Draw the Slider's marker.
Parameters:
drawStyle - the style in which to draw it.

handlePenMove

public void handlePenMove(int x,
                          int y)
Deal with the fact that the pen moved.
Parameters:
x - the X coordinate of the pen's new position
y - the Y coordinate of the pen's new position

handlePenDown

public void handlePenDown(int x,
                          int y)
Deal with the fact that the pen went down.
Parameters:
x - the X coordinate of the pen's new position
y - the Y coordinate of the pen's new position

contains

public boolean contains(int x,
                        int y)
Is this point within the Slider's bounds?
Parameters:
x - the X coordinate to test
y - the Y coordinate to test
Returns:
true if the point is in bounds, false otherwise