-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathScrollerWidget.java
More file actions
278 lines (242 loc) · 5.61 KB
/
ScrollerWidget.java
File metadata and controls
278 lines (242 loc) · 5.61 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
package org.lcdproc.lcdjava;
/**
* Scroller Widget.
* <p>Displays a scroller on the LCD display.
* <p>Copyright (c) 2004-2005 Darren Greaves.
* @author Darren Greaves
* @version $Id: ScrollerWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $
*/
public class ScrollerWidget extends AbstractWidget
{
/**
* Version details.
*/
public static final String CVSID =
"$Id: ScrollerWidget.java,v 1.2 2005-03-03 14:13:16 boncey Exp $";
/**
* The Horizontal direction.
*/
public static final char DIRECTION_HORIZONTAL = 'h';
/**
* The Vertical direction.
*/
public static final char DIRECTION_VERTICAL = 'v';
/**
* The 'Marquee' direction.
* <p>Will loop around horizontally rather than bounce back and forth.
*/
public static final char DIRECTION_MARQUEE = 'm';
/**
* The top position of the scroller.
*/
private int _top = 1;
/**
* The bottom position of the scroller.
*/
private int _bottom = 1;
/**
* The left position of the scroller.
*/
private int _left = 1;
/**
* The right position of the scroller.
*/
private int _right = 1;
/**
* The direction to scroll.
*/
private char _direction;
/**
* The speed of the scroller.
*/
private int _speed;
/**
* The Widget text.
*/
private String _text;
/**
* Constructor.
* @param id the of the Widget.
* @param screen the Screen that knows about this Widget.
*/
protected ScrollerWidget(int id, Screen screen)
{
super(id, screen);
}
/**
* Get the Widget type.
* @return the Widget type.
*/
public String getType()
{
return WIDGET_SCROLLER;
}
/**
* Set the Widget text.
* @param text the Widget text.
*/
public void setText(String text)
{
_text = text;
update();
}
/**
* Get the Widget text.
* @return the Widget text.
*/
public String getText()
{
return _text;
}
/**
* Set the top position.
* @param top the top position.
*/
public void setTop(int top)
{
_top = top;
update();
}
/**
* Get the top position.
* @return the top position.
*/
public int getTop()
{
return _top;
}
/**
* Set the bottom position.
* @param bottom the bottom position.
*/
public void setBottom(int bottom)
{
_bottom = bottom;
update();
}
/**
* Get the bottom position.
* @return the bottom position.
*/
public int getBottom()
{
return _bottom;
}
/**
* Set the left position.
* @param left the left position.
*/
public void setLeft(int left)
{
_left = left;
update();
}
/**
* Get the left position.
* @return the left position.
*/
public int getLeft()
{
return _left;
}
/**
* Set the right position.
* @param right the right position.
*/
public void setRight(int right)
{
_right = right;
update();
}
/**
* Get the right position.
* @return the right position.
*/
public int getRight()
{
return _right;
}
/**
* Set the direction.
* @param direction the direction.
*/
public void setDirection(char direction)
{
_direction = direction;
update();
}
/**
* Get the direction.
* @return the direction.
*/
public char getDirection()
{
return _direction;
}
/**
* Set the speed.
* @param speed the speed.
*/
public void setSpeed(int speed)
{
_speed = speed;
update();
}
/**
* Get the speed.
* @return the speed.
*/
public int getSpeed()
{
return _speed;
}
/**
* Return the data this Widget needs to update itself.
* @return the data to update this Widget.
*/
public String getData()
{
return _left + " " + _top + " " + _right + " " + _bottom + " " +
_direction + " " + _speed + " \"" + stripQuotes(_text) + "\"";
}
/**
* Construct a new ScrollerWidget.
* @param screen the Screen that owns the Widget.
* @param left the left position.
* @param top the top position.
* @param right the right position.
* @param bottom the bottom position.
* @param direction the direction.
* @param speed the speed.
* @param text the widget text.
* @return a new ScrollerWidget.
*/
public static ScrollerWidget construct(Screen screen,
int left,
int top,
int right,
int bottom,
char direction,
int speed,
String text)
{
ScrollerWidget widget = null;
try
{
widget = (ScrollerWidget)screen.constructWidget(
WIDGET_SCROLLER);
widget.setLeft(left);
widget.setTop(top);
widget.setRight(right);
widget.setBottom(bottom);
widget.setDirection(direction);
widget.setSpeed(speed);
widget.setText(text);
}
catch (LCDException e)
{
// Supress, would only get one if we asked for an invalid Widget.
}
return widget;
}
}