changeset 7050:25a5ce8abfef generator-refactoring

Add annotationProcessor
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 19 Sep 2013 11:29:35 +0200
parents 165ea04b1545
children c4bacc5ddd9b
files artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java
diffstat 1 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java	Thu Sep 19 11:29:35 2013 +0200
@@ -0,0 +1,63 @@
+/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.process;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+//import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.jfree.RiverAnnotation;
+import org.dive4elements.river.themes.ThemeDocument;
+
+/**
+ * Add data to chart/generator.
+ *
+ */
+public class AnnotationProcessor implements Processor {
+
+    /** Private logger. */
+    private static final Logger logger =
+            Logger.getLogger(AnnotationProcessor.class);
+
+    @Override
+    public void doOut(
+            XYChartGenerator generator,
+            ArtifactAndFacet aaf,
+            ThemeDocument    theme,
+            boolean          visible,
+            int              index)
+    {
+        if (!visible) {
+            // Nothing to do
+            return;
+        }
+        CallContext context = generator.getCallContext();
+        if (!(aaf.getData(context) instanceof RiverAnnotation)) {
+            // Just a bit defensive should not happen
+            logger.error("Incompatible facet in doOut");
+            return;
+        }
+        RiverAnnotation ra = (RiverAnnotation)aaf.getData(context);
+        ra.setTheme(theme);
+        ra.setLabel(aaf.getFacetDescription());
+        generator.addAnnotations(ra);
+    }
+
+    @Override
+    public boolean canHandle(String facetType) {
+        if (facetType == null) {
+            return false;
+        }
+        return facetType.equals(FacetTypes.LONGITUDINAL_ANNOTATION);
+    }
+}

http://dive4elements.wald.intevation.org