Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java @ 8585:e9343e4c9ae0
Reduce duplicated functions to obtain layer descritpions for bedquality
This should make it easier to reuse those for interpolation facets.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 17 Mar 2015 16:37:17 +0100 |
parents | b0d7b0d79d6e |
children | 07c9ac22f611 |
comparison
equal
deleted
inserted
replaced
8584:ce325339e9ba | 8585:e9343e4c9ae0 |
---|---|
52 .getLogger(BedQualityState.class); | 52 .getLogger(BedQualityState.class); |
53 | 53 |
54 public static final String I18N_TOPLAYER = "bedquality.toplayer"; | 54 public static final String I18N_TOPLAYER = "bedquality.toplayer"; |
55 public static final String I18N_SUBLAYER = "bedquality.sublayer"; | 55 public static final String I18N_SUBLAYER = "bedquality.sublayer"; |
56 | 56 |
57 /* Calculated layers */ | |
57 public static final String I18N_FACET_BED_POROSITY_TOPLAYER = "facet.bedquality.bed.porosity.toplayer"; | 58 public static final String I18N_FACET_BED_POROSITY_TOPLAYER = "facet.bedquality.bed.porosity.toplayer"; |
58 public static final String I18N_FACET_BED_POROSITY_SUBLAYER = "facet.bedquality.bed.porosity.sublayer"; | 59 public static final String I18N_FACET_BED_POROSITY_SUBLAYER = "facet.bedquality.bed.porosity.sublayer"; |
59 public static final String I18N_FACET_BED_DENSITY_TOPLAYER = "facet.bedquality.bed.density.toplayer"; | 60 public static final String I18N_FACET_BED_DENSITY_TOPLAYER = "facet.bedquality.bed.density.toplayer"; |
60 public static final String I18N_FACET_BED_DENSITY_SUBLAYER = "facet.bedquality.bed.density.sublayer"; | 61 public static final String I18N_FACET_BED_DENSITY_SUBLAYER = "facet.bedquality.bed.density.sublayer"; |
61 public static final String I18N_FACET_BED_DIAMETER_TOPLAYER = "facet.bedquality.bed.diameter.toplayer"; | 62 public static final String I18N_FACET_BED_DIAMETER_TOPLAYER = "facet.bedquality.bed.diameter.toplayer"; |
62 public static final String I18N_FACET_BED_DIAMETER_SUBLAYER = "facet.bedquality.bed.diameter.sublayer"; | 63 public static final String I18N_FACET_BED_DIAMETER_SUBLAYER = "facet.bedquality.bed.diameter.sublayer"; |
64 public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; | |
65 | |
66 /* Data Layers */ | |
67 public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; | |
63 public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer"; | 68 public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer"; |
64 public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer"; | 69 public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer"; |
65 public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; | |
66 public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; | |
67 | 70 |
68 static { | 71 static { |
69 // Active/deactivate facets. | 72 // Active/deactivate facets. |
70 FacetActivity.Registry.getInstance().register( | 73 FacetActivity.Registry.getInstance().register( |
71 "minfo", | 74 "minfo", |
265 DateRange range = result.getDateRange(); | 268 DateRange range = result.getDateRange(); |
266 BedDiameterResult[] bedDiameter = result.getBedResults(); | 269 BedDiameterResult[] bedDiameter = result.getBedResults(); |
267 for (int j = 0; j < bedDiameter.length; j++) { | 270 for (int j = 0; j < bedDiameter.length; j++) { |
268 newFacets.add(new BedDiameterTopFacet((idx << 8) + j, | 271 newFacets.add(new BedDiameterTopFacet((idx << 8) + j, |
269 BED_QUALITY_BED_DIAMETER_TOPLAYER, | 272 BED_QUALITY_BED_DIAMETER_TOPLAYER, |
270 createDiameterTopLayerDescription( | 273 getLayerDescription( |
271 meta, | 274 meta, |
272 bedDiameter[j], | 275 bedDiameter[j], |
273 range), | 276 range, |
277 I18N_FACET_BED_DIAMETER_TOPLAYER, | |
278 true), | |
274 ComputeType.ADVANCE, stateId, hash)); | 279 ComputeType.ADVANCE, stateId, hash)); |
275 | 280 |
276 newFacets.add(new BedDiameterSubFacet((idx << 8) +j, | 281 newFacets.add(new BedDiameterSubFacet((idx << 8) +j, |
277 BED_QUALITY_BED_DIAMETER_SUBLAYER, | 282 BED_QUALITY_BED_DIAMETER_SUBLAYER, |
278 createDiameterSubLayerDescription( | 283 getLayerDescription( |
279 meta, | 284 meta, |
280 bedDiameter[j], | 285 bedDiameter[j], |
281 range), | 286 range, |
287 I18N_FACET_BED_DIAMETER_SUBLAYER, | |
288 false), | |
282 ComputeType.ADVANCE, stateId, hash)); | 289 ComputeType.ADVANCE, stateId, hash)); |
283 } | 290 } |
284 BedloadDiameterResult[] bedloadDiameter = result.getBedloadResults(); | 291 BedloadDiameterResult[] bedloadDiameter = result.getBedloadResults(); |
285 for (int j = 0; j < bedloadDiameter.length; j++) { | 292 for (int j = 0; j < bedloadDiameter.length; j++) { |
286 newFacets.add(new BedloadDiameterFacet( | 293 newFacets.add(new BedloadDiameterFacet( |
296 if (bedDiameter.length > 0) { | 303 if (bedDiameter.length > 0) { |
297 BedParametersResult[] bedParameters = result.getParameters(); | 304 BedParametersResult[] bedParameters = result.getParameters(); |
298 for (int j = 0; j < bedParameters.length; j++) { | 305 for (int j = 0; j < bedParameters.length; j++) { |
299 newFacets.add(new BedPorosityTopFacet((idx << 8) + j, | 306 newFacets.add(new BedPorosityTopFacet((idx << 8) + j, |
300 BED_QUALITY_POROSITY_TOPLAYER, | 307 BED_QUALITY_POROSITY_TOPLAYER, |
301 createPorosityTopLayerDescription( | 308 getLayerDescription( |
302 meta, | 309 meta, |
303 bedParameters[j], | 310 bedParameters[j], |
304 range), | 311 range, |
312 I18N_FACET_BED_POROSITY_TOPLAYER, | |
313 true), | |
305 ComputeType.ADVANCE, stateId, hash)); | 314 ComputeType.ADVANCE, stateId, hash)); |
306 | 315 |
307 newFacets.add(new BedPorositySubFacet((idx << 8) + j, | 316 newFacets.add(new BedPorositySubFacet((idx << 8) + j, |
308 BED_QUALITY_POROSITY_SUBLAYER, | 317 BED_QUALITY_POROSITY_SUBLAYER, |
309 createPorositySubLayerDescription( | 318 getLayerDescription( |
310 meta, | 319 meta, |
311 bedParameters[j], | 320 bedParameters[j], |
312 range), | 321 range, |
322 I18N_FACET_BED_POROSITY_SUBLAYER, | |
323 false), | |
313 ComputeType.ADVANCE, stateId, hash)); | 324 ComputeType.ADVANCE, stateId, hash)); |
314 | 325 |
315 newFacets.add(new BedDensityTopFacet((idx << 8) + j, | 326 newFacets.add(new BedDensityTopFacet((idx << 8) + j, |
316 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, | 327 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, |
317 createDensityTopLayerDescription( | 328 getLayerDescription( |
318 meta, | 329 meta, |
319 bedParameters[j], | 330 bedParameters[j], |
320 range), | 331 range, |
332 I18N_FACET_BED_DENSITY_TOPLAYER, | |
333 true), | |
321 ComputeType.ADVANCE, stateId, hash)); | 334 ComputeType.ADVANCE, stateId, hash)); |
322 | 335 |
323 newFacets.add(new BedDensitySubFacet((idx << 8) + j, | 336 newFacets.add(new BedDensitySubFacet((idx << 8) + j, |
324 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, | 337 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, |
325 createDensitySubLayerDescription( | 338 getLayerDescription( |
326 meta, | 339 meta, |
327 bedParameters[j], | 340 bedParameters[j], |
328 range), | 341 range, |
342 I18N_FACET_BED_DENSITY_SUBLAYER, | |
343 false), | |
329 ComputeType.ADVANCE, stateId, hash)); | 344 ComputeType.ADVANCE, stateId, hash)); |
330 } | 345 } |
331 } | 346 } |
332 } | 347 } |
333 } | 348 } |
334 | 349 |
335 protected String createPorosityTopLayerDescription(CallMeta meta, | 350 protected String getLayerDescription(CallMeta meta, |
336 BedParametersResult result, DateRange range) { | 351 Object result, DateRange range, String i18n, boolean topLayer) { |
337 Date from = range != null ? range.getFrom() : new Date(); | 352 Date from = range != null ? range.getFrom() : new Date(); |
338 Date to = range != null ? range.getTo() : new Date(); | 353 Date to = range != null ? range.getTo() : new Date(); |
339 | 354 |
340 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); | 355 String layer; |
341 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_TOPLAYER, | 356 /* Maybe just a check if i18n ends with .sublayer? */ |
342 I18N_FACET_BED_POROSITY_TOPLAYER, new Object[] { from, to, toplayer }); | 357 if (topLayer) { |
343 } | 358 layer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); |
344 | 359 } else { |
345 protected String createPorositySubLayerDescription(CallMeta meta, | 360 layer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); |
346 BedParametersResult result, DateRange range) { | 361 } |
347 Date from = range != null ? range.getFrom() : new Date(); | 362 if (result instanceof BedDiameterResult) { |
348 Date to = range != null ? range.getTo() : new Date(); | 363 return Resources.getMsg(meta, i18n, i18n, new Object[] { ((BedDiameterResult)result).getType(), |
349 | 364 from, to, layer }); |
350 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); | 365 } else { |
351 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_SUBLAYER, | 366 return Resources.getMsg(meta, i18n, i18n, new Object[] { from, to, layer }); |
352 I18N_FACET_BED_POROSITY_SUBLAYER, new Object[] { from, to, sublayer }); | 367 } |
353 } | |
354 | |
355 protected String createDensityTopLayerDescription(CallMeta meta, | |
356 BedParametersResult result, DateRange range) { | |
357 Date from = range != null ? range.getFrom() : new Date(); | |
358 Date to = range != null ? range.getTo() : new Date(); | |
359 | |
360 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); | |
361 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_TOPLAYER, | |
362 I18N_FACET_BED_DENSITY_TOPLAYER, new Object[] { from, to, toplayer }); | |
363 } | |
364 | |
365 protected String createDensitySubLayerDescription(CallMeta meta, | |
366 BedParametersResult result, DateRange range) { | |
367 Date from = range != null ? range.getFrom() : new Date(); | |
368 Date to = range != null ? range.getTo() : new Date(); | |
369 | |
370 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); | |
371 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_SUBLAYER, | |
372 I18N_FACET_BED_DENSITY_SUBLAYER, new Object[] { from, to, sublayer }); | |
373 } | |
374 | |
375 protected String createDiameterTopLayerDescription(CallMeta meta, | |
376 BedDiameterResult result, DateRange range) { | |
377 Date from = range != null ? range.getFrom() : new Date(); | |
378 Date to = range != null ? range.getTo() : new Date(); | |
379 | |
380 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); | |
381 | |
382 return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_TOPLAYER, | |
383 I18N_FACET_BED_DIAMETER_TOPLAYER, new Object[] { result.getType(), | |
384 from, to, toplayer }); | |
385 } | |
386 | |
387 protected String createDiameterSubLayerDescription(CallMeta meta, | |
388 BedDiameterResult result, DateRange range) { | |
389 Date from = range != null ? range.getFrom() : new Date(); | |
390 Date to = range != null ? range.getTo() : new Date(); | |
391 | |
392 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); | |
393 return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_SUBLAYER, | |
394 I18N_FACET_BED_DIAMETER_SUBLAYER, new Object[] { result.getType(), | |
395 from, to, sublayer }); | |
396 } | 368 } |
397 | 369 |
398 protected String createDiameterDescription(CallMeta meta, | 370 protected String createDiameterDescription(CallMeta meta, |
399 BedQualityDiameterResult result) { | 371 BedQualityDiameterResult result) { |
400 return Resources.getMsg(meta, I18N_FACET_BEDLOAD_DIAMETER, | 372 return Resources.getMsg(meta, I18N_FACET_BEDLOAD_DIAMETER, |