Mercurial > dive4elements > gnv-client
diff 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 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Wed Jun 09 07:38:40 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java Wed Jun 09 09:37:57 2010 +0000 @@ -402,24 +402,15 @@ } // HISTOGRAM else if (outputMode.equalsIgnoreCase("histogram")) { - Collection results = (Collection) getChartResult(uuid, callContext); requestParameter.put("locale", locale); - Object[][] data = HistogramHelper.prepareHistogramData( - results, parameters, measurements, dates); - - int size = data.length; - Chart[] histograms = new Chart[size]; - - for (int i = 0; i < size; i++) { - ChartLabels labels = createHistogramLabels( - uuid, callContext, locale, data[i]); - - ChartTheme theme = createStyle(callContext); - - histograms[i] = new DefaultHistogram( - labels, data[i], theme, requestParameter); - } + Chart[] histograms = getHistograms( + uuid, + callContext, + parameters, + measurements, + dates, + requestParameter); if (mode.equalsIgnoreCase("img")) { ChartExportHelper.exportHistograms( @@ -500,6 +491,36 @@ } + protected Chart[] getHistograms( + String uuid, + CallContext callContext, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + Collection<KeyValueDescibeData> dates, + Map requestParameter + ) { + Locale locale = (Locale) requestParameter.get("locale"); + + Collection results = (Collection) getChartResult(uuid, callContext); + ChartTheme theme = createStyle(callContext); + + Object[][] data = HistogramHelper.prepareHistogramData( + results, parameters, measurements, dates); + + int size = data.length; + Chart[] histograms = new Chart[size]; + + for (int i = 0; i < size; i++) { + ChartLabels labels = HistogramHelper.createHistogramLabels( + uuid, callContext, locale, data[i]); + + histograms[i] = new DefaultHistogram( + labels, data[i], theme, requestParameter); + } + + return histograms; + } + /** * @param outputStream * @param uuid @@ -1101,27 +1122,6 @@ /** - * Creates and returns labels to decorate histograms. - * - * @param uuid The UUID of the current artifact. - * @param context The CallContext object. - * @param data An array storing strings. - * @return A ChartLabels object with the 1st string in <i>data</i> as title. - */ - protected ChartLabels createHistogramLabels( - String uuid, CallContext context, Locale locale, Object[] data) - { - RessourceFactory fac = RessourceFactory.getInstance(); - - return new ChartLabels( - (String) data[0], - "", - "", - fac.getRessource(locale, "histogram.axis.range.title", "")); - } - - - /** * Returns the selected fis name. * * @param locale The Locale object used to adjust the language.