Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java @ 5273:db196abd16ca
Use lookup table from bedd_height from database in importer.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 13 Mar 2013 16:39:08 +0100 |
parents | 7f8d92873d58 |
children |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.flys.artifacts.AnnotationArtifact; import de.intevation.flys.jfree.FLYSAnnotation; import de.intevation.flys.jfree.StickyAxisAnnotation; import de.intevation.flys.model.Annotation; import de.intevation.flys.model.FastAnnotations; import de.intevation.artifactdatabase.state.DefaultFacet; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.utils.FLYSUtils; import de.intevation.flys.artifacts.FLYSArtifact; /** * Facet to access Annotations (landmarks, POIs) of a river. */ public class AnnotationFacet extends DefaultFacet { /** Logger for this class. */ private static final Logger logger = Logger.getLogger(AnnotationFacet.class); /** * Trivial Constructor. */ public AnnotationFacet() { } /** * Trivial Constructor for a AnnotationFacet. * * @param index Database-Index to use. * @param name Name (~type) of Facet. * @param description Description of Facet. */ public AnnotationFacet(int index, String name, String description) { super(index, name, description); } /** * Get List of Annotations for river from Artifact. * * @param artifact (Annotation-)Artifact to query for list of Annotations. * @param context Ignored. */ @Override public Object getData(Artifact artifact, CallContext context) { // TODO issue880: Make annotations available _per type_ AnnotationArtifact annotationArtifact = (AnnotationArtifact) artifact; String riverName = FLYSUtils.getRivername((FLYSArtifact)artifact); FastAnnotations fas = LocationProvider.getAnnotations(riverName); String filterName = annotationArtifact.getFilterName(); FastAnnotations.Filter filter = (filterName == null) ? FastAnnotations.IS_POINT : new FastAnnotations.NameFilter(filterName); List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(fas.size()); for (Iterator<FastAnnotations.Annotation> iter = fas.filter(filter); iter.hasNext();) { FastAnnotations.Annotation fa = iter.next(); xy.add(new StickyAxisAnnotation( fa.getPosition(), (float)fa.getA(), StickyAxisAnnotation.SimpleAxis.X_AXIS)); } return new FLYSAnnotation(description, xy); } @Override public Facet deepCopy() { AnnotationFacet copy = new AnnotationFacet(); copy.set(this); return copy; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :