Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/shared/model/DoubleArrayData.java @ 1595:e53d773e6992
Display inserted W/Q values in WQSimpleArrayPanel.
flys-client/trunk@3908 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 03 Feb 2012 15:27:46 +0000 |
parents | 0f2b94408bd1 |
children | d0a9acddbea2 |
comparison
equal
deleted
inserted
replaced
1594:ddf43791244c | 1595:e53d773e6992 |
---|---|
2 | 2 |
3 | 3 |
4 /** | 4 /** |
5 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 5 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
6 */ | 6 */ |
7 public class DoubleArrayData extends DefaultData { | 7 public class DoubleArrayData implements Data { |
8 | 8 |
9 public static final String TYPE = "doublearray"; | 9 public static final String TYPE = "doublearray"; |
10 | 10 |
11 | 11 |
12 protected String label; | |
13 protected String description; | |
14 | |
15 protected double[] values; | |
16 | |
17 | |
12 public DoubleArrayData() { | 18 public DoubleArrayData() { |
13 super(); | |
14 } | 19 } |
15 | 20 |
16 | 21 |
17 public DoubleArrayData(String name, String description, DataItem[] items) { | 22 public DoubleArrayData(String label, String description, double[] values) { |
18 super(name, description, TYPE, items); | 23 this.label = label; |
24 this.description = description; | |
25 this.values = values; | |
26 } | |
27 | |
28 | |
29 /** | |
30 * Returns the label of the item. | |
31 * | |
32 * @return the label. | |
33 */ | |
34 public String getLabel() { | |
35 return label; | |
36 } | |
37 | |
38 | |
39 /** | |
40 * Returns the description of the item. | |
41 * | |
42 * @return the description. | |
43 */ | |
44 public String getDescription() { | |
45 return description; | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Returns the type of the item. | |
51 * | |
52 * @return the type. | |
53 */ | |
54 public String getType() { | |
55 return TYPE; | |
56 } | |
57 | |
58 | |
59 /** | |
60 * Returns a DataItem which value is a string that consists of the double | |
61 * values separated by a ';'. | |
62 * | |
63 * @return the DataItem. | |
64 */ | |
65 public DataItem[] getItems() { | |
66 if (values == null || values.length == 0) { | |
67 return new DataItem[0]; | |
68 } | |
69 | |
70 StringBuilder sb = new StringBuilder(); | |
71 boolean first = true; | |
72 | |
73 for (double value: values) { | |
74 if (first) { | |
75 sb.append(String.valueOf(value)); | |
76 } | |
77 else { | |
78 sb.append(";" + String.valueOf(value)); | |
79 } | |
80 } | |
81 | |
82 String value = sb.toString(); | |
83 DataItem item = new DefaultDataItem(value, value, value); | |
84 | |
85 return new DataItem[] { item }; | |
86 } | |
87 | |
88 | |
89 /** | |
90 * Returns the values as array. | |
91 * | |
92 * @return the values as array. | |
93 */ | |
94 public double[] getValues() { | |
95 return values; | |
96 } | |
97 | |
98 | |
99 /** | |
100 * @return always null. | |
101 */ | |
102 public DataItem getDefault() { | |
103 return null; | |
19 } | 104 } |
20 } | 105 } |
21 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |