changeset 2407:dce0cc856357

'Bezugslinien': Added axis labels matching the displayed data. flys-artifacts/trunk@4036 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 10 Feb 2012 16:00:57 +0000
parents 84cdde4bc482
children 8e2ae8813a06
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 9 files changed, 79 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 10 16:00:57 2012 +0000
@@ -1,3 +1,25 @@
+2012-02-10  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java:
+	  Indexed access to getInCm.
+
+	* src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java:
+	  Simplified. Do not provide any data to blackboard. Only side effect the
+	  call context.
+
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java:
+	  Added convinience method to i18n string with defaulting to key name.
+
+	* src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java:
+	  Label the axis according the scale types of the data.
+	  TODO: Let the NormalizedReferenceCurveGenerator be a sub class of
+	  this.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: i18n for the reference curve axes.
+
 2012-02-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveExporter.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ReferenceCurveFacet.java	Fri Feb 10 16:00:57 2012 +0000
@@ -1,8 +1,7 @@
 package de.intevation.flys.artifacts.model;
 
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
+import java.util.Collections;
 
 import de.intevation.artifactdatabase.state.Facet;
 
@@ -19,12 +18,9 @@
 public class ReferenceCurveFacet 
 extends      DataFacet
 {
-    public static final String BLACK_BOARD_KEY = "reference.curve.axis.scale";
+    private static Logger log = Logger.getLogger(ReferenceCurveFacet.class);
 
-    public static final List BLACK_BOARD_KEY_LIST =
-        Arrays.asList(new String [] { BLACK_BOARD_KEY });
-
-    private static Logger log = Logger.getLogger(ReferenceCurveFacet.class);
+    public static final String CONTEXT_KEY = "reference.curve.axis.scale";
 
     public ReferenceCurveFacet() {
     }
@@ -82,45 +78,19 @@
 
     @Override
     public List getDataProviderKeys(Artifact art, CallContext context) {
-        // Answer to key only if x or y in meter...
-        List keys = new ArrayList();
+
         // compute / get data
-        Object obj = context.getContextValue("reference.curve.axis.scale");
+        Object obj = context.getContextValue(CONTEXT_KEY);
 
         if (!(obj instanceof WWAxisTypes)) {
             obj = new WWAxisTypes(getWWQQ(art, context));
-            context.putContextValue("reference.curve.axis.scale", obj);
+            context.putContextValue(CONTEXT_KEY, obj);
         }
         else {
             ((WWAxisTypes)obj).classify(getWWQQ(art, context));
         }
-        // TODO we do not need to provide data
-        return BLACK_BOARD_KEY_LIST;
-    }
 
-    @Override
-    public Object provideBlackboardData(
-        Artifact    artifact,
-        Object      key,
-        Object      param,
-        CallContext context
-    ) {
-        // TODO we do not really need to provide data
-        if (!key.equals(BLACK_BOARD_KEY)) {
-            return null;
-        }
-
-        Object obj = context.getContextValue("reference.curve.axis.scale");
-
-        if (!(obj instanceof WWAxisTypes)) {
-            obj = new WWAxisTypes(getWWQQ(artifact, context));
-            context.putContextValue("reference.curve.axis.scale", obj);
-        }
-        else {
-            ((WWAxisTypes)obj).classify(getWWQQ(artifact, context));
-        }
-
-        return obj;
+        return Collections.emptyList();
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java	Fri Feb 10 16:00:57 2012 +0000
@@ -23,6 +23,14 @@
         if (!ww.endAtGauge())   inCm2 = false;
     }
 
+    public boolean getInCm(int index) {
+        switch (index) {
+            case 0:  return inCm1;
+            case 1:  return inCm2;
+            default: return false;
+        }
+    }
+
     public boolean getInCm1() {
         return inCm1;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Fri Feb 10 16:00:57 2012 +0000
@@ -933,6 +933,9 @@
         return Resources.getMsg(context.getMeta(), key, def);
     }
 
+    protected String msg(String key) {
+        return Resources.getMsg(context.getMeta(), key, key);
+    }
 
     protected String msg(String key, String def, Object[] args) {
         return Resources.getMsg(context.getMeta(), key, def, args);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java	Fri Feb 10 16:00:57 2012 +0000
@@ -2,8 +2,6 @@
 
 import org.w3c.dom.Document;
 
-import java.awt.Font;
-
 import org.apache.log4j.Logger;
 
 import org.jfree.chart.JFreeChart;
@@ -30,8 +28,7 @@
 implements   FacetTypes
 {
     public static enum YAXIS {
-        W_M(0),
-        W_CM(1);
+        W(0);
 
         public int idx;
         private YAXIS(int c) {
@@ -49,62 +46,33 @@
     public static final String I18N_CHART_SUBTITLE =
         "chart.reference.curve.subtitle";
 
-    public static final String W_CM_DEFAULT =
-        "chart.reference.curve.wcm";
-
-    public static final String W_NNM_DEFAULT =
-        "chart.reference.curve.wnn";
-
-    public static final String START_GAUGE =
-        "chart.reference.curve.start_at_gauge";
-
-    public static final String START_FREE =
-        "chart.reference.curve.start_free";
-
-    /*
+    public static final String I18N_X_AXIS_IN_CM =
+        "chart.reference.curve.x.axis.in.cm";
 
-    public static final String I18N_XAXIS_LABEL =
-        "chart.reference.curve.xaxis.label";
+    public static final String I18N_X_AXIS_IN_M =
+        "chart.reference.curve.x.axis.in.m";
 
-    public static final String I18N_YAXIS_LABEL =
-        "chart.reference.curve.yaxis.label";
-*/
-/*
-    public static final String I18N_XAXIS_LABEL_DEFAULT  =
-        "W [NN + m]";
+    public static final String I18N_Y_AXIS_IN_CM =
+        "chart.reference.curve.y.axis.in.cm";
 
-    public static final String I18N_YAXIS_LABEL_DEFAULT  =
-        "W [NN + m]";
-    */
-
+    public static final String I18N_Y_AXIS_IN_M =
+        "chart.reference.curve.y.axis.in.m";
 
     public static final String I18N_CHART_TITLE_DEFAULT  =
         "Bezugslinie";
 
 
     public ReferenceCurveGenerator() {
-        super();
     }
 
-
     /**
      * Create Axis for given index.
      * @return axis with according internationalized label.
      */
     @Override
     protected NumberAxis createYAxis(int index) {
-        Font labelFont = new Font("Tahoma", Font.BOLD, 14);
-        String label   = getYAxisLabel(index);
-
-        NumberAxis axis = createNumberAxis(index, label);
-        // TODO aspect-ratio settings.
-        /*
-        if (index == YAXIS.W_M.idx) {
-            axis.setAutoRangeIncludesZero(false);
-        }
-        */
+        NumberAxis axis = super.createYAxis(index);
         axis.setAutoRangeIncludesZero(false);
-        axis.setLabelFont(labelFont);
         return axis;
     }
 
@@ -134,13 +102,16 @@
         }
     }
 
+    protected boolean getInCm(int index) {
+        Object obj = context.getContextValue("reference.curve.axis.scale");
+        return obj instanceof WWAxisTypes && ((WWAxisTypes)obj).getInCm(index);
+    }
+
 
     /** Get Label for X-axis (W). */
     @Override
     protected String getDefaultXAxisLabel() {
-        // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
-        // at_gauge + w_cm
-        return "W am Bezugsort- oder Pegel.";
+        return msg(getInCm(0) ? I18N_X_AXIS_IN_CM : I18N_X_AXIS_IN_M);
     }
 
 
@@ -150,17 +121,7 @@
      */
     @Override
     protected String getDefaultYAxisLabel(int index) {
-        String label = "default";
-        if (index == YAXIS.W_M.idx) {
-            //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
-            //TODO i18n 
-            return "W am Zielort";
-        }
-        else if (index == YAXIS.W_CM.idx) {
-            return "W am Zielpegel";
-        }
-
-        return label;
+        return msg(getInCm(1) ? I18N_Y_AXIS_IN_CM : I18N_Y_AXIS_IN_M);
     }
 
 
@@ -194,11 +155,10 @@
                 artifactFacet,
                 theme,
                 visible,
-                YAXIS.W_M.idx);
+                YAXIS.W.idx);
         }
         else {
             logger.warn("Unknown facet name: " + name);
-            return;
         }
     }
 
@@ -229,12 +189,7 @@
             series.add(values[0], values[1], false);
         }
 
-        if (ww.endAtGauge()) {
-            addAxisSeries(series, YAXIS.W_M.idx, visible);
-        }
-        else {
-            addAxisSeries(series, YAXIS.W_CM.idx, visible);
-        }
+        addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
 
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Feb 10 16:00:57 2012 +0000
@@ -91,6 +91,11 @@
 chart.reference.curve.title = Reference Curve
 chart.reference.curve.subtitle = {0}
 
+chart.reference.curve.x.axis.in.cm = Reference Gauge(s) [cm]
+chart.reference.curve.x.axis.in.m = Reference Station(s) [NN + m]
+chart.reference.curve.y.axis.in.cm = Target Gauge(s) [cm]
+chart.reference.curve.y.axis.in.m = Target Station(s) [NN + m] 
+
 chart.w_differences.title = Differences
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.w_differences.yaxis.label = m
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 10 16:00:57 2012 +0000
@@ -91,6 +91,11 @@
 chart.reference.curve.title = Bezugslinie
 chart.reference.curve.subtitle = {0}
 
+chart.reference.curve.x.axis.in.cm = Bezugspegel [cm]
+chart.reference.curve.x.axis.in.m = Bezugsort(e) [NN + m]
+chart.reference.curve.y.axis.in.cm = Zielpegel [cm]
+chart.reference.curve.y.axis.in.m = Zielort(e) [NN + m] 
+
 chart.w_differences.title = Differenzen
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.w_differences.yaxis.label = m
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 10 16:00:57 2012 +0000
@@ -91,6 +91,11 @@
 chart.reference.curve.title = Bezugslinie
 chart.reference.curve.subtitle = {0}
 
+chart.reference.curve.x.axis.in.cm = Bezugspegel [cm]
+chart.reference.curve.x.axis.in.m = Bezugsort(e) [NN + m]
+chart.reference.curve.y.axis.in.cm = Zielpegel [cm]
+chart.reference.curve.y.axis.in.m = Zielort(e) [NN + m] 
+
 chart.w_differences.title = Differenzen
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.w_differences.yaxis.label = m
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 10 14:04:07 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 10 16:00:57 2012 +0000
@@ -89,6 +89,11 @@
 chart.reference.curve.title = Reference Curve
 chart.reference.curve.subtitle = {0}
 
+chart.reference.curve.x.axis.in.cm = Reference Gauge(s) [cm]
+chart.reference.curve.x.axis.in.m = Reference Station(s) [NN + m]
+chart.reference.curve.y.axis.in.cm = Target Gauge(s) [cm]
+chart.reference.curve.y.axis.in.m = Target Station(s) [NN + m] 
+
 chart.w_differences.title = Differences
 chart.w_differences.subtitle = Range: {0}-km {1,number,#.###} - {2,number,#.###}
 chart.w_differences.yaxis.label = m

http://dive4elements.wald.intevation.org