changeset 2018:3f1a63da2cf4

Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams). flys-artifacts/trunk@3473 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 06:37:41 +0000
parents e384d78ff78b
children aa3e7ed1fa46
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/AreaCreationState.java
diffstat 5 files changed, 64 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Dec 20 06:26:25 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Dec 20 06:37:41 2011 +0000
@@ -1,3 +1,20 @@
+2011-12-20	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Lay ground for having areas in longitudinal section diagrams, too.
+	This is done by different naming of the facets.
+
+	* src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java:
+	  Make the name dynamic.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java:
+	  Added further facet types, helper.
+
+	* src/main/java/de/intevation/flys/artifacts/AreaArtifact.java:
+	  Store name for facets in data item, restrict access to some fields.
+
+	* src/main/java/de/intevation/flys/artifacts/states/AreaCreationState.java:
+	  Use AreaArtifacts data item to use name for facets.
+
 2011-12-20	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Cosmetics.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java	Tue Dec 20 06:26:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java	Tue Dec 20 06:37:41 2011 +0000
@@ -35,17 +35,22 @@
     /** Name of Artifact. */
     public static final String AREA_ARTIFACT_NAME = "area_artifact";
 
+    /** Dataitem: Facet name. Facets with this name will be created (important
+     * to not have the area calculated in e.g. a CrossSection to be shown in
+     * LongitudinalSection.  */
+    protected static final String FACET_NAME = "area.facet";
+
     /** Name of state. */
     public static final String STATIC_STATE_NAME = "state.area_artifact";
 
     /** data item name to access upper curve. */
-    public static final String AREA_CURVE_OVER = "area.curve_over";
+    protected static final String AREA_CURVE_OVER = "area.curve_over";
 
     /** data item name to access lower curve. */
-    public static final String AREA_CURVE_UNDER = "area.curve_under";
+    protected static final String AREA_CURVE_UNDER = "area.curve_under";
 
     /** Name of state. */
-    public static final String AREA_NAME = "area.name";
+    protected static final String AREA_NAME = "area.name";
 
     /** Own logger. */
     private static final Logger logger =
@@ -76,8 +81,9 @@
         String ids = XMLUtils.xpathString(
             data, XPATH_IDS, ArtifactNamespaceContext.INSTANCE);
 
+        // TODO this facet will be remodeled during next feed.
         List<Facet> fs = new ArrayList<Facet>();
-        fs.add(new AreaFacet(0, "TODO: I am an AreaFacet"));
+        fs.add(new AreaFacet(0, "", "TODO: I am an AreaFacet"));
 
         AreaCreationState state = (AreaCreationState) getCurrentState(context);
 
@@ -98,6 +104,12 @@
         // do nothing
     }
 
+    /**
+     * Get name of facets to create.
+     */
+    public String getFacetName() {
+        return getDataAsString(FACET_NAME);
+    }
 
     /**
      * Get dataprovider key for the 'lower' curve (we got that information fed
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java	Tue Dec 20 06:26:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java	Tue Dec 20 06:37:41 2011 +0000
@@ -21,6 +21,13 @@
 
 /**
  * Trival Facet for areas.
+ * Note that this Facet comes in two "types" (names):
+ *  <ul>
+ *    <li>CROSS_SECTION_AREA (cross_section.area) and</li>
+ *    <li>LONGITUDINAL_SECTION_AREA (longitudinal.area</li>
+ *  </ul>
+ * This is to support different diagram types without being painted in both
+ * at the same time. The name has to be given when constructing.
  */
 public class AreaFacet
 extends      DefaultFacet
@@ -28,9 +35,13 @@
 
     private static Logger logger = Logger.getLogger(AreaFacet.class);
 
-    /** Trivial constructor, set (maybe localized) description. */
-    public AreaFacet(int idx, String description) {
-        super(idx, AREA, description);
+    /**
+     * Constructor, set (maybe localized) description and name.
+     * @param idx Index given when querying artifact for data.
+     * @param name important to discern areas in different diagram types.
+     */
+    public AreaFacet(int idx, String name, String description) {
+        super(idx, name, description);
     }
 
 
@@ -54,7 +65,8 @@
         List<DataProvider> providers = context.
             getDataProvider(artifact.getLowerDPKey());
         if (providers.size() < 1) {
-            logger.warn("No 'lower' given for area");
+            logger.warn("No 'lower' provider given for area [" + 
+                artifact.getLowerDPKey() + "]");
         }
         else {
             lowerData = providers.get(0).provideData(
@@ -63,7 +75,8 @@
 
         providers = context.getDataProvider(artifact.getUpperDPKey());
         if (providers.size() < 1) {
-            logger.warn("No 'upper' given for area");
+            logger.warn("No 'upper' provider given for area [" +
+                artifact.getUpperDPKey() + "]");
         }
         else {
             upperData = providers.get(0).provideData(
@@ -81,7 +94,7 @@
     /** Do a deep copy. */
     @Override 
     public Facet deepCopy() {
-        AreaFacet copy = new AreaFacet(this.index, this.description);
+        AreaFacet copy = new AreaFacet(this.index, this.name, this.description);
         copy.set(this);
         return copy;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Tue Dec 20 06:26:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Tue Dec 20 06:37:41 2011 +0000
@@ -12,9 +12,16 @@
                || type.equals(HEIGHTMARKS_POINTS)
                || WQ_KM(type);
         }
+        public static boolean AREA(String type) {
+            return type.equals(AREA)
+                || type.equals(CROSS_SECTION_AREA)
+                || type.equals(LONGITUDINAL_SECTION_AREA);
+        }
     };
 
     String AREA                   = "area";
+    String CROSS_SECTION_AREA     = "cross_section.area";
+    String LONGITUDINAL_SECTION_AREA = "longitudinal.area";
 
     String FLOODMAP_WSPLGEN       = "floodmap.wsplgen";
     String FLOODMAP_BARRIERS      = "floodmap.barriers";
@@ -59,6 +66,8 @@
     String STATIC_WQ_ANNOTATIONS = "other.wq.annotations";
     String STATIC_WKMS  = "other.wkms";
     String STATIC_WQKMS = "other.wqkms";
+    String STATIC_WQKMS_W = "other.wqkms.w";
+    String STATIC_WQKMS_Q = "other.wqkms.q";
     String STATIC_WKMS_INTERPOL = "other.wkms.interpol";
 
     String HEIGHTMARKS_POINTS = "heightmarks_points";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/AreaCreationState.java	Tue Dec 20 06:26:25 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/AreaCreationState.java	Tue Dec 20 06:37:41 2011 +0000
@@ -50,8 +50,9 @@
         logger.debug("AreaCreationState.compute");
 
         if (facets != null) {
-            facets.add(new AreaFacet(0,
-                ((AreaArtifact) areaArtifact).getAreaName()));
+            AreaArtifact aArt = (AreaArtifact) areaArtifact;
+
+            facets.add(new AreaFacet(0, aArt.getFacetName(), aArt.getAreaName()));
         }
 
         // TODO use compute to exploit caching strategies.

http://dive4elements.wald.intevation.org