Search…
Velocimeter

Overview

The Velocimeter represents a velocimeter gauge. The background and pointer can be customized. The text, max and min values can be drawn or not. The pointer's color can be changed
Could not load image
VelocimeterSample.java
1
// Adds a timer
2
tt = addTimer(50);
3
4
// Creates a simple Velocimeter
5
vel = new Velocimeter();
6
vel.value = -20;
7
vel.max = 40;
8
vel.pointerColor = Color.GREEN;
9
add(vel, CENTER, CENTER, PARENTSIZE + 50, PARENTSIZE + 50);
10
11
// Generates an event from the timer
12
@Override
13
public void onEvent(Event e)
14
{
15
if (e.type == TimerEvent.TRIGGERED && tt.triggered)
16
{
17
vel.value++;
18
if (vel.value > vel.max + 20)
19
{
20
vel.value = vel.min - 20;
21
}
22
repaint();
23
}
24
}
Copied!
To view the full code, click here.

Attributes

Type
Name
Description
boolean
drawMax
Set to false to don't draw the max value's text
boolean
drawMin
Set to false to don't draw the min value's text
boolean
drawValue
Set to false to don't draw the value's text.
int
max
The maximum value; defaults to 100.
int
maxAngle
The maximum angle value; defaults to 270 degrees for the default gauge
int
min
The minimum value; defaults to 0
int
pointerColor
The pointer's color
int
value
The current value
int
valueColor
The value's color.

Methods

Type
Name
Description
Constructor
Velocimeter( )
Constructs a velocimeter using the default gauge and pointer images
Constructor
Velocimeter(String gaugeImagePath, String pointerImagePath)
Constructs a velocimeter using the given images

References

See the JavaDocs for more information.
Last modified 2yr ago