Method | Description |
Thermometer(int x, int y, int width, int height, int min, int max) | Creates a new Thermometer at the given position and of the specified size. The parameters min and max define the range of values. |
setCaption(String captionMin, String captionMax) | Adds a caption to the Thermometer . The passed Strings will be displayed at the top right (captionMax ) and bottom right (captionMin ) of this component. |
setNumericDisplay(int digits, int decimals, String unit) | This method configures the alphanumeric display of measured values. Parameter digits defines the total number of displayed digits, decimals specifies the number of decimals included in digits . Example: digits=4 and decimals=3 will display values in form of x,xxx . If decimals=0 , no decimal point will be displayed (useful if the measured value shall be displayed in a different range of values). The parameter unit holds the unit of the displayed values (e.g. "V"). |
setValue(int value) | Passes a new value to the Thermometer , which thereupon will be updated. If value exceeds the range of values, it will be replaced by the according value for min or max . |
1 | import jcontrol.lang.Math; |
2 | import jcontrol.lang.ThreadExt; |
3 | import jcontrol.ui.vole.Border; |
4 | import jcontrol.ui.vole.Container; |
5 | import jcontrol.ui.vole.Frame; |
6 | import jcontrol.ui.vole.Label; |
7 | import jcontrol.ui.vole.meter.Thermometer; |
8 | |
9 | /** |
10 | * <p>This example demonstrates how to use the |
11 | * component Thermometer within the GUI framework |
12 | * JControl/Vole.</p> |
13 | * |
14 | * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p> |
15 | */ |
16 | public class VoleThermometerExample extends Frame { |
17 | Thermometer tm1, tm2; |
18 | |
19 | /** |
20 | * Create three AnalogMeters with different configurations. |
21 | */ |
22 | public VoleThermometerExample() { |
23 | Container container = new Container(); |
24 | jcontrol.io.Backlight.setBrightness(255); |
25 | |
26 | // create the first Thermometer |
27 | // |
28 | // NOTE: The String "\u00b0" hereby represents the |
29 | // UTF8 version of the 'degree' character |
30 | tm1 = new Thermometer(8, 10, 50, 45, 0, 400); |
31 | tm1.setNumericDisplay(5, 1, "\u00b0C"); |
32 | tm1.setCaption("0\u00b0C", "+40\u00b0C"); |
33 | |
34 | container.add(tm1); |
35 | container.add(new Label("Inside Temp.", 8, 55, 50, 8, |
36 | Label.ALIGN_CENTER)); |
37 | |
38 | // create the second Thermometer |
39 | // |
40 | // NOTE: The String "\u00b0" hereby represents the |
41 | // UTF8 version of the 'degree' character |
42 | tm2 = new Thermometer(68, 10, 50, 45, -300, 500); |
43 | tm2.setNumericDisplay(5, 1, "\u00b0C"); |
44 | tm2.setCaption("-30\u00b0C", "+50\u00b0C"); |
45 | |
46 | container.add(tm2); |
47 | container.add(new Label("Outside Temp.", 68, 55, 50, 8, |
48 | Label.ALIGN_CENTER)); |
49 | |
50 | // add a border |
51 | container.add(new Border("Thermometers", 0, 0, 128, 64)); |
52 | |
53 | // add the container to the frame |
54 | this.add(container); |
55 | |
56 | // make us visible |
57 | show(); |
58 | |
59 | // create some random values |
60 | for (;;) { |
61 | tm1.setValue(Math.rnd(400)); |
62 | tm2.setValue(Math.rnd(800)-300); |
63 | |
64 | try { |
65 | ThreadExt.sleep(1000); |
66 | } catch (InterruptedException e) {} |
67 | } |
68 | } |
69 | |
70 | // Instantiate and show the VoleAnalogMeterExample |
71 | public static void main(String[] args) { |
72 | new VoleThermometerExample(); |
73 | } |
74 | } |