# HG changeset patch # User Andre Heinecke # Date 1379582975 -7200 # Node ID 25a5ce8abfefb8529556c38761f53dfddb7a78ce # Parent 165ea04b15450b1d8075a4f60b41288ce7d96d70 Add annotationProcessor diff -r 165ea04b1545 -r 25a5ce8abfef artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java --- /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); + } +}