diff gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java @ 331:1c427acb6c76

Added subtitles to charts. gnv-artifacts/trunk@397 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 04 Dec 2009 15:30:20 +0000
parents 22a6493e8460
children e37930705daa
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java	Fri Dec 04 09:04:10 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java	Fri Dec 04 15:30:20 2009 +0000
@@ -210,17 +210,6 @@
                     log.error(e, e);
                     throw new TransitionException(e);
                 }
-                Collection<KeyValueDescibeData> parameters = this.getParameters(uuid);
-                Collection<KeyValueDescibeData> measurements = this.getMeasurements(uuid);
-                Collection<KeyValueDescibeData> dates = this.getDates(uuid);
-                ChartLabels chartLables = new ChartLabels(this.getFisName(callMeta.getLanguages())+" "+this
-                        .getSelectedFeatureName(uuid), this.domainLable);
-
-                String exportFormat       = getExportFormat(mimeType);
-
-                // TODO Remove this and parse input data
-                boolean linesVisible = true;
-                boolean shapesVisible = true;
 
                 PreferredLocale[] locales = callMeta.getLanguages();
                 Locale[] serverLocales    =
@@ -233,6 +222,22 @@
                     "browser locales -  is " + locale.toString()
                 );
 
+                Collection parameters   = this.getParameters(uuid);
+                Collection measurements = this.getMeasurements(uuid);
+                Collection dates        = this.getDates(uuid);
+
+                ChartLabels chartLables = new ChartLabels(
+                    createChartTitle(locale, uuid),
+                    createChartSubtitle(locale, uuid),
+                    domainLable
+                );
+
+                String exportFormat = getExportFormat(mimeType);
+
+                // TODO Remove this and parse input data
+                boolean linesVisible = true;
+                boolean shapesVisible = true;
+
                 this.createChart(
                     outputStream,
                     parameters,
@@ -271,9 +276,9 @@
                     getMeasurements(uuid),
                     getDates(uuid),
                     new ChartLabels(
-                        this.getFisName(callMeta.getLanguages()) +
-                        " "+ getSelectedFeatureName(uuid),
-                        this.domainLable),
+                        createChartTitle(locale, uuid),
+                        createChartSubtitle(locale, uuid),
+                        domainLable),
                     uuid,
                     "A4",
                     true,
@@ -307,9 +312,10 @@
                     getMeasurements(uuid),
                     getDates(uuid),
                     new ChartLabels(
-                        this.getFisName(callMeta.getLanguages()) +
-                        " "+ getSelectedFeatureName(uuid),
-                        this.domainLable),
+                        createChartTitle(locale, uuid),
+                        createChartSubtitle(locale, uuid),
+                        domainLable
+                    ),
                     uuid,
                     locale,
                     width,
@@ -456,13 +462,16 @@
         return doc;
     }
 
+
     protected String getSelectedFeatureName(String uuid) {
-        Collection<KeyValueDescibeData> values = this
-                .getCollection(featureValuesName, uuid);
+        Collection values = getCollection(featureValuesName, uuid);
+
         if (values != null) {
-            Iterator<KeyValueDescibeData> it = values.iterator();
+            Iterator it = values.iterator();
+
             while (it.hasNext()) {
-                KeyValueDescibeData data = it.next();
+                KeyValueDescibeData data = (KeyValueDescibeData) it.next();
+
                 if (data.isSelected()) {
                     return data.getValue();
                 }
@@ -471,6 +480,7 @@
         return null;
     }
 
+
     /**
      * @param outputStream
      * @param parameters
@@ -683,18 +693,35 @@
         return theme;
     }
 
-    protected String getFisName(PreferredLocale[] preferredLocales){
-        String returnValue = "";
-        InputData inputData = this.inputData.get("fisname");
-        if (inputData != null){
-            returnValue = RessourceFactory.getInstance()
-                                          .getRessource(preferredLocales, 
-                                                        inputData.getValue(), 
-                                                        inputData.getValue());
+
+    protected String createChartTitle(Locale locale, String uuid) {
+        return getFisName(locale);
+
+    }
+
+
+    protected String createChartSubtitle(Locale locale, String uuid) {
+        return getSelectedFeatureName(uuid);
+    }
+
+
+    protected String getFisName(Locale locale) {
+        String    returnValue = "";
+        InputData input       = inputData.get("fisname");
+
+        if (input != null) {
+            String value = input.getValue();
+
+            returnValue = RessourceFactory.getInstance().getRessource(
+                locale,
+                value,
+                value
+            );
         }
         return returnValue;
     }
 
+
     protected Collection<KeyValueDescibeData> getParameters(String uuid) {
         return this.getCollection(parameterValuesName, uuid);
     }

http://dive4elements.wald.intevation.org