view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java @ 3809:cc83b8e42dbe

Picked rev3347-rev3351 from trunk. flys-artifacts/tags/pre2.6-2011-12-05@3352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 05 Dec 2011 09:48:44 +0000
parents 69929c471646
children 59622ba800c8
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import org.jfree.chart.annotations.XYTextAnnotation;

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.artifactdatabase.state.DefaultFacet;
import de.intevation.artifactdatabase.state.Facet;

/**
 * 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) {
        AnnotationArtifact annotationArtifact = (AnnotationArtifact) artifact;

        List<Annotation>       as = annotationArtifact.getAnnotations();
        List<XYTextAnnotation> xy = new ArrayList<XYTextAnnotation>();

        for (Annotation a: as) {
            xy.add(new StickyAxisAnnotation(
                a.getPosition().getValue(),
                (float) a.getRange().getA().doubleValue(),
                StickyAxisAnnotation.SimpleAxis.X_AXIS));
        }

        return new FLYSAnnotation(description, xy);
    }


    @Override
    public Facet deepCopy() {
        AnnotationFacet copy = new AnnotationFacet();
        copy.set(this);
        return copy;
    }
}

http://dive4elements.wald.intevation.org