changeset 1028:10bafb4f46cc

Made (kind of dummy-) Annotations in LongitudinalSection diagrams visible. flys-artifacts/trunk@2488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 11 Aug 2011 12:48:31 +0000
parents a60d2a46f0a8
children 3f3988bb6284
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 3 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Aug 11 12:43:00 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Aug 11 12:48:31 2011 +0000
@@ -1,3 +1,12 @@
+2011-08-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Made Annotations visible in LongitudinalSection diagrams.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java,
+	  src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Register new Facet Type, let LongitudinalSectionGenerator include
+	  Annotations in diagram (yet unfiltered and independent of river).
+
 2011-08-11  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* doc/conf/conf.xml,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Aug 11 12:43:00 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Aug 11 12:48:31 2011 +0000
@@ -12,6 +12,7 @@
 
     String LONGITUDINAL_W = "longitudinal_section.w";
     String LONGITUDINAL_Q = "longitudinal_section.q";
+    String LONGITUDINAL_ANNOTATION = "longitudinal_section.annotations";
 
     String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q";
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Aug 11 12:43:00 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Aug 11 12:48:31 2011 +0000
@@ -1,7 +1,12 @@
 package de.intevation.flys.exports;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
+import org.jfree.chart.annotations.XYLineAnnotation;
+import org.jfree.chart.annotations.XYTextAnnotation;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.axis.ValueAxis;
@@ -21,6 +26,7 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 
+import de.intevation.flys.model.Annotation;
 
 /**
  * An OutGenerator that generates discharge curves.
@@ -58,9 +64,11 @@
 
     protected boolean inverted;
 
+    protected List<Annotation> annotations;
 
     public LongitudinalSectionGenerator() {
         super();
+        annotations = new ArrayList<Annotation>();
     }
 
 
@@ -90,6 +98,22 @@
         chart.addSubtitle(new TextTitle(subtitle));
     }
 
+    @Override
+    public JFreeChart generateChart() {
+        JFreeChart c = super.generateChart();
+        XYPlot p = (XYPlot) c.getPlot();
+
+        for (Annotation a: annotations) {
+            double pos = a.getRange().getA().doubleValue();
+            XYTextAnnotation ta = new XYTextAnnotation(a.getPosition().getValue(), pos, 140);
+            ta.setRotationAngle(270.0 / (Math.PI * 2.0));
+            p.addAnnotation(ta);
+            XYLineAnnotation la = new XYLineAnnotation(pos, 0, pos, 140);
+            p.addAnnotation(la);
+        }
+        return c;
+    }
+
 
     protected String getXAxisLabel() {
         return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
@@ -167,6 +191,9 @@
         else if (name.equals(LONGITUDINAL_Q)) {
             doQOut((WQKms) f.getData(artifact, context), attr);
         }
+        else if (name.equals(LONGITUDINAL_ANNOTATION)) {
+            doAnnotationsOut(f.getData(artifact, context), attr);
+        }
         else {
             logger.warn("Unknown facet name: " + name);
             return;
@@ -174,6 +201,12 @@
     }
 
 
+    protected void doAnnotationsOut(Object o, Document theme) {
+        logger.debug("LongitudinalSectionGenerator.doAnnotationsOut");
+        this.annotations = (List<Annotation>) o;
+    }
+
+
     /**
      * Process the output for W facets in a longitudinal section curve.
      *

http://dive4elements.wald.intevation.org