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.
-
colors
- Array that holds colors of each of the 3 parts.
-
font
- current font of the labels.
-
pixMax_
-
-
pixMin_
-
-
width_
-
-
TripleSlider()
- Constructs and initializes the slider.
-
getColor(int)
- Returns color of a part.
-
getValue(int)
- Returns value for a part.
-
HandleMouse(int)
- Does all the recalculations related to user interaction with
the slider.
-
minimumSize()
- Overrides the default minimumSize() method.
-
Motion()
- This method is called when the "thumb" of the slider is dragged by
the user.
-
mouseDown(Event, int, int)
- An internal method used to handle mouse down events.
-
mouseDrag(Event, int, int)
- An internal method used to handle mouse drag events.
-
paint(Graphics)
- Paints the whole slider and labels.
-
preferredSize()
- Overrides the default preferredSize() method.
-
reshape(int, int, int, int)
- This method is called by the runtime when the slider is resized.
-
setColor(int, Color)
- Sets color of a part.
-
setEnabled(boolean)
- Enables/disables the slider.
-
setValues(double, double)
- Sets new values of the slider.
-
update(Graphics)
- Overrides the default update(Graphics) method
in order not to clear screen to avoid flicker.
colors
protected Color colors[]
- Array that holds colors of each of the 3 parts.
pixMin_
protected int pixMin_
pixMax_
protected int pixMax_
width_
protected int width_
font
protected Font font
- current font of the labels.
TripleSlider
public TripleSlider()
- Constructs and initializes the slider.
setEnabled
public void setEnabled(boolean flag)
- Enables/disables the slider.
- Parameters:
- flag - enable if true; disable otherwise.
- Overrides:
- setEnabled in class Component
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.
getColor
public Color getColor(int part)
- Returns color of a part.
- Parameters:
- part - slider's part; 0 to 2.
- Returns:
- current part's color.
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
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.
getValue
public double getValue(int part)
- Returns value for a part.
- Parameters:
- part - part's number; 0 to 2.
- Returns:
- value for the part.
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.
paint
public void paint(Graphics g)
- Paints the whole slider and labels.
- Overrides:
- paint in class Canvas
mouseDown
public boolean mouseDown(Event e,
int x,
int y)
- An internal method used to handle mouse down events.
- Overrides:
- mouseDown in class Component
mouseDrag
public boolean mouseDrag(Event e,
int x,
int y)
- An internal method used to handle mouse drag events.
- Overrides:
- mouseDrag in class Component
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.
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
preferredSize
public Dimension preferredSize()
- Overrides the default preferredSize() method.
- Returns:
- new Dimension
- Overrides:
- preferredSize in class Component
minimumSize
public Dimension minimumSize()
- Overrides the default minimumSize() method.
- Returns:
- new Dimension
- Overrides:
- minimumSize in class Component