Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java @ 3812:f788d2d901d6
merged flys-artifacts/pre2.6-2011-12-05
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:53 +0200 |
parents | 69929c471646 |
children | 59622ba800c8 |
comparison
equal
deleted
inserted
replaced
3808:5fab0fe3c445 | 3812:f788d2d901d6 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import org.jfree.chart.annotations.XYTextAnnotation; | |
9 | |
10 import de.intevation.artifacts.Artifact; | |
11 import de.intevation.artifacts.CallContext; | |
12 | |
13 import de.intevation.flys.artifacts.AnnotationArtifact; | |
14 import de.intevation.flys.jfree.FLYSAnnotation; | |
15 import de.intevation.flys.jfree.StickyAxisAnnotation; | |
16 | |
17 import de.intevation.flys.model.Annotation; | |
18 | |
19 import de.intevation.artifactdatabase.state.DefaultFacet; | |
20 import de.intevation.artifactdatabase.state.Facet; | |
21 | |
22 /** | |
23 * Facet to access Annotations (landmarks, POIs) of a river. | |
24 */ | |
25 public class AnnotationFacet | |
26 extends DefaultFacet | |
27 { | |
28 /** Logger for this class. */ | |
29 private static final Logger logger = Logger.getLogger(AnnotationFacet.class); | |
30 | |
31 | |
32 /** | |
33 * Trivial Constructor. | |
34 */ | |
35 public AnnotationFacet() { | |
36 } | |
37 | |
38 | |
39 /** | |
40 * Trivial Constructor for a AnnotationFacet. | |
41 * | |
42 * @param index Database-Index to use. | |
43 * @param name Name (~type) of Facet. | |
44 * @param description Description of Facet. | |
45 */ | |
46 public AnnotationFacet(int index, String name, String description) { | |
47 super(index, name, description); | |
48 } | |
49 | |
50 | |
51 /** | |
52 * Get List of Annotations for river from Artifact. | |
53 * | |
54 * @param artifact (Annotation-)Artifact to query for list of Annotations. | |
55 * @param context Ignored. | |
56 */ | |
57 @Override | |
58 public Object getData(Artifact artifact, CallContext context) { | |
59 AnnotationArtifact annotationArtifact = (AnnotationArtifact) artifact; | |
60 | |
61 List<Annotation> as = annotationArtifact.getAnnotations(); | |
62 List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>(); | |
63 | |
64 for (Annotation a: as) { | |
65 xy.add(new StickyAxisAnnotation( | |
66 a.getPosition().getValue(), | |
67 (float) a.getRange().getA().doubleValue(), | |
68 StickyAxisAnnotation.SimpleAxis.X_AXIS)); | |
69 } | |
70 | |
71 return new FLYSAnnotation(description, xy); | |
72 } | |
73 | |
74 | |
75 @Override | |
76 public Facet deepCopy() { | |
77 AnnotationFacet copy = new AnnotationFacet(); | |
78 copy.set(this); | |
79 return copy; | |
80 } | |
81 } |