1 package org.informagen.echo.app;
2
3
4 import nextapp.echo.app.Component;
5 import nextapp.echo.app.Color;
6 import nextapp.echo.app.Extent;
7
8 import java.lang.Number;
9
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
13
14
15
16
17
18
19 public class CapacityBar extends Component {
20
21
22 public static final String PROPERTY_WIDTH = "width";
23 public static final String PROPERTY_HEIGHT = "height";
24 public static final String PROPERTY_SHOW_TICKS = "showTicks";
25 public static final String PROPERTY_REFLECTIVITY = "reflectivity";
26 public static final String PROPERTY_CORNER_RADIUS = "cornerRadius";
27
28
29 public static final String PROPERTY_TICK_SPACING = "tickSpacing";
30 public static final String PROPERTY_COLORS = "colors";
31 public static final String PROPERTY_VALUES = "values";
32
33 private Extent width = new Extent(460, Extent.PX);
34 private Extent height = new Extent(18, Extent.PX);
35 private boolean showTicks = true;
36 private double reflectivity = 0.75;
37 private double cornerRadius = 1.0;
38
39 private Number tickSpacing = null;
40
41 private List<Color> colors = Collections.EMPTY_LIST;
42 private List<Number> values = Collections.EMPTY_LIST;
43
44 public CapacityBar() {
45 super();
46 }
47
48
49 public CapacityBar(int height, int width) {
50 super();
51
52 setHeight(height);
53 setWidth(width);
54 }
55
56
57
58
59
60
61
62
63
64 public void setWidth(int width) {
65 setWidth(new Extent(width, Extent.PX));
66 }
67
68 public void setWidth(Extent width) {
69 Extent oldWidth = this.width;
70 this.width = width;
71 firePropertyChange(PROPERTY_WIDTH, oldWidth, width);
72 }
73
74
75
76
77
78
79
80 public Extent getWidth() {
81 return width;
82 }
83
84
85
86
87
88
89
90
91
92 public void setHeight(int height) {
93 setHeight(new Extent(height, Extent.PX));
94 }
95
96 public void setHeight(Extent height) {
97 Extent oldHeight = this.height;
98 this.height = height;
99 firePropertyChange(PROPERTY_HEIGHT, oldHeight, height);
100 }
101
102
103
104
105
106
107
108
109 public Extent getHeight() {
110 return height;
111 }
112
113
114
115
116
117
118
119
120
121 public void setShowTicks(boolean showTicks) {
122 Boolean oldShowTicks = this.showTicks ? Boolean.TRUE : Boolean.FALSE;
123 this.showTicks = showTicks;
124 firePropertyChange(PROPERTY_SHOW_TICKS, oldShowTicks, showTicks ? Boolean.TRUE : Boolean.FALSE);
125 }
126
127
128
129
130
131
132
133
134 public boolean isShowTicks() {
135 return showTicks;
136 }
137
138
139
140
141
142
143
144
145
146 public void setReflectivity(double reflectivity) {
147 Double oldValue = new Double(this.reflectivity);
148
149
150 reflectivity = Math.max(reflectivity, 0.001);
151 reflectivity = Math.min(reflectivity, 1.00);
152
153 this.reflectivity = reflectivity;
154 firePropertyChange(PROPERTY_REFLECTIVITY, oldValue, new Double(reflectivity));
155 }
156
157
158
159
160
161
162
163
164 public double getReflectivity() {
165 return reflectivity;
166 }
167
168
169
170
171
172
173
174
175
176 public void setCornerRadius(double cornerRadius) {
177 Double oldCornerRadius = new Double(this.cornerRadius);
178
179
180 cornerRadius = Math.max(cornerRadius, 0.001);
181 cornerRadius = Math.min(cornerRadius, 1.00);
182
183 this.cornerRadius = cornerRadius;
184 firePropertyChange(PROPERTY_CORNER_RADIUS, oldCornerRadius, new Double(cornerRadius));
185 }
186
187
188
189
190
191
192
193
194 public double getCornerRadius() {
195 return cornerRadius;
196 }
197
198
199
200
201
202
203
204
205
206 public void setTickSpacing(Number tickSpacing) {
207 Number oldTickSpacing = this.tickSpacing;
208
209 this.tickSpacing = tickSpacing;
210 firePropertyChange(PROPERTY_TICK_SPACING, oldTickSpacing, tickSpacing);
211 }
212
213
214
215
216
217
218
219
220 public Number getTickSpacing() {
221 return tickSpacing;
222 }
223
224
225
226
227
228
229
230
231
232 public void setColors(List<Color> colors) {
233 List oldColors = this.colors;
234
235 this.colors = colors;
236 firePropertyChange(PROPERTY_COLORS, oldColors, colors);
237 }
238
239
240
241
242
243
244
245
246 public List<Color> getColors() {
247 return colors;
248 }
249
250
251
252
253
254
255
256
257
258 public void setValues(List<Number> values) {
259 List oldValues = this.values;
260
261 this.values = values;
262 firePropertyChange(PROPERTY_VALUES, oldValues, values);
263 }
264
265
266
267
268
269
270
271
272 public List<Number> getValues() {
273 return values;
274 }
275
276
277
278 }
279