Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 1080:01e26528bb39
Some code refactoring for the implementation of histograms using vectorial parameters.
gnv-artifacts/trunk@1182 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Jun 2010 09:37:57 +0000 |
parents | 6169ddc827ac |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
1079:1657ee3ac054 | 1080:01e26528bb39 |
---|---|
400 ); | 400 ); |
401 } | 401 } |
402 } | 402 } |
403 // HISTOGRAM | 403 // HISTOGRAM |
404 else if (outputMode.equalsIgnoreCase("histogram")) { | 404 else if (outputMode.equalsIgnoreCase("histogram")) { |
405 Collection results = (Collection) getChartResult(uuid, callContext); | |
406 requestParameter.put("locale", locale); | 405 requestParameter.put("locale", locale); |
407 | 406 |
408 Object[][] data = HistogramHelper.prepareHistogramData( | 407 Chart[] histograms = getHistograms( |
409 results, parameters, measurements, dates); | 408 uuid, |
410 | 409 callContext, |
411 int size = data.length; | 410 parameters, |
412 Chart[] histograms = new Chart[size]; | 411 measurements, |
413 | 412 dates, |
414 for (int i = 0; i < size; i++) { | 413 requestParameter); |
415 ChartLabels labels = createHistogramLabels( | |
416 uuid, callContext, locale, data[i]); | |
417 | |
418 ChartTheme theme = createStyle(callContext); | |
419 | |
420 histograms[i] = new DefaultHistogram( | |
421 labels, data[i], theme, requestParameter); | |
422 } | |
423 | 414 |
424 if (mode.equalsIgnoreCase("img")) { | 415 if (mode.equalsIgnoreCase("img")) { |
425 ChartExportHelper.exportHistograms( | 416 ChartExportHelper.exportHistograms( |
426 outputStream, | 417 outputStream, |
427 histograms, | 418 histograms, |
497 log.error(e, e); | 488 log.error(e, e); |
498 throw new StateException(e); | 489 throw new StateException(e); |
499 } | 490 } |
500 } | 491 } |
501 | 492 |
493 | |
494 protected Chart[] getHistograms( | |
495 String uuid, | |
496 CallContext callContext, | |
497 Collection<KeyValueDescibeData> parameters, | |
498 Collection<KeyValueDescibeData> measurements, | |
499 Collection<KeyValueDescibeData> dates, | |
500 Map requestParameter | |
501 ) { | |
502 Locale locale = (Locale) requestParameter.get("locale"); | |
503 | |
504 Collection results = (Collection) getChartResult(uuid, callContext); | |
505 ChartTheme theme = createStyle(callContext); | |
506 | |
507 Object[][] data = HistogramHelper.prepareHistogramData( | |
508 results, parameters, measurements, dates); | |
509 | |
510 int size = data.length; | |
511 Chart[] histograms = new Chart[size]; | |
512 | |
513 for (int i = 0; i < size; i++) { | |
514 ChartLabels labels = HistogramHelper.createHistogramLabels( | |
515 uuid, callContext, locale, data[i]); | |
516 | |
517 histograms[i] = new DefaultHistogram( | |
518 labels, data[i], theme, requestParameter); | |
519 } | |
520 | |
521 return histograms; | |
522 } | |
502 | 523 |
503 /** | 524 /** |
504 * @param outputStream | 525 * @param outputStream |
505 * @param uuid | 526 * @param uuid |
506 * @throws IOException | 527 * @throws IOException |
1099 return subtitle; | 1120 return subtitle; |
1100 } | 1121 } |
1101 | 1122 |
1102 | 1123 |
1103 /** | 1124 /** |
1104 * Creates and returns labels to decorate histograms. | |
1105 * | |
1106 * @param uuid The UUID of the current artifact. | |
1107 * @param context The CallContext object. | |
1108 * @param data An array storing strings. | |
1109 * @return A ChartLabels object with the 1st string in <i>data</i> as title. | |
1110 */ | |
1111 protected ChartLabels createHistogramLabels( | |
1112 String uuid, CallContext context, Locale locale, Object[] data) | |
1113 { | |
1114 RessourceFactory fac = RessourceFactory.getInstance(); | |
1115 | |
1116 return new ChartLabels( | |
1117 (String) data[0], | |
1118 "", | |
1119 "", | |
1120 fac.getRessource(locale, "histogram.axis.range.title", "")); | |
1121 } | |
1122 | |
1123 | |
1124 /** | |
1125 * Returns the selected fis name. | 1125 * Returns the selected fis name. |
1126 * | 1126 * |
1127 * @param locale The Locale object used to adjust the language. | 1127 * @param locale The Locale object used to adjust the language. |
1128 * @return the name of the fis. | 1128 * @return the name of the fis. |
1129 */ | 1129 */ |