-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNumWidget.java
More file actions
119 lines (104 loc) · 2.32 KB
/
NumWidget.java
File metadata and controls
119 lines (104 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package org.lcdproc.lcdjava;
/**
* Number Widget.
* <p>Displays a number on the LCD display.
* <p>Copyright (c) 2004-2005 Darren Greaves.
* @author Darren Greaves
* @version $Id: NumWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $
*/
public class NumWidget extends AbstractWidget
{
/**
* Version details.
*/
public static final String CVSID =
"$Id: NumWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $";
/**
* The Widget number.
*/
private int _number;
/**
* The x position.
*/
private int _x = 1;
/**
* Constructor.
* @param id the of the Widget.
* @param screen the Screen that knows about this Widget.
*/
protected NumWidget(int id, Screen screen)
{
super(id, screen);
}
/**
* Get the Widget type.
* @return the Widget type.
*/
public String getType()
{
return Widget.WIDGET_NUM;
}
/**
* Set the x position.
* @param x the x position.
*/
public void setX(int x)
{
_x = x;
}
/**
* Get the x position.
* @return the x position.
*/
public int getX()
{
return _x;
}
/**
* Set the Widget number.
* @param number the Widget number.
*/
public void setNumber(int number)
{
_number = number;
update();
}
/**
* Get the Widget number.
* @return the Widget number.
*/
public int getNumber()
{
return _number;
}
/**
* Return the data this Widget needs to update itself.
* @return the data to update this Widget.
*/
public String getData()
{
return _x + " " + _number;
}
/**
* Construct a new NumWidget.
* @param screen the Screen that owns the Widget.
* @param x the x position.
* @param number the number.
* @return a new NumWidget.
*/
public static NumWidget construct(Screen screen, int x, int number)
{
NumWidget widget = null;
try
{
widget = (NumWidget)screen.constructWidget(Widget.WIDGET_NUM);
widget.setX(x);
widget.setNumber(number);
}
catch (LCDException e)
{
// Supress, would only get one if we asked for an invalid Widget.
}
return widget;
}
}