diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java @ 2104:bb0dede9294f

Implementation towards areas at other than first axis (flys/issue441). flys-artifacts/trunk@3661 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 12 Jan 2012 12:29:56 +0000
parents 76cedac30d35
children 5642a83420f2
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java	Thu Jan 12 12:22:40 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java	Thu Jan 12 12:29:56 2012 +0000
@@ -57,6 +57,7 @@
         AreaArtifact artifact = (AreaArtifact) art;
         Object lowerData      = null;
         Object upperData      = null;
+        String stemFacetName  = null;
 
         List<DataProvider> providers = context.
             getDataProvider(artifact.getLowerDPKey());
@@ -67,6 +68,9 @@
         else {
             lowerData = providers.get(0).provideData(
                 artifact.getLowerDPKey(), null, context);
+            logger.debug("'Lower' data provider key for area [" + 
+                artifact.getLowerDPKey() + "]");
+            stemFacetName = artifact.getLowerDPKey().split(":")[1];
         }
 
         providers = context.getDataProvider(artifact.getUpperDPKey());
@@ -77,15 +81,19 @@
         else {
             upperData = providers.get(0).provideData(
                 artifact.getUpperDPKey(), null, context);
+            logger.debug("'Upper' data provider key for area [" +
+                artifact.getUpperDPKey() + "]");
+            if (stemFacetName == null) {
+                stemFacetName = artifact.getUpperDPKey().split(":")[1];
+            }
         }
 
         if (upperData == null && lowerData == null) {
             logger.warn("Not given 'upper' and 'lower' for area");
         }
 
-        return new Object[] {lowerData,
-            upperData,
-            Boolean.valueOf(artifact.getPaintBetween())};
+        return new Data(stemFacetName, lowerData, upperData,
+            Boolean.valueOf(artifact.getPaintBetween()));
     }
 
 
@@ -96,5 +104,43 @@
         copy.set(this);
         return copy;
     }
+
+    /** Result data bundle. */
+    public class Data {
+        protected String  rootFacetName;
+        protected Object  upperData;
+        protected Object  lowerData;
+        protected boolean doPaintBetween;
+
+        /** Create a new result data bundle. */
+        public Data(String rootName, Object low, Object up, boolean between) {
+            this.rootFacetName  = rootName;
+            this.lowerData      = low;
+            this.upperData      = up;
+            this.doPaintBetween = between;
+        }
+
+        /** Get name of a facet that is involved in area generation
+         * to induce type (e.g. longitudinal_section.w -> "W over km"). */
+        public String getRootFacetName() {
+            return this.rootFacetName;
+        }
+
+        /** Get data for 'upper' curve of area. */
+        public Object getUpperData() {
+            return this.upperData;
+        }
+
+        /** Get data for 'lower' curve of area. */
+        public Object getLowerData() {
+            return this.lowerData;
+        }
+
+        /** Whether to fill whole area between (in contrast to 'under'
+         *  or 'over'). */
+        public boolean doPaintBetween() {
+            return this.doPaintBetween;
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org