Class TripleSlider

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----TripleSlider

public class TripleSlider
extends Canvas
This class produces a slider with 2 thumbs that has 3 values.


Variable Index

 o colors
Array that holds colors of each of the 3 parts.
 o font
current font of the labels.
 o pixMax_
 o pixMin_
 o width_

Constructor Index

 o TripleSlider()
Constructs and initializes the slider.

Method Index

 o getColor(int)
Returns color of a part.
 o getValue(int)
Returns value for a part.
 o HandleMouse(int)
Does all the recalculations related to user interaction with the slider.
 o minimumSize()
Overrides the default minimumSize() method.
 o Motion()
This method is called when the "thumb" of the slider is dragged by the user.
 o mouseDown(Event, int, int)
An internal method used to handle mouse down events.
 o mouseDrag(Event, int, int)
An internal method used to handle mouse drag events.
 o paint(Graphics)
Paints the whole slider and labels.
 o preferredSize()
Overrides the default preferredSize() method.
 o reshape(int, int, int, int)
This method is called by the runtime when the slider is resized.
 o setColor(int, Color)
Sets color of a part.
 o setEnabled(boolean)
Enables/disables the slider.
 o setValues(double, double)
Sets new values of the slider.
 o update(Graphics)
Overrides the default update(Graphics) method in order not to clear screen to avoid flicker.

Variables

 o colors
 protected Color colors[]
Array that holds colors of each of the 3 parts.

 o pixMin_
 protected int pixMin_
 o pixMax_
 protected int pixMax_
 o width_
 protected int width_
 o font
 protected Font font
current font of the labels.

Constructors

 o TripleSlider
 public TripleSlider()
Constructs and initializes the slider.

Methods

 o setEnabled
 public void setEnabled(boolean flag)
Enables/disables the slider.

Parameters:
flag - enable if true; disable otherwise.
Overrides:
setEnabled in class Component
 o setColor
 public void setColor(int part,
                      Color color)
Sets color of a part.

Parameters:
part - slider's part; 0 to 2.
color - new color of the part.
 o getColor
 public Color getColor(int part)
Returns color of a part.

Parameters:
part - slider's part; 0 to 2.
Returns:
current part's color.
 o reshape
 public void reshape(int x,
                     int y,
                     int width,
                     int height)
This method is called by the runtime when the slider is resized.

Overrides:
reshape in class Component
 o setValues
 public void setValues(double a,
                       double b)
Sets new values of the slider.

Parameters:
a - new value for the left part.
b - new value for the central part. The right part's value is 1 - a - b.
 o getValue
 public double getValue(int part)
Returns value for a part.

Parameters:
part - part's number; 0 to 2.
Returns:
value for the part.
 o Motion
 public void Motion()
This method is called when the "thumb" of the slider is dragged by the user. Must be overridden to give the slider some behavior.

 o paint
 public void paint(Graphics g)
Paints the whole slider and labels.

Overrides:
paint in class Canvas
 o mouseDown
 public boolean mouseDown(Event e,
                          int x,
                          int y)
An internal method used to handle mouse down events.

Overrides:
mouseDown in class Component
 o mouseDrag
 public boolean mouseDrag(Event e,
                          int x,
                          int y)
An internal method used to handle mouse drag events.

Overrides:
mouseDrag in class Component
 o HandleMouse
 protected void HandleMouse(int x)
Does all the recalculations related to user interaction with the slider.

Parameters:
x - the x coordinate of the mouse event.
 o update
 public void update(Graphics g)
Overrides the default update(Graphics) method in order not to clear screen to avoid flicker.

Overrides:
update in class Component
 o preferredSize
 public Dimension preferredSize()
Overrides the default preferredSize() method.

Returns:
new Dimension
Overrides:
preferredSize in class Component
 o minimumSize
 public Dimension minimumSize()
Overrides the default minimumSize() method.

Returns:
new Dimension
Overrides:
minimumSize in class Component