diff 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
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Fri Feb 12 18:04:58 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Mon Feb 15 11:44:01 2010 +0000
@@ -19,6 +19,7 @@
 
 import de.intevation.gnv.chart.Chart;
 import de.intevation.gnv.chart.ChartLabels;
+import de.intevation.gnv.chart.DefaultHistogram;
 import de.intevation.gnv.chart.TimeSeriesChart;
 import de.intevation.gnv.chart.XMLChartTheme;
 
@@ -35,6 +36,8 @@
 
 import de.intevation.gnv.geobackend.base.Result;
 
+import de.intevation.gnv.histogram.HistogramHelper;
+
 import de.intevation.gnv.state.InputData;
 import de.intevation.gnv.state.OutputStateBase;
 
@@ -289,6 +292,40 @@
                     callContext
                 );
             }
+            else if (outputMode.equalsIgnoreCase("histogram")) {
+                log.debug("Create histogram.");
+
+                Collection results      = (Collection)
+                    getChartResult(uuid, callContext);
+
+                String exportFormat = getExportFormat(mimeType);
+                Collection<KeyValueDescibeData> parameters = getParameters(uuid);
+                Collection<KeyValueDescibeData> measurements = getMeasurements(uuid);
+                Collection<KeyValueDescibeData> dates        = getDates(uuid);
+                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, data[i]);
+
+                    ChartTheme theme   = createStyle(callContext);
+
+                    histograms[i] = new DefaultHistogram(
+                        labels, data[i], theme);
+                }
+
+                ChartExportHelper.exportHistograms(
+                    outputStream,
+                    histograms,
+                    exportFormat,
+                    chartWidth,
+                    chartHeight
+                );
+            }
             else if (outputMode.equalsIgnoreCase("pdf")) {
                 log.debug("Output mode == pdf");
 
@@ -385,7 +422,8 @@
 
                 XMLUtils.toStream(doc, outputStream);
 
-            } else if (outputMode.equalsIgnoreCase("odv")) {
+            }
+            else if (outputMode.equalsIgnoreCase("odv")) {
                 Collection<Result> odvResult = this.getODVResult(uuid);
                 this.createODV(outputStream, odvResult);
             }
@@ -773,6 +811,13 @@
     }
 
 
+    protected ChartLabels createHistogramLabels(
+        String uuid, CallContext context, Object[] data)
+    {
+        return new ChartLabels((String) data[0], "", "");
+    }
+
+
     protected String getFisName(Locale locale) {
         String    returnValue = "";
         InputData input       = inputData.get("fisname");

http://dive4elements.wald.intevation.org