changeset 6364:eec895f6ec80 3.0.8

Fixed y axis label generation in sedimentload generator.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 18 Jun 2013 13:53:58 +0200
parents abed7e091762
children d3ba73a88533
files artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Tue Jun 18 13:25:52 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Tue Jun 18 13:53:58 2013 +0200
@@ -17,7 +17,6 @@
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.artifacts.MINFOArtifact;
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -71,7 +70,7 @@
     public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]";
     public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]";
 
-    private D4EArtifact artifact;
+    private String yLabel = "";
 
     @Override
     protected YAxisWalker getYAxisWalker() {
@@ -102,8 +101,16 @@
         }
 
         Facet facet = bundle.getFacet();
-        artifact = (D4EArtifact)bundle.getArtifact();
+        D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
 
+        SedimentLoadAccess slaccess = new SedimentLoadAccess(artifact);
+        String unit = slaccess.getUnit();
+        if (unit != null && unit.equals("m3_per_a")) {
+            yLabel = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
+        }
+        else {
+            yLabel = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
+        }
         if (facet == null) {
             return;
         }
@@ -119,13 +126,11 @@
             context.putContextValue("endkm", getXBounds(0).getUpper());
         }
         else if (getXBounds(0) == null && getDomainAxisRange() == null) {
-            D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
             RangeAccess access = new RangeAccess(artifact);
             context.putContextValue("startkm", access.getFrom());
             context.putContextValue("endkm", access.getTo());
         }
         else if (getXBounds(0) == null && getDomainAxisRange() != null){
-            D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
             RangeAccess access = new RangeAccess(artifact);
             Bounds b = new DoubleBounds(access.getFrom(), access.getTo());
             Bounds bounds =
@@ -226,14 +231,8 @@
     @Override
     protected String getDefaultYAxisLabel(int pos) {
         String label = "default";
-        if (pos == YAXIS.L.idx && artifact instanceof MINFOArtifact) {
-            SedimentLoadAccess access = new SedimentLoadAccess(artifact);
-            if (access.getUnit().equals("m3_per_a")) {
-                label = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
-            }
-            else {
-                label = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
-            }
+        if (pos == YAXIS.L.idx) {
+            label = yLabel;
         }
         else if (pos == YAXIS.V.idx) {
             label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT);

http://dive4elements.wald.intevation.org