changeset 2175:3f90f4d37c8d

Render manual points in longitudinal sections. flys-artifacts/trunk@3770 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 26 Jan 2012 13:12:19 +0000
parents 98f7397d8f02
children 65dac9cf6ff5
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/themes.xml flys-artifacts/pom.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 6 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jan 26 13:12:19 2012 +0000
@@ -1,3 +1,21 @@
+2012-01-26  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Renderer 'manual' points in LongitudinalSectionGenerator.
+
+	* pom.xml: New dependency to org.json/json.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  (doOut): Handle manual points.
+	  (doPoints): Add point- series.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java:
+	  Added MANUALPOINTS Facet Type.
+
+	* doc/conf/themes.xml: Added Default Theme for Manual Points.
+
+	* doc/conf/artifacts/winfo.xml: Added manual point facet to
+	  compatibility list of longitudinal section diagram.
+	
 2012-01-26  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Cosmetics.
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Jan 26 13:12:19 2012 +0000
@@ -274,6 +274,7 @@
                     <facet name="other.wq"               description="WQ-Type of data" />
                     <facet name="other.wqkms.q"          description="Q-Type of data" />
                     <facet name="other.wkms"             description="facet.other.wkms"/>
+                    <facet name="manualpoints"           description="Manuelle Punkte"/>
                     <facet name="other.wqkms"            description="facet.other.wqkms"/>
                     <facet name="heightmarks_points"     description="facet.other.wkms.heightmarks_points"/>
                     <facet name="longitudinal_section.area"        description="an area"/>
--- a/flys-artifacts/doc/conf/themes.xml	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Thu Jan 26 13:12:19 2012 +0000
@@ -942,5 +942,6 @@
         <mapping from="cross_section.area" to="Area"/>
         <mapping from="hyk" to="Hyk"/>
         <mapping from="longitudinal_section.area" to="Area"/>
+        <mapping from="manualpoints" to="LongitudinalSectionPoints"/>
     </mappings>
 </themes>
--- a/flys-artifacts/pom.xml	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/pom.xml	Thu Jan 26 13:12:19 2012 +0000
@@ -120,6 +120,11 @@
       <artifactId>gt-geojson</artifactId>
       <version>2.7.2</version>
     </dependency>
+    <dependency>   
+      <groupId>org.json</groupId>   
+      <artifactId>json</artifactId>   
+      <version>20090211</version>   
+    </dependency>
     <dependency>
       <groupId>org.apache.velocity</groupId>
       <artifactId>velocity</artifactId>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Jan 26 13:12:19 2012 +0000
@@ -78,6 +78,8 @@
     String DURATION_Q = "duration_curve.q";
     String DURATION_MAINVALUES_Q = "duration_curve.mainvalues.q";
 
+    String MANUALPOINTS = "manualpoints";
+
     String STATIC_WQ    = "other.wq";
     String STATIC_WQ_ANNOTATIONS = "other.wq.annotations";
     String STATIC_WKMS  = "other.wkms";
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Jan 26 12:56:57 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Jan 26 13:12:19 2012 +0000
@@ -29,6 +29,8 @@
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.DataUtil;
 
+import org.json.JSONArray;
+import org.json.JSONException;
 
 /**
  * An OutGenerator that generates discharge curves.
@@ -369,6 +371,11 @@
                 visible);
         
         }
+        else if (FacetTypes.MANUALPOINTS.equals(name)) {
+            doPoints(artifactAndFacet.getData(context),
+                artifactAndFacet.getFacetDescription(),
+                attr, visible);
+        }
         else {
             logger.warn("Unknown facet name: " + name);
             return;
@@ -532,6 +539,7 @@
         }
     }
 
+
     /**
      * Do Area out.
      */
@@ -611,5 +619,34 @@
         // Add area to the respective axis.
         addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible);
     }
+
+
+    /**
+     * Do Points out.
+     */
+    protected void doPoints(
+        Object     o,
+        String     seriesName,
+        Document   theme,
+        boolean    visible
+    ) {
+        XYSeries series = new StyledXYSeries(seriesName, theme);
+
+        try {
+            JSONArray points = new JSONArray((String) o);
+            for (int i = 0; i < points.length(); i++) {
+                JSONArray array = points.getJSONArray(i);
+                double x = array.getDouble(0);
+                double y = array.getDouble(1);
+                //logger.debug(" x " + x + " y " + y );
+                series.add(x, y, false);
+            }
+        }
+        catch(JSONException e){
+            logger.error("Could not decode json.");
+        }
+
+        addAxisSeries(series, YAXIS.W.idx, visible);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org