diff gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java @ 492:79e80c289018

Added labels and titles to 'Profilschnitt' charts. gnv-artifacts/trunk@569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jan 2010 10:06:03 +0000
parents ab29e4ff2fda
children 1bf058f1a2d1
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Mon Jan 18 15:49:12 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Tue Jan 19 10:06:03 2010 +0000
@@ -35,6 +35,7 @@
 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
 
 import de.intevation.gnv.artifacts.cache.CacheFactory;
+import de.intevation.gnv.artifacts.ressource.RessourceFactory;
 
 import de.intevation.gnv.chart.Chart;
 import de.intevation.gnv.chart.ChartLabels;
@@ -87,11 +88,13 @@
 
 /**
  * @author Tim Englich         (tim.englich@intevation.de)
- * @author Ingo Weinzierl      (iweinzierl@intevation.de)
+ * @author Ingo Weinzierl      (ingo.weinzierl@intevation.de)
  * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
  */
 public class VerticalCrossSectionOutputState extends TimeSeriesOutputState {
 
+    public static final String CHART_TYPE = "verticalcrosssection";
+
     public static final String[] ATTRIBUTE_LIST = {
         "SHAPE",
         "Z",
@@ -106,6 +109,8 @@
 
     private String ijkQueryID = "horizontalprofile_meshpoint_cross_ij";
 
+    private String rangeLabel;
+
     /**
      * The UID of this Class
      */
@@ -117,6 +122,41 @@
     public VerticalCrossSectionOutputState() {
         super();
         super.domainLable = "chart.verticalcrosssection.title.xaxis";
+        this.rangeLabel   = "chart.verticalcrosssection.title.yaxis";
+    }
+
+
+    @Override
+    protected ChartLabels createChartLabels(Locale locale, String uuid) {
+        RessourceFactory factory = RessourceFactory.getInstance();
+        String parameterName     = getSelectedInputDataName(
+            uuid, parameterValuesName);
+
+        if (parameterName == null)
+            parameterName = "parameterid";
+
+        return new ChartLabels(
+            createChartTitle(locale, uuid),
+            createChartSubtitle(locale, uuid),
+            factory.getRessource(locale, domainLable, domainLable),
+            factory.getRessource(locale, rangeLabel, rangeLabel),
+            parameterName
+        );
+    }
+
+
+    @Override
+    protected String createChartSubtitle(Locale locale, String uuid) {
+        String date = getSelectedInputDataName(uuid, dateValueName);
+
+        if (date == null)
+            date = "dateid";
+
+        RessourceFactory factory = RessourceFactory.getInstance();
+        String chartType         = factory.getRessource(
+            locale, CHART_TYPE, CHART_TYPE);
+
+        return chartType + ": " + date;
     }
 
 
@@ -183,6 +223,24 @@
         return obj;
     }
 
+
+    protected String getSelectedInputDataName(String uuid, String id) {
+        Collection values = getCollection(id, uuid);
+
+        if (values != null) {
+            Iterator it = values.iterator();
+
+            while (it.hasNext()) {
+                KeyValueDescibeData data = (KeyValueDescibeData) it.next();
+
+                if (data.isSelected()) {
+                    return data.getValue();
+                }
+            }
+        }
+        return null;
+    }
+
     private static int getGroundInterpolation(CallContext callContext) {
         GNVArtifactContext context = 
             (GNVArtifactContext)callContext.globalContext();
@@ -490,7 +548,8 @@
         chart = new VerticalCrossSectionChart(
             columns,
             paletteManager.getBase(),
-            locale);
+            locale,
+            chartLables);
 
         chart.generateChart();
 
@@ -502,6 +561,7 @@
         return chart;
     }
 
+
     /**
      * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createChart(java.io.OutputStream,
      *      java.util.Collection, java.util.Collection, java.lang.String,

http://dive4elements.wald.intevation.org