Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/AnnotationFacet.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/AnnotationFacet.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.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 org.dive4elements.artifacts.Artifact; | |
10 import org.dive4elements.artifacts.CallContext; | |
11 | |
12 import org.dive4elements.river.artifacts.AnnotationArtifact; | |
13 | |
14 import org.dive4elements.river.jfree.FLYSAnnotation; | |
15 import org.dive4elements.river.jfree.StickyAxisAnnotation; | |
16 | |
17 import org.dive4elements.river.model.Annotation; | |
18 import org.dive4elements.river.model.FastAnnotations; | |
19 | |
20 import org.dive4elements.artifactdatabase.state.DefaultFacet; | |
21 import org.dive4elements.artifactdatabase.state.Facet; | |
22 | |
23 import org.dive4elements.river.utils.FLYSUtils; | |
24 | |
25 import org.dive4elements.river.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 | |
66 // TODO issue880: Make annotations available _per type_ | |
67 AnnotationArtifact annotationArtifact = (AnnotationArtifact) artifact; | |
68 | |
69 String riverName = FLYSUtils.getRivername((FLYSArtifact)artifact); | |
70 | |
71 FastAnnotations fas = LocationProvider.getAnnotations(riverName); | |
72 | |
73 String filterName = annotationArtifact.getFilterName(); | |
74 | |
75 FastAnnotations.Filter filter = (filterName == null) | |
76 ? FastAnnotations.IS_POINT | |
77 : new FastAnnotations.NameFilter(filterName); | |
78 | |
79 List<StickyAxisAnnotation> xy = | |
80 new ArrayList<StickyAxisAnnotation>(fas.size()); | |
81 | |
82 for (Iterator<FastAnnotations.Annotation> iter = | |
83 fas.filter(filter); iter.hasNext();) { | |
84 FastAnnotations.Annotation fa = iter.next(); | |
85 | |
86 xy.add(new StickyAxisAnnotation( | |
87 fa.getPosition(), | |
88 (float)fa.getA(), | |
89 StickyAxisAnnotation.SimpleAxis.X_AXIS)); | |
90 } | |
91 | |
92 return new FLYSAnnotation(description, xy); | |
93 } | |
94 | |
95 | |
96 @Override | |
97 public Facet deepCopy() { | |
98 AnnotationFacet copy = new AnnotationFacet(); | |
99 copy.set(this); | |
100 return copy; | |
101 } | |
102 } | |
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |