diff gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 502:fec85cd01497

Fixed issue105. Added option to enable/disable data points in charts. Parse this option while creating charts. gnv-artifacts/trunk@585 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Jan 2010 15:17:35 +0000
parents 4080b57dcb52
children a162793b6053
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Wed Jan 20 14:47:30 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Wed Jan 20 15:17:35 2010 +0000
@@ -207,27 +207,40 @@
 
         CallMeta callMeta         = callContext.getMeta();
 
+        int chartWidth   = 600;
+        int chartHeight  = 400;
+        boolean sVisible = false;
+
+        // lines are always visible. if lines should be configurable we need a
+        // parameter in the user interface
+        boolean lVisible = true;
+
+        try {
+            if (inputData != null) {
+                Iterator<InputData> it = inputData.iterator();
+                while (it.hasNext()) {
+                    InputData ip      = it.next();
+                    String optionName = ip.getName().trim();
+
+                    if (optionName.equals("width")) {
+                        chartWidth = Integer.parseInt(ip.getValue());
+                    }
+                    else if (optionName.equals("height")) {
+                        chartHeight = Integer.parseInt(ip.getValue());
+                    }
+                    else if (optionName.equals("points")) {
+                        sVisible = Boolean.parseBoolean(ip.getValue());
+                    }
+                }
+            }
+        } catch (NumberFormatException e) {
+            log.error(e, e);
+            throw new StateException(e);
+        }
+
         try {
             if (outputMode.equalsIgnoreCase("chart")) {
                 log.debug("Chart will be generated.");
-                int chartWidth = 600;
-                int chartHeight = 400;
-                try {
-                    if (inputData != null) {
-                        Iterator<InputData> it = inputData.iterator();
-                        while (it.hasNext()) {
-                            InputData ip = it.next();
-                            if (ip.getName().equalsIgnoreCase("width")) {
-                                chartWidth = Integer.parseInt(ip.getValue());
-                            } else if (ip.getName().equalsIgnoreCase("height")) {
-                                chartHeight = Integer.parseInt(ip.getValue());
-                            }
-                        }
-                    }
-                } catch (NumberFormatException e) {
-                    log.error(e, e);
-                    throw new StateException(e);
-                }
 
                 PreferredLocale[] locales = callMeta.getLanguages();
                 Locale[] serverLocales    =
@@ -248,10 +261,6 @@
 
                 String exportFormat = getExportFormat(mimeType);
 
-                // TODO Remove this and parse input data
-                boolean linesVisible = true;
-                boolean shapesVisible = true;
-
                 this.createChart(
                     outputStream,
                     parameters,
@@ -264,8 +273,8 @@
                     locale,
                     chartWidth,
                     chartHeight,
-                    linesVisible,
-                    shapesVisible,
+                    lVisible,
+                    sVisible,
                     callContext
                 );
             }
@@ -277,10 +286,6 @@
                 Locale locale             =
                     callMeta.getPreferredLocale(serverLocales);
 
-                // TODO Remove this and parse input data
-                boolean linesVisible = true;
-                boolean shapesVisible = true;
-
                 log.debug(
                     "Best locale - regarding intersection of server and " +
                     "browser locales -  is " + locale.toString()
@@ -303,20 +308,14 @@
                     uuid,
                     "A4",
                     true,
-                    linesVisible,
-                    shapesVisible,
+                    lVisible,
+                    sVisible,
                     locale,
                     callContext
                 );
             }
             else if (outputMode.equalsIgnoreCase("svg")) {
                 log.debug("Output mode == svg");
-                int width  = 600;
-                int height = 400;
-
-                // TODO Remove this and parse input data
-                boolean linesVisible = true;
-                boolean shapesVisible = true;
 
                 Locale[] serverLocales    =
                     RessourceFactory.getInstance().getLocales();
@@ -344,10 +343,10 @@
                     ),
                     uuid,
                     locale,
-                    width,
-                    height,
-                    linesVisible,
-                    shapesVisible,
+                    chartWidth,
+                    chartHeight,
+                    lVisible,
+                    sVisible,
                     callContext
                 );
             }
@@ -392,7 +391,6 @@
                 XMLUtils.toStream(doc, outputStream);
 
             } else if (outputMode.equalsIgnoreCase("odv")) {
-                
                 Collection<Result> odvResult = this.getODVResult(uuid);
                 this.createODV(outputStream, odvResult);
             }

http://dive4elements.wald.intevation.org