Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/DifferencesState.java @ 4673:32f90baf4afa
Generate and draw new facets.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 13 Dec 2012 17:19:38 +0100 |
parents | da48e33f4241 |
children | c5c31299bca1 |
comparison
equal
deleted
inserted
replaced
4672:12e3da5724e6 | 4673:32f90baf4afa |
---|---|
34 private static Logger logger = Logger.getLogger(DifferencesState.class); | 34 private static Logger logger = Logger.getLogger(DifferencesState.class); |
35 public static final String I18N_DIFF_YEAR = "beddifference.year"; | 35 public static final String I18N_DIFF_YEAR = "beddifference.year"; |
36 public static final String I18N_DIFF_EPOCH = "beddifference.epoch"; | 36 public static final String I18N_DIFF_EPOCH = "beddifference.epoch"; |
37 | 37 |
38 public static final String I18N_FACET_BED_DIFF_YEAR = "facet.bedheight.diff.year"; | 38 public static final String I18N_FACET_BED_DIFF_YEAR = "facet.bedheight.diff.year"; |
39 public static final String I18N_FACET_BED_DIFF_YEAR_RAW = "facet.bedheight.diff.year.raw"; | |
39 public static final String I18N_FACET_BED_DIFF_ABSOLUTE = "facet.bedheight.diff.absolute"; | 40 public static final String I18N_FACET_BED_DIFF_ABSOLUTE = "facet.bedheight.diff.absolute"; |
41 public static final String I18N_FACET_BED_DIFF_ABSOLUTE_RAW = "facet.bedheight.diff.absolute.raw"; | |
40 public static final String I18N_FACET_BED_DIFF_MORPH = "facet.bedheight.diff.morph"; | 42 public static final String I18N_FACET_BED_DIFF_MORPH = "facet.bedheight.diff.morph"; |
41 public static final String I18N_FACET_BED_DIFF_EPOCH = "facet.bedheight.diff.epoch"; | 43 public static final String I18N_FACET_BED_DIFF_EPOCH = "facet.bedheight.diff.epoch"; |
44 public static final String I18N_FACET_BED_DIFF_EPOCH_RAW = "facet.bedheight.diff.epoch.raw"; | |
42 public static final String I18N_FACET_BED_DIFF_HEIGHT1 = "facet.bedheight.diff.height1"; | 45 public static final String I18N_FACET_BED_DIFF_HEIGHT1 = "facet.bedheight.diff.height1"; |
46 public static final String I18N_FACET_BED_DIFF_HEIGHT1_RAW = "facet.bedheight.diff.height1.raw"; | |
43 public static final String I18N_FACET_BED_DIFF_HEIGHT2 = "facet.bedheight.diff.height2"; | 47 public static final String I18N_FACET_BED_DIFF_HEIGHT2 = "facet.bedheight.diff.height2"; |
48 public static final String I18N_FACET_BED_DIFF_HEIGHT2_RAW = "facet.bedheight.diff.height2.raw"; | |
44 | 49 |
45 public DifferencesState() { | 50 public DifferencesState() { |
46 } | 51 } |
47 | 52 |
48 @Override | 53 @Override |
88 newFacets.add(new BedDiffYearFacet( | 93 newFacets.add(new BedDiffYearFacet( |
89 idx, | 94 idx, |
90 BED_DIFFERENCE_YEAR, | 95 BED_DIFFERENCE_YEAR, |
91 createBedDiffYearDescription( | 96 createBedDiffYearDescription( |
92 meta, | 97 meta, |
93 (BedDiffYearResult)results[idx]), | 98 (BedDiffYearResult)results[idx], |
99 false), | |
94 ComputeType.ADVANCE, | 100 ComputeType.ADVANCE, |
95 stateId, | 101 stateId, |
96 hash)); | 102 hash)); |
97 newFacets.add(new BedDiffYearFacet( | 103 newFacets.add(new BedDiffYearFacet( |
98 idx, | 104 idx, |
107 idx, | 113 idx, |
108 BED_DIFFERENCE_YEAR_HEIGHT1, | 114 BED_DIFFERENCE_YEAR_HEIGHT1, |
109 createBedDiffHeightDescription( | 115 createBedDiffHeightDescription( |
110 meta, | 116 meta, |
111 (BedDiffYearResult)results[idx], | 117 (BedDiffYearResult)results[idx], |
112 0), | 118 0, |
119 false), | |
113 ComputeType.ADVANCE, | 120 ComputeType.ADVANCE, |
114 stateId, | 121 stateId, |
115 hash)); | 122 hash)); |
116 newFacets.add(new BedDiffYearFacet( | 123 newFacets.add(new BedDiffYearFacet( |
117 idx, | 124 idx, |
118 BED_DIFFERENCE_YEAR_HEIGHT2, | 125 BED_DIFFERENCE_YEAR_HEIGHT2, |
119 createBedDiffHeightDescription( | 126 createBedDiffHeightDescription( |
120 meta, | 127 meta, |
121 (BedDiffYearResult)results[idx], | 128 (BedDiffYearResult)results[idx], |
122 1), | 129 1, |
130 false), | |
123 ComputeType.ADVANCE, | 131 ComputeType.ADVANCE, |
124 stateId, | 132 stateId, |
125 hash)); | 133 hash)); |
126 newFacets.add(new BedDiffYearFacet( | 134 newFacets.add(new BedDiffYearFacet( |
127 idx, | 135 idx, |
128 BED_DIFFERENCE_HEIGHT_YEAR, | 136 BED_DIFFERENCE_HEIGHT_YEAR, |
129 createBedDiffAbsoluteDescription( | 137 createBedDiffAbsoluteDescription( |
130 meta, | 138 meta, |
131 (BedDiffYearResult)results[idx]), | 139 (BedDiffYearResult)results[idx], |
140 false), | |
141 ComputeType.ADVANCE, | |
142 stateId, | |
143 hash)); | |
144 newFacets.add(new BedDiffYearFacet( | |
145 idx, | |
146 BED_DIFFERENCE_YEAR_FILTERED, | |
147 createBedDiffYearDescription( | |
148 meta, | |
149 (BedDiffYearResult)results[idx], | |
150 true), | |
151 ComputeType.ADVANCE, | |
152 stateId, | |
153 hash)); | |
154 newFacets.add(new BedDiffYearFacet( | |
155 idx, | |
156 BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED, | |
157 createBedDiffHeightDescription( | |
158 meta, | |
159 (BedDiffYearResult)results[idx], | |
160 0, | |
161 true), | |
162 ComputeType.ADVANCE, | |
163 stateId, | |
164 hash)); | |
165 newFacets.add(new BedDiffYearFacet( | |
166 idx, | |
167 BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED, | |
168 createBedDiffHeightDescription( | |
169 meta, | |
170 (BedDiffYearResult)results[idx], | |
171 1, | |
172 true), | |
173 ComputeType.ADVANCE, | |
174 stateId, | |
175 hash)); | |
176 newFacets.add(new BedDiffYearFacet( | |
177 idx, | |
178 BED_DIFFERENCE_HEIGHT_YEAR_FILTERED, | |
179 createBedDiffAbsoluteDescription( | |
180 meta, | |
181 (BedDiffYearResult)results[idx], | |
182 true), | |
132 ComputeType.ADVANCE, | 183 ComputeType.ADVANCE, |
133 stateId, | 184 stateId, |
134 hash)); | 185 hash)); |
135 } | 186 } |
136 if (results[idx] instanceof BedDiffEpochResult) { | 187 if (results[idx] instanceof BedDiffEpochResult) { |
137 newFacets.add(new BedDiffEpochFacet( | 188 newFacets.add(new BedDiffEpochFacet( |
138 idx, | 189 idx, |
139 BED_DIFFERENCE_EPOCH, | 190 BED_DIFFERENCE_EPOCH, |
140 createBedDiffEpochDescription( | 191 createBedDiffEpochDescription( |
141 meta, | 192 meta, |
142 (BedDiffEpochResult)results[idx]), | 193 (BedDiffEpochResult)results[idx], |
194 false), | |
143 ComputeType.ADVANCE, | 195 ComputeType.ADVANCE, |
144 stateId, | 196 stateId, |
145 hash)); | 197 hash)); |
146 newFacets.add(new BedDiffEpochFacet( | 198 newFacets.add(new BedDiffEpochFacet( |
147 idx, | 199 idx, |
148 BED_DIFFERENCE_EPOCH_HEIGHT1, | 200 BED_DIFFERENCE_EPOCH_HEIGHT1, |
149 createBedDiffHeightEpochDescription( | 201 createBedDiffHeightEpochDescription( |
150 meta, | 202 meta, |
151 (BedDiffEpochResult)results[idx], | 203 (BedDiffEpochResult)results[idx], |
152 0), | 204 0, |
205 false), | |
153 ComputeType.ADVANCE, | 206 ComputeType.ADVANCE, |
154 stateId, | 207 stateId, |
155 hash)); | 208 hash)); |
156 newFacets.add(new BedDiffEpochFacet( | 209 newFacets.add(new BedDiffEpochFacet( |
157 idx, | 210 idx, |
158 BED_DIFFERENCE_EPOCH_HEIGHT2, | 211 BED_DIFFERENCE_EPOCH_HEIGHT2, |
159 createBedDiffHeightEpochDescription( | 212 createBedDiffHeightEpochDescription( |
160 meta, | 213 meta, |
161 (BedDiffEpochResult)results[idx], | 214 (BedDiffEpochResult)results[idx], |
162 1), | 215 1, |
163 ComputeType.ADVANCE, | 216 false), |
164 stateId, | 217 ComputeType.ADVANCE, |
165 hash)); | 218 stateId, |
166 | 219 hash)); |
220 newFacets.add(new BedDiffEpochFacet( | |
221 idx, | |
222 BED_DIFFERENCE_EPOCH_FILTERED, | |
223 createBedDiffEpochDescription( | |
224 meta, | |
225 (BedDiffEpochResult)results[idx], | |
226 true), | |
227 ComputeType.ADVANCE, | |
228 stateId, | |
229 hash)); | |
230 newFacets.add(new BedDiffEpochFacet( | |
231 idx, | |
232 BED_DIFFERENCE_EPOCH_HEIGHT1_FILTERED, | |
233 createBedDiffHeightEpochDescription( | |
234 meta, | |
235 (BedDiffEpochResult)results[idx], | |
236 0, | |
237 true), | |
238 ComputeType.ADVANCE, | |
239 stateId, | |
240 hash)); | |
241 newFacets.add(new BedDiffEpochFacet( | |
242 idx, | |
243 BED_DIFFERENCE_EPOCH_HEIGHT2_FILTERED, | |
244 createBedDiffHeightEpochDescription( | |
245 meta, | |
246 (BedDiffEpochResult)results[idx], | |
247 1, | |
248 true), | |
249 ComputeType.ADVANCE, | |
250 stateId, | |
251 hash)); | |
167 } | 252 } |
168 } | 253 } |
169 } | 254 } |
170 | 255 |
171 private String createBedDiffHeightDescription( | 256 private String createBedDiffHeightDescription( |
172 CallMeta meta, | 257 CallMeta meta, |
173 BedDiffYearResult result, | 258 BedDiffYearResult result, |
174 int ndx | 259 int ndx, |
260 boolean raw | |
175 ) { | 261 ) { |
176 String range = result.getStart() + " - " + result.getEnd(); | 262 String range = result.getStart() + " - " + result.getEnd(); |
177 | 263 |
264 String i18nHeight1 = I18N_FACET_BED_DIFF_HEIGHT1; | |
265 String i18nHeight2 = I18N_FACET_BED_DIFF_HEIGHT2; | |
266 if (raw) { | |
267 i18nHeight1 = I18N_FACET_BED_DIFF_HEIGHT1_RAW; | |
268 i18nHeight2 = I18N_FACET_BED_DIFF_HEIGHT2_RAW; | |
269 } | |
178 if (ndx == 0) { | 270 if (ndx == 0) { |
179 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_HEIGHT1, | 271 return Resources.getMsg(meta, i18nHeight1, |
180 I18N_FACET_BED_DIFF_HEIGHT1, new Object[] { range }); | 272 i18nHeight2, new Object[] { range }); |
181 } | 273 } |
182 else { | 274 else { |
183 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_HEIGHT2, | 275 return Resources.getMsg(meta, i18nHeight1, |
184 I18N_FACET_BED_DIFF_HEIGHT2, new Object[] {range}); | 276 i18nHeight2, new Object[] {range}); |
185 } | 277 } |
186 } | 278 } |
187 | 279 |
188 private String createBedDiffHeightEpochDescription( | 280 private String createBedDiffHeightEpochDescription( |
189 CallMeta meta, | 281 CallMeta meta, |
190 BedDiffEpochResult result, | 282 BedDiffEpochResult result, |
191 int ndx | 283 int ndx, |
284 boolean raw | |
192 ) { | 285 ) { |
193 DateFormat df = Formatter.getDateFormatter(meta, "yyyy"); | 286 DateFormat df = Formatter.getDateFormatter(meta, "yyyy"); |
194 String range = | 287 String range = |
195 df.format(result.getStart()) | 288 df.format(result.getStart()) |
196 + " - " + | 289 + " - " + |
197 df.format(result.getEnd()); | 290 df.format(result.getEnd()); |
198 | 291 |
292 String i18nHeight1 = I18N_FACET_BED_DIFF_HEIGHT1; | |
293 String i18nHeight2 = I18N_FACET_BED_DIFF_HEIGHT2; | |
294 if (raw) { | |
295 i18nHeight1 = I18N_FACET_BED_DIFF_HEIGHT1_RAW; | |
296 i18nHeight2 = I18N_FACET_BED_DIFF_HEIGHT2_RAW; | |
297 } | |
199 if (ndx == 0) { | 298 if (ndx == 0) { |
200 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_HEIGHT1, | 299 return Resources.getMsg(meta, i18nHeight1, |
201 I18N_FACET_BED_DIFF_HEIGHT1, new Object[] { range }); | 300 i18nHeight1, new Object[] { range }); |
202 } | 301 } |
203 else { | 302 else { |
204 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_HEIGHT2, | 303 return Resources.getMsg(meta, i18nHeight2, |
205 I18N_FACET_BED_DIFF_HEIGHT2, new Object[] {range}); | 304 i18nHeight2, new Object[] {range}); |
206 } | 305 } |
207 } | 306 } |
208 | 307 |
209 protected String createBedDiffYearDescription( | 308 protected String createBedDiffYearDescription( |
309 CallMeta meta, | |
310 BedDiffYearResult result, | |
311 boolean raw | |
312 ) { | |
313 String range = result.getStart() + " - " + result.getEnd(); | |
314 | |
315 String i18n = I18N_FACET_BED_DIFF_YEAR; | |
316 if (raw) { | |
317 i18n = I18N_FACET_BED_DIFF_YEAR_RAW; | |
318 } | |
319 return Resources.getMsg(meta, i18n, i18n, new Object[] { range }); | |
320 } | |
321 | |
322 protected String createBedDiffMorphDescription( | |
210 CallMeta meta, | 323 CallMeta meta, |
211 BedDiffYearResult result) { | 324 BedDiffYearResult result) { |
212 String range = result.getStart() + " - " + result.getEnd(); | 325 String range = result.getStart() + " - " + result.getEnd(); |
213 | 326 |
214 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_YEAR, | |
215 I18N_FACET_BED_DIFF_YEAR, new Object[] { range }); | |
216 } | |
217 | |
218 protected String createBedDiffMorphDescription( | |
219 CallMeta meta, | |
220 BedDiffYearResult result) { | |
221 String range = result.getStart() + " - " + result.getEnd(); | |
222 | |
223 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_MORPH, | 327 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_MORPH, |
224 I18N_FACET_BED_DIFF_MORPH, new Object[] { range }); | 328 I18N_FACET_BED_DIFF_MORPH, new Object[] { range }); |
225 } | 329 } |
226 | 330 |
227 protected String createBedDiffAbsoluteDescription( | 331 protected String createBedDiffAbsoluteDescription( |
228 CallMeta meta, | 332 CallMeta meta, |
229 BedDiffYearResult result) { | 333 BedDiffYearResult result, |
334 boolean raw | |
335 ) { | |
230 String range = result.getStart() + " - " + result.getEnd(); | 336 String range = result.getStart() + " - " + result.getEnd(); |
231 | 337 |
232 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_ABSOLUTE, | 338 String i18n = I18N_FACET_BED_DIFF_ABSOLUTE; |
233 I18N_FACET_BED_DIFF_ABSOLUTE, new Object[] { range }); | 339 if (raw) { |
340 i18n = I18N_FACET_BED_DIFF_ABSOLUTE_RAW; | |
341 } | |
342 return Resources.getMsg(meta, i18n, i18n, new Object[] { range }); | |
234 } | 343 } |
235 | 344 |
236 protected String createBedDiffEpochDescription( | 345 protected String createBedDiffEpochDescription( |
237 CallMeta meta, | 346 CallMeta meta, |
238 BedDiffEpochResult result) { | 347 BedDiffEpochResult result, |
348 boolean raw) { | |
239 DateFormat df = Formatter.getDateFormatter(meta, "yyyy"); | 349 DateFormat df = Formatter.getDateFormatter(meta, "yyyy"); |
240 String range = | 350 String range = |
241 df.format(result.getStart()) | 351 df.format(result.getStart()) |
242 + " - " + | 352 + " - " + |
243 df.format(result.getEnd()); | 353 df.format(result.getEnd()); |
244 | 354 |
245 return Resources.getMsg(meta, I18N_FACET_BED_DIFF_EPOCH, | 355 String i18n = I18N_FACET_BED_DIFF_EPOCH; |
246 I18N_FACET_BED_DIFF_EPOCH, new Object[] { range }); | 356 if (raw) { |
357 i18n = I18N_FACET_BED_DIFF_EPOCH_RAW; | |
358 } | |
359 return Resources.getMsg(meta, i18n, i18n, new Object[] { range }); | |
247 } | 360 } |
248 } | 361 } |