Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | df70f14af981 |
children | efb067ab2ca4 |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.Iterator; | |
5 import java.util.List; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 import de.intevation.artifacts.Artifact; | |
10 import de.intevation.artifacts.CallContext; | |
11 | |
12 import de.intevation.flys.artifacts.AnnotationArtifact; | |
13 | |
14 import de.intevation.flys.jfree.FLYSAnnotation; | |
15 import de.intevation.flys.jfree.StickyAxisAnnotation; | |
16 | |
17 import de.intevation.flys.model.Annotation; | |
18 import de.intevation.flys.model.FastAnnotations; | |
19 | |
20 import de.intevation.artifactdatabase.state.DefaultFacet; | |
21 import de.intevation.artifactdatabase.state.Facet; | |
22 | |
23 import de.intevation.flys.utils.FLYSUtils; | |
24 | |
25 import de.intevation.flys.artifacts.FLYSArtifact; | |
26 | |
27 | |
28 /** | |
29 * Facet to access Annotations (landmarks, POIs) of a river. | |
30 */ | |
31 public class AnnotationFacet | |
32 extends DefaultFacet | |
33 { | |
34 /** Logger for this class. */ | |
35 private static final Logger logger = Logger.getLogger(AnnotationFacet.class); | |
36 | |
37 | |
38 /** | |
39 * Trivial Constructor. | |
40 */ | |
41 public AnnotationFacet() { | |
42 } | |
43 | |
44 | |
45 /** | |
46 * Trivial Constructor for a AnnotationFacet. | |
47 * | |
48 * @param index Database-Index to use. | |
49 * @param name Name (~type) of Facet. | |
50 * @param description Description of Facet. | |
51 */ | |
52 public AnnotationFacet(int index, String name, String description) { | |
53 super(index, name, description); | |
54 } | |
55 | |
56 | |
57 /** | |
58 * Get List of Annotations for river from Artifact. | |
59 * | |
60 * @param artifact (Annotation-)Artifact to query for list of Annotations. | |
61 * @param context Ignored. | |
62 */ | |
63 @Override | |
64 public Object getData(Artifact artifact, CallContext context) { | |
65 AnnotationArtifact annotationArtifact = (AnnotationArtifact) artifact; | |
66 | |
67 String riverName = FLYSUtils.getRivername((FLYSArtifact)artifact); | |
68 | |
69 FastAnnotations fas = LocationProvider.getAnnotations(riverName); | |
70 | |
71 List<StickyAxisAnnotation> xy = | |
72 new ArrayList<StickyAxisAnnotation>(fas.size()); | |
73 | |
74 for (Iterator<FastAnnotations.Annotation> iter = | |
75 fas.filter(FastAnnotations.IS_POINT); iter.hasNext();) { | |
76 FastAnnotations.Annotation fa = iter.next(); | |
77 | |
78 xy.add(new StickyAxisAnnotation( | |
79 fa.getPosition(), | |
80 (float)fa.getA(), | |
81 StickyAxisAnnotation.SimpleAxis.X_AXIS)); | |
82 } | |
83 | |
84 return new FLYSAnnotation(description, xy); | |
85 } | |
86 | |
87 | |
88 @Override | |
89 public Facet deepCopy() { | |
90 AnnotationFacet copy = new AnnotationFacet(); | |
91 copy.set(this); | |
92 return copy; | |
93 } | |
94 } | |
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |