Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttributedTheme.java @ 9416:05405292a7ca
Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:28:03 +0200 |
parents | ea9eef426962 |
children |
comparison
equal
deleted
inserted
replaced
9415:9744ce3c3853 | 9416:05405292a7ca |
---|---|
16 /** | 16 /** |
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
18 */ | 18 */ |
19 public class AttributedTheme implements Theme { | 19 public class AttributedTheme implements Theme { |
20 | 20 |
21 protected Map<String, String> attributes; | 21 private static final long serialVersionUID = 1L; |
22 | |
23 private Map<String, String> attributes; | |
22 | 24 |
23 /** CollectionItem associated with this facet/themes artifact. */ | 25 /** CollectionItem associated with this facet/themes artifact. */ |
24 protected CollectionItem collectionItem; | 26 private CollectionItem collectionItem; |
25 | 27 |
26 public AttributedTheme() { | 28 public AttributedTheme() { |
27 this.attributes = new HashMap<String, String>(); | 29 this.attributes = new HashMap<String, String>(); |
28 } | 30 } |
29 | 31 |
32 /** Remark: only here so attributes is not final and serialization is happy */ | |
33 public void setAttributes(final Map<String, String> attributes) { | |
34 this.attributes = attributes; | |
35 } | |
30 | 36 |
31 public Set<String> getKeys() { | 37 public Set<String> getKeys() { |
32 return attributes.keySet(); | 38 return this.attributes.keySet(); |
33 } | 39 } |
34 | 40 |
35 | 41 public void addAttr(final String name, final String value) { |
36 public void addAttr(String name, String value) { | |
37 if (name != null && value != null) { | 42 if (name != null && value != null) { |
38 attributes.put(name, value); | 43 this.attributes.put(name, value); |
39 } | 44 } |
40 } | 45 } |
41 | 46 |
42 | 47 public String getAttr(final String name) { |
43 public String getAttr(String name) { | 48 return this.attributes.get(name); |
44 return attributes.get(name); | 49 } |
45 } | 50 |
46 | 51 public Integer getAttrAsInt(final String name) { |
47 | 52 final String attr = getAttr(name); |
48 public Integer getAttrAsInt(String name) { | |
49 String attr = getAttr(name); | |
50 | 53 |
51 if (attr != null && attr.length() > 0) { | 54 if (attr != null && attr.length() > 0) { |
52 try { | 55 try { |
53 return Integer.parseInt(attr); | 56 return Integer.parseInt(attr); |
54 } | 57 } |
55 catch (NumberFormatException nfe) { | 58 catch (final NumberFormatException nfe) { |
59 nfe.printStackTrace(); | |
56 } | 60 } |
57 } | 61 } |
58 | 62 |
59 return null; | 63 return null; |
60 } | 64 } |
61 | 65 |
62 | 66 public Double getAttrAsDouble(final String name) { |
63 public boolean getAttrAsBoolean(String name) { | 67 |
64 String attr = getAttr(name); | 68 final String attr = getAttr(name); |
69 if (attr == null || attr.isEmpty()) | |
70 return null; | |
71 | |
72 try { | |
73 return Double.parseDouble(attr); | |
74 } | |
75 catch (final NumberFormatException nfe) { | |
76 nfe.printStackTrace(); | |
77 return null; | |
78 } | |
79 } | |
80 | |
81 public boolean getAttrAsBoolean(final String name) { | |
82 final String attr = getAttr(name); | |
65 | 83 |
66 if (attr != null) { | 84 if (attr != null) { |
67 try { | 85 try { |
68 int num = Integer.valueOf(attr); | 86 final int num = Integer.valueOf(attr); |
69 return num > 0; | 87 return num > 0; |
70 } | 88 } |
71 catch (NumberFormatException nfe) { | 89 catch (final NumberFormatException nfe) { |
72 // do nothing | 90 // do nothing |
91 nfe.printStackTrace(); | |
73 } | 92 } |
74 } | 93 } |
75 | 94 |
76 return Boolean.valueOf(attr); | 95 return Boolean.valueOf(attr); |
77 } | 96 } |
78 | 97 |
79 | 98 |
80 @Override | 99 @Override |
81 public int getPosition() { | 100 public int getPosition() { |
82 Integer pos = getAttrAsInt("pos"); | 101 final Integer pos = getAttrAsInt("pos"); |
83 | 102 |
84 return pos != null ? pos.intValue() : -1; | 103 return pos != null ? pos.intValue() : -1; |
85 } | 104 } |
86 | 105 |
87 | 106 |
88 @Override | 107 @Override |
89 public void setPosition(int pos) { | 108 public void setPosition(final int pos) { |
90 addAttr("pos", String.valueOf(pos)); | 109 addAttr("pos", String.valueOf(pos)); |
91 } | 110 } |
92 | 111 |
93 | 112 |
94 @Override | 113 @Override |
95 public int getIndex() { | 114 public int getIndex() { |
96 Integer idx = getAttrAsInt("index"); | 115 final Integer idx = getAttrAsInt("index"); |
97 | 116 |
98 return idx != null ? idx.intValue() : -1; | 117 return idx != null ? idx.intValue() : -1; |
99 } | 118 } |
100 | 119 |
101 | 120 |
104 return getAttrAsInt("active"); | 123 return getAttrAsInt("active"); |
105 } | 124 } |
106 | 125 |
107 | 126 |
108 @Override | 127 @Override |
109 public void setActive(int active) { | 128 public void setActive(final int active) { |
110 addAttr("active", String.valueOf(active)); | 129 addAttr("active", String.valueOf(active)); |
111 } | 130 } |
112 | 131 |
113 | 132 |
114 @Override | 133 @Override |
128 return getAttr("description"); | 147 return getAttr("description"); |
129 } | 148 } |
130 | 149 |
131 | 150 |
132 @Override | 151 @Override |
133 public void setDescription(String description) { | 152 public void setDescription(final String description) { |
134 if (description != null && description.length() > 0) { | 153 if (description != null && description.length() > 0) { |
135 addAttr("description", description); | 154 addAttr("description", description); |
136 } | 155 } |
137 } | 156 } |
138 | 157 |
142 return getAttrAsInt("visible"); | 161 return getAttrAsInt("visible"); |
143 } | 162 } |
144 | 163 |
145 | 164 |
146 @Override | 165 @Override |
147 public void setVisible(int visible) { | 166 public void setVisible(final int visible) { |
148 addAttr("visible", String.valueOf(visible)); | 167 addAttr("visible", String.valueOf(visible)); |
149 } | 168 } |
150 | 169 |
151 | 170 |
152 @Override | 171 @Override |
153 public boolean equals(Object o) { | 172 public boolean equals(final Object o) { |
154 if (!(o instanceof AttributedTheme)) { | 173 if (!(o instanceof AttributedTheme)) { |
155 return false; | 174 return false; |
156 } | 175 } |
157 | 176 |
158 AttributedTheme other = (AttributedTheme) o; | 177 final AttributedTheme other = (AttributedTheme) o; |
159 | 178 |
160 if (other.getPosition() != getPosition()) { | 179 if (other.getPosition() != getPosition()) { |
161 return false; | 180 return false; |
162 } | 181 } |
163 | 182 |
186 } | 205 } |
187 | 206 |
188 return true; | 207 return true; |
189 } | 208 } |
190 | 209 |
191 | |
192 /** Get the CollectionItem representing the facets artifact. */ | 210 /** Get the CollectionItem representing the facets artifact. */ |
193 @Override | 211 @Override |
194 public CollectionItem getCollectionItem() { | 212 public CollectionItem getCollectionItem() { |
195 return collectionItem; | 213 return this.collectionItem; |
196 } | 214 } |
197 | |
198 | 215 |
199 /** Set the CollectionItem representing the facets artifact. */ | 216 /** Set the CollectionItem representing the facets artifact. */ |
200 @Override | 217 @Override |
201 public void setCollectionItem(CollectionItem ci) { | 218 public void setCollectionItem(final CollectionItem ci) { |
202 this.collectionItem = ci; | 219 this.collectionItem = ci; |
203 } | 220 } |
204 } | 221 } |
205 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |