Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java @ 7050:25a5ce8abfef generator-refactoring
Add annotationProcessor
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 19 Sep 2013 11:29:35 +0200 |
parents | |
children | 1011a40ee79c |
comparison
equal
deleted
inserted
replaced
7049:165ea04b1545 | 7050:25a5ce8abfef |
---|---|
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.exports.process; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 import org.jfree.data.xy.XYSeries; | |
13 | |
14 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.model.FacetTypes; | |
17 //import org.dive4elements.river.exports.DiagramGenerator; | |
18 import org.dive4elements.river.exports.XYChartGenerator; | |
19 import org.dive4elements.river.jfree.RiverAnnotation; | |
20 import org.dive4elements.river.themes.ThemeDocument; | |
21 | |
22 /** | |
23 * Add data to chart/generator. | |
24 * | |
25 */ | |
26 public class AnnotationProcessor implements Processor { | |
27 | |
28 /** Private logger. */ | |
29 private static final Logger logger = | |
30 Logger.getLogger(AnnotationProcessor.class); | |
31 | |
32 @Override | |
33 public void doOut( | |
34 XYChartGenerator generator, | |
35 ArtifactAndFacet aaf, | |
36 ThemeDocument theme, | |
37 boolean visible, | |
38 int index) | |
39 { | |
40 if (!visible) { | |
41 // Nothing to do | |
42 return; | |
43 } | |
44 CallContext context = generator.getCallContext(); | |
45 if (!(aaf.getData(context) instanceof RiverAnnotation)) { | |
46 // Just a bit defensive should not happen | |
47 logger.error("Incompatible facet in doOut"); | |
48 return; | |
49 } | |
50 RiverAnnotation ra = (RiverAnnotation)aaf.getData(context); | |
51 ra.setTheme(theme); | |
52 ra.setLabel(aaf.getFacetDescription()); | |
53 generator.addAnnotations(ra); | |
54 } | |
55 | |
56 @Override | |
57 public boolean canHandle(String facetType) { | |
58 if (facetType == null) { | |
59 return false; | |
60 } | |
61 return facetType.equals(FacetTypes.LONGITUDINAL_ANNOTATION); | |
62 } | |
63 } |