diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java @ 1089:e298c4d28927

Improved mainvalues rendering. flys-artifacts/trunk@2592 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 26 Aug 2011 11:15:24 +0000
parents 07878836ee0d
children 139e7df1787c
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Fri Aug 26 11:11:46 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java	Fri Aug 26 11:15:24 2011 +0000
@@ -17,8 +17,9 @@
 import de.intevation.artifacts.CallMeta;
 import de.intevation.flys.artifacts.model.RiverFactory;
 
+import de.intevation.flys.artifacts.model.MainValuesQFacet;
 import de.intevation.flys.artifacts.model.MainValuesWFacet;
-import de.intevation.flys.artifacts.model.MainValuesQFacet;
+import de.intevation.flys.artifacts.model.NamedDouble;
 import de.intevation.artifactdatabase.data.DefaultStateData;
 import de.intevation.flys.artifacts.states.StaticState;
 
@@ -166,6 +167,11 @@
             : null;
     }
 
+    /**
+     * Access the Gauge that the mainvalues are taken from.
+     * @return Gauge that main values are taken from or null in case of
+     *         invalid parameterization.
+     */
     protected Gauge getGauge() {
         River river = getRiver();
 
@@ -179,28 +185,57 @@
         return river.determineGaugeByPosition(location);
     }
 
-    public List<MainValue> getMainValuesQ() {
-        List<MainValue> filteredList = new ArrayList<MainValue>();
+
+    /**
+     * Get datum of Gauge.
+     * @return datum of gauge.
+     */
+    public double getGaugeDatum() {
+        Gauge gauge = getGauge();
+        if (gauge == null) { return 0.0f; }
+        return gauge.getDatum().doubleValue();
+    }
+
+
+    /**
+     * Get a list of "Q" main values.
+     * @return list of Q main values.
+     */
+    public List<NamedDouble> getMainValuesQ() {
+        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
         if (gauge != null) {
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("Q")) {
-                    filteredList.add(mv);
+                    filteredList.add(new NamedDouble(
+                                mv.getMainValue().getName(),
+                                mv.getValue().doubleValue()
+                                ));
                 }
             }
         }
         return filteredList;
     }
 
-    public List<MainValue> getMainValuesW() {
-        List<MainValue> filteredList = new ArrayList<MainValue>();
+
+    /**
+     * Get a list of "W" main values.
+     * @return list of W main values.
+     */
+    public List<NamedDouble> getMainValuesW() {
+        List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
+        double datum = gauge.getDatum().doubleValue();
+        logger.debug("DATUM:: " + datum);
         if (gauge != null) {
             List<MainValue> orig = gauge.getMainValues();
             for (MainValue mv : orig) {
                 if (mv.getMainValue().getType().getName().equals("W")) {
-                    filteredList.add(mv);
+                    filteredList.add(new NamedDouble(
+                                mv.getMainValue().getName(),
+                                mv.getValue().doubleValue()/100.f + datum
+                                ));
                 }
             }
         }

http://dive4elements.wald.intevation.org