All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.Meter

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----tea.set.Meter

public class Meter
extends Canvas
Meter widget is a simple widget used to show a progress of a value. There are two layout for the meter. A meter can be horizontally layed out, and it grows from left to right. Or it can be vertically layed out, in which case it grows from bottom up. The value of the meter can be displayed as either percentage of the range, or as an absolute value. The display of the value can also be disabled by specifying NONE flag. Meter display draw a border around the display area, use Effect3D to add a border if it's desired.

Meter supports the following properties:
Property NameProperty TypeDescription
Valueint Current meter value.
Lowint The lower end of the range.
Highint The higher end of the range.
Displayint Label display flag.
ColorColor Meter fill color.


Variable Index

 o ABSOLUTE
Display the absolute value.
 o HORIZONTAL
Meter grows from left to right.
 o NONE
Don't display value.
 o PERCENT
Display the current value as a percentage of the range (Default).
 o VERTICAL
Meter grows from bottom up.

Constructor Index

 o Meter()
Construct a default Meter, and set the range to 0-100.
 o Meter(int, int)
Construct a meter with specified range.
 o Meter(int, int, int)
Construct a meter with specified range.

Method Index

 o getColor()
Get the filling color.
 o getDisplay()
Get display option, NONE, PERCENT, or ABSOLUTE.
 o getHigh()
Return the higher value of the range.
 o getLow()
Return the lower value of the range.
 o getMinimumSize()
Return the minimum size of the meter.
 o getPreferredSize()
Return the preferred size of the meter.
 o getValue()
Return the current value of the meter.
 o paint(Graphics)
Paint meter.
 o setColor(Color)
Set the filling color.
 o setDisplay(int)
Set the display style.
 o setValue(int)
Set the current value of the meter.
 o update(Graphics)
Overriden for double buffering.

Variables

 o NONE
 public static final int NONE
Don't display value.

 o PERCENT
 public static final int PERCENT
Display the current value as a percentage of the range (Default).

 o ABSOLUTE
 public static final int ABSOLUTE
Display the absolute value.

 o HORIZONTAL
 public static final int HORIZONTAL
Meter grows from left to right.

 o VERTICAL
 public static final int VERTICAL
Meter grows from bottom up.

Constructors

 o Meter
 public Meter()
Construct a default Meter, and set the range to 0-100.

 o Meter
 public Meter(int low,
              int high)
Construct a meter with specified range. The direction defaults to HORIZONTAL.

Parameters:
low - range lower bound.
high - range higher bound.
 o Meter
 public Meter(int low,
              int high,
              int direction)
Construct a meter with specified range. The direction parameter can either be HORIZONTAL or VERTICAL.

Parameters:
low - range lower bound.
high - range higher bound.
direction - can be either HORIZONTAL or VERTICAL.

Methods

 o setValue
 public synchronized void setValue(int value)
Set the current value of the meter. This causes a repaint.

Parameters:
value - current value.
 o getValue
 public int getValue()
Return the current value of the meter.

Returns:
current value.
 o getLow
 public int getLow()
Return the lower value of the range.

Returns:
lower bound.
 o getHigh
 public int getHigh()
Return the higher value of the range.

Returns:
higher bound.
 o setDisplay
 public void setDisplay(int dispF)
Set the display style. It can either be NONE, PERCENT, or ABSOLUTE.

Parameters:
dispf - label display option.
 o getDisplay
 public int getDisplay()
Get display option, NONE, PERCENT, or ABSOLUTE.

Returns:
display option.
 o setColor
 public void setColor(Color c)
Set the filling color. The default color is blue.

Parameters:
c - filling color.
 o getColor
 public Color getColor()
Get the filling color.

Returns:
filling color.
 o getPreferredSize
 public Dimension getPreferredSize()
Return the preferred size of the meter.

Returns:
preferred size.
Overrides:
getPreferredSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
Return the minimum size of the meter.

Returns:
minimum size.
Overrides:
getMinimumSize in class Component
 o paint
 public void paint(Graphics g)
Paint meter.

Parameters:
g - Graphics context of this component.
Overrides:
paint in class Canvas
 o update
 public void update(Graphics g)
Overriden for double buffering.

Parameters:
g - Graphics context of this component.
Overrides:
update in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index