diff flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java @ 686:3dc61e00385e facets-slt

Merged with trunk and introduced hashing of computed values. flys-artifacts/branches/facets-slt@2126 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 15 Jun 2011 15:28:54 +0000
parents d73b02526a6e
children 45cd58a2a2bb
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Wed Jun 08 13:03:21 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Wed Jun 15 15:28:54 2011 +0000
@@ -16,8 +16,11 @@
 
 import de.intevation.artifacts.Artifact;
 
+import de.intevation.flys.model.River;
+
 import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.WQDay;
+import de.intevation.flys.artifacts.resources.Resources;
 
 
 /**
@@ -27,6 +30,9 @@
  */
 public class DurationCurveGenerator extends XYChartGenerator {
 
+    public static final String I18N_DURATION_W = "chart.duration.curve.curve.w";
+    public static final String I18N_DURATION_Q = "chart.duration.curve.curve.q";
+
     private static Logger logger =
         Logger.getLogger(DurationCurveGenerator.class);
 
@@ -146,8 +152,8 @@
 
         NumberAxis qAxis = new NumberAxis("Q [m\u00b3/s]");
 
-        plot.setRangeAxis(2, qAxis);
-        plot.mapDatasetToRangeAxis(1, 2);
+        plot.setRangeAxis(1, qAxis);
+        plot.mapDatasetToRangeAxis(1, 1);
     }
 
 
@@ -159,11 +165,14 @@
             return;
         }
 
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+        River         river = winfo.getRiver();
+
         if (facet.equals(DURATION_CURVE_W)) {
-            doWOut(getDurationCurveData(artifact));
+            doWOut(getDurationCurveData(artifact), river.getName());
         }
         else if (facet.equals(DURATION_CURVE_Q)) {
-            doQOut(getDurationCurveData(artifact));
+            doQOut(getDurationCurveData(artifact), river.getName());
         }
         else {
             logger.warn("Unknown facet name: " + facet);
@@ -176,12 +185,14 @@
      * Creates the series for a duration curve's W facet.
      *
      * @param wqdays The WQDay store that contains the Ws.
+     * @param river The name of the river.
      */
-    protected void doWOut(WQDay wqdays) {
+    protected void doWOut(WQDay wqdays, String river) {
         logger.debug("DurationCurveGenerator.doWOut");
 
         // TODO find the correct series name
-        XYSeries series = new XYSeries("W-1");
+        XYSeries series = new XYSeries(
+            getSeriesName(river, DURATION_CURVE_W));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -199,12 +210,14 @@
      * Creates the series for a duration curve's Q facet.
      *
      * @param wqdays The WQDay store that contains the Qs.
+     * @param river The name of the river.
      */
-    protected void doQOut(WQDay wqdays) {
+    protected void doQOut(WQDay wqdays, String river) {
         logger.debug("DurationCurveGenerator.doQOut");
 
         // TODO find the correct series name
-        XYSeries series = new XYSeries("Q-1");
+        XYSeries series = new XYSeries(
+            getSeriesName(river, DURATION_CURVE_Q));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -230,5 +243,32 @@
         WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
         return winfoArtifact.getDurationCurveData();
     }
+
+
+    protected String getSeriesName(String river, String type) {
+        Object[] args = new Object[] { river };
+
+        if (type == null || type.length() == 0) {
+            logger.warn("No duration curve type given.");
+            return "n/a";
+        }
+        else if (type.equals(DURATION_CURVE_W)) {
+            return Resources.getMsg(
+                context.getMeta(),
+                I18N_DURATION_W,
+                "W",
+                args);
+        }
+        else if (type.equals(DURATION_CURVE_Q)) {
+            return Resources.getMsg(
+                context.getMeta(),
+                I18N_DURATION_Q,
+                "W",
+                args);
+        }
+
+        logger.warn("Could not determine chart curve type: " + type);
+        return type;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org