Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 617:3d13fa281a7e
Added new ouput mode: histogram.
gnv-artifacts/trunk@688 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Feb 2010 11:44:01 +0000 |
parents | 01054ddccb0f |
children | c009d8df53aa |
comparison
equal
deleted
inserted
replaced
616:93978859fa9e | 617:3d13fa281a7e |
---|---|
17 | 17 |
18 import de.intevation.gnv.artifacts.ressource.RessourceFactory; | 18 import de.intevation.gnv.artifacts.ressource.RessourceFactory; |
19 | 19 |
20 import de.intevation.gnv.chart.Chart; | 20 import de.intevation.gnv.chart.Chart; |
21 import de.intevation.gnv.chart.ChartLabels; | 21 import de.intevation.gnv.chart.ChartLabels; |
22 import de.intevation.gnv.chart.DefaultHistogram; | |
22 import de.intevation.gnv.chart.TimeSeriesChart; | 23 import de.intevation.gnv.chart.TimeSeriesChart; |
23 import de.intevation.gnv.chart.XMLChartTheme; | 24 import de.intevation.gnv.chart.XMLChartTheme; |
24 | 25 |
25 import de.intevation.gnv.chart.exception.TechnicalChartException; | 26 import de.intevation.gnv.chart.exception.TechnicalChartException; |
26 | 27 |
32 import de.intevation.gnv.exports.Export.Profile; | 33 import de.intevation.gnv.exports.Export.Profile; |
33 | 34 |
34 import de.intevation.gnv.exports.SimpleOdvDataCollector; | 35 import de.intevation.gnv.exports.SimpleOdvDataCollector; |
35 | 36 |
36 import de.intevation.gnv.geobackend.base.Result; | 37 import de.intevation.gnv.geobackend.base.Result; |
38 | |
39 import de.intevation.gnv.histogram.HistogramHelper; | |
37 | 40 |
38 import de.intevation.gnv.state.InputData; | 41 import de.intevation.gnv.state.InputData; |
39 import de.intevation.gnv.state.OutputStateBase; | 42 import de.intevation.gnv.state.OutputStateBase; |
40 | 43 |
41 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData; | 44 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData; |
287 lVisible, | 290 lVisible, |
288 sVisible, | 291 sVisible, |
289 callContext | 292 callContext |
290 ); | 293 ); |
291 } | 294 } |
295 else if (outputMode.equalsIgnoreCase("histogram")) { | |
296 log.debug("Create histogram."); | |
297 | |
298 Collection results = (Collection) | |
299 getChartResult(uuid, callContext); | |
300 | |
301 String exportFormat = getExportFormat(mimeType); | |
302 Collection<KeyValueDescibeData> parameters = getParameters(uuid); | |
303 Collection<KeyValueDescibeData> measurements = getMeasurements(uuid); | |
304 Collection<KeyValueDescibeData> dates = getDates(uuid); | |
305 Object[][] data = HistogramHelper.prepareHistogramData( | |
306 results, parameters, measurements, dates); | |
307 | |
308 int size = data.length; | |
309 Chart[] histograms = new Chart[size]; | |
310 | |
311 for (int i = 0; i < size; i++) { | |
312 ChartLabels labels = createHistogramLabels( | |
313 uuid, callContext, data[i]); | |
314 | |
315 ChartTheme theme = createStyle(callContext); | |
316 | |
317 histograms[i] = new DefaultHistogram( | |
318 labels, data[i], theme); | |
319 } | |
320 | |
321 ChartExportHelper.exportHistograms( | |
322 outputStream, | |
323 histograms, | |
324 exportFormat, | |
325 chartWidth, | |
326 chartHeight | |
327 ); | |
328 } | |
292 else if (outputMode.equalsIgnoreCase("pdf")) { | 329 else if (outputMode.equalsIgnoreCase("pdf")) { |
293 log.debug("Output mode == pdf"); | 330 log.debug("Output mode == pdf"); |
294 | 331 |
295 Locale[] serverLocales = | 332 Locale[] serverLocales = |
296 RessourceFactory.getInstance().getLocales(); | 333 RessourceFactory.getInstance().getLocales(); |
383 | 420 |
384 Document doc = writeStatistics2XML(statistics); | 421 Document doc = writeStatistics2XML(statistics); |
385 | 422 |
386 XMLUtils.toStream(doc, outputStream); | 423 XMLUtils.toStream(doc, outputStream); |
387 | 424 |
388 } else if (outputMode.equalsIgnoreCase("odv")) { | 425 } |
426 else if (outputMode.equalsIgnoreCase("odv")) { | |
389 Collection<Result> odvResult = this.getODVResult(uuid); | 427 Collection<Result> odvResult = this.getODVResult(uuid); |
390 this.createODV(outputStream, odvResult); | 428 this.createODV(outputStream, odvResult); |
391 } | 429 } |
392 } catch (IOException e) { | 430 } catch (IOException e) { |
393 log.error(e, e); | 431 log.error(e, e); |
771 protected String createChartSubtitle(Locale locale, String uuid) { | 809 protected String createChartSubtitle(Locale locale, String uuid) { |
772 return getSelectedFeatureName(uuid); | 810 return getSelectedFeatureName(uuid); |
773 } | 811 } |
774 | 812 |
775 | 813 |
814 protected ChartLabels createHistogramLabels( | |
815 String uuid, CallContext context, Object[] data) | |
816 { | |
817 return new ChartLabels((String) data[0], "", ""); | |
818 } | |
819 | |
820 | |
776 protected String getFisName(Locale locale) { | 821 protected String getFisName(Locale locale) { |
777 String returnValue = ""; | 822 String returnValue = ""; |
778 InputData input = inputData.get("fisname"); | 823 InputData input = inputData.get("fisname"); |
779 | 824 |
780 if (input != null) { | 825 if (input != null) { |