changeset 8540:422a78fbb4df

(issue1753) Add SQ Measurement dates as text annotations to points
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 13 Feb 2015 12:34:38 +0100
parents 84929f882fa2
children c0334399625b
files artifacts/src/main/java/org/dive4elements/river/exports/process/SQRelationProcessor.java
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SQRelationProcessor.java	Fri Feb 13 12:34:06 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SQRelationProcessor.java	Fri Feb 13 12:34:38 2015 +0100
@@ -9,15 +9,23 @@
 package org.dive4elements.river.exports.process;
 
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.text.DateFormat;
 
 import org.apache.log4j.Logger;
 
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.jfree.RiverAnnotation;
 import org.dive4elements.river.themes.ThemeDocument;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation;
+import org.jfree.chart.annotations.XYTextAnnotation;
 
 import org.dive4elements.river.jfree.JFreeUtil;
 
@@ -70,14 +78,29 @@
 
             SQ[] sqs = (SQ[]) data;
             series = new StyledXYSeries(desc, theme);
+            List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();
+
+            DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT,
+                Resources.getLocale(context.getMeta()));
 
             for (SQ sq: sqs) {
                 double q = sq.getQ();
                 double s = sq.getS();
                 if (s > 0d && q > 0d) {
                     series.add(q, s, false);
+                    // Annotate with measurement date
+                    if (sq.getDate() != null) {
+                        xy.add(new CollisionFreeXYTextAnnotation(dateFormat.format(sq.getDate()), q, s));
+                    }
                 }
             }
+
+            if (visible && theme.parseShowPointLabel()) {
+
+                RiverAnnotation annotation = new RiverAnnotation("Messdatum", null, null, theme);
+                annotation.setTextAnnotations(xy);
+                generator.addAnnotations(annotation);
+            }
         } else {
             log.error("Could not handle: " + facetName);
             return;

http://dive4elements.wald.intevation.org