|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.component.GaugeField
public class GaugeField
Displays a horizontal bar that you can use for numeric selection or as a progress indicator.
Behaviour
Displays a label followed by a gauge bar. The gauge optionally has text
overlayed over it indicating the percentage the gauge represents.
If this field is built as Field.EDITABLE
, the user can employ the
trackwheel to change the value by ALT-rolling. If
Ui.getIncreaseDirection()
returns -1, then rolling the trackwheel down
decreases the value. If Ui.getIncreaseDirection()
returns +1, then
rolling the trackwheel up increases the * value.
If the UI is not operating in MODE_ADVANCED
mode, this field adds a context menu item usable for changing its value. When
invoked, a dialog appears in which one can use the trackwheel to select the
item without ALT-rolling. Pressing ENTER or clicking dismisses the dialog,
changing this field's value. Pressing ESCAPE dismisses the dialog,
cancelling the change.
Field Summary | ||
---|---|---|
static long |
LABEL_AS_PROGRESS
Display the label as the progress value. |
|
static int |
NO_TEXT
Do not display progress value in text form. |
|
static int |
PERCENT
Displays progress as a percentage. |
Constructor Summary | ||
---|---|---|
GaugeField()
Constructs a new GaugeField instance. |
||
GaugeField(String label,
int min,
int max,
int start,
long style)
Constructs a new GaugeField instance with label, values, and style. |
Method Summary | ||
---|---|---|
protected void |
drawFocus(Graphics graphics,
boolean on)
Draws the focus indicator for this field. |
|
AccessibleContext |
getAccessibleContext()
Returns accessible representation of the field for a screen reader. |
|
String |
getLabel()
Retrieves this field's label. |
|
int |
getPreferredHeight()
Retrieves this field's preferred height. |
|
int |
getPreferredWidth()
Retrieves this field's preferred width. |
|
int |
getValue()
Retrieves the current progress level. |
|
int |
getValueMax()
Retrieves the highest value in this field's range. |
|
int |
getValueMin()
Retrieves the lowest value in this field's ragne. |
|
protected void |
layout(int width,
int height)
Lays out this field's contents. |
|
protected void |
makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu. |
|
protected int |
moveFocus(int amount,
int status,
int time)
Handles moving the focus within this field. |
|
protected void |
paint(Graphics graphics)
Redraws this field. |
|
void |
reset(String label,
int min,
int max,
int start)
Resets this field's values. |
|
void |
setLabel(String label)
Sets this field's label. |
|
void |
setValue(int value)
Sets the progress level for the gauge. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_TEXT
By default, this field displays the progress in a textual form.
public static final int PERCENT
By default, this field displays progress in absolute values (that is, the actual values ranging from the min to the max of this field's range).
public static final long LABEL_AS_PROGRESS
Constructor Detail |
---|
public GaugeField()
This builds a new gauge field with no label, 0 for min, 100 for max, and PERCENT as style.
public GaugeField(String label, int min, int max, int start, long style)
Provided a range of values and a start position, this method builds a gauge field of your specified style, and sets the extent of its progress to your start position.
Note that the range of values handled by this field includes both
your min and max values, and that (min <= start <= max)
.
When using this constructor, you specify this field's style as a
combination of this class's various style constants (Field.FOCUSABLE
,
Field.EDITABLE
,
GaugeField.NO_TEXT
,
GaugeField.PERCENT
).
label
- Optional label for the gauge (may be null).min
- Bottom of the value range.max
- Top of the value range.start
- Initial progress level of this field.style
- Style value(s) for this field.
IllegalArgumentException
- if max is less than or equal to min, or
start is not in the range between min and max.Method Detail |
---|
public void reset(String label, int min, int max, int start)
The parameters for this method serve exactly the same purpose as in
the constructor, GaugeField.GaugeField(java.lang.String, int, int, int, long)
.
label
- Optional label for the gauge (may be null).min
- Bottom of the value range.max
- Top of the value range.start
- Initial progress level of this field.
IllegalArgumentException
- if max is less than or equal to min, or
start is not in the range between min and max.protected void drawFocus(Graphics graphics, boolean on)
This field's manager invokes this method after painting this field to invert the border of the focus indicator.
drawFocus
in class Field
graphics
- Graphics context for drawing the focus.on
- True if the focus should be set; otherwise, false.public int getValueMin()
public int getValueMax()
public int getValue()
public String getLabel()
protected void layout(int width, int height)
this field's manager invokes this method during the layout process to instruct this field to arrange its contents, given an amount of available space.
Note that this field always uses all the available horizontal width.
layout
in class Field
width
- Amount of available horizontal space.height
- Amount of available vertical space.public int getPreferredHeight()
Field
Managers may make use of this value during layout. Override this method to request a certain height for your field.
getPreferredHeight
in class Field
Field.getPreferredHeight()
public int getPreferredWidth()
Field
Managers make use of this value during layout. Override this method to request a certain width for your field.
getPreferredWidth
in class Field
Field.getPreferredWidth()
protected void makeContextMenu(ContextMenu contextMenu)
Field.getContextMenu()
invokes this method to construct this field's
context menu.
If the UI is not operating in MODE_ADVANCED
mode, this
method builds this field's context menu adding a menu item for changing
this field's value.
makeContextMenu
in class Field
contextMenu
- Context menu to build.ContextMenu
protected void paint(Graphics graphics)
This field's manager invokes this method during the repainting process to instruct this field to repaint itself.
paint
in class Field
graphics
- Graphics context for repainting this field.protected int moveFocus(int amount, int status, int time)
This field's manager invokes this method only when this field already has the focus.
If this field is not Field.EDITABLE
, this method does nothing and
returns the entire roll amount.
If the trackwheel is ALT-rolling the roll amount is used to change the progress value of the gauge field. If an end of this field's allowable range is reached, this method clamps the progress value to the maximum or minimum end of the range (as appropriate) and returns zero.
moveFocus
in class Field
amount
- Number of positions to move, positive means downward (or
towards the max end of the field's progress value), negative means upward
(or towards the min end of the field's progress value).status
- Modifier key state: if KeypadListener.STATUS_ALT
,
then this method uses the roll amount to change this field's progress value.time
- Number of milliseconds since the device was turned on.
public void setLabel(String label)
You can leave this field without a label: provide null for this method's parameter.
label
- New label for this field.public void setValue(int value)
value
- New progress level for this field.
IllegalArgumentException
- if value
is less than the bottom of the value range
or greater than the top of the value range. The value range is set when the field is constructed
or when the field's values are reset.GaugeField.reset(java.lang.String, int, int, int)
public AccessibleContext getAccessibleContext()
getAccessibleContext
in class Field
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.