view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java @ 2263:bdd032bfd978

Minor i18n for reference curve chart added. flys-artifacts/trunk@3919 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 06 Feb 2012 13:04:52 +0000
parents 98f3ef8da857
children bc23341bf322
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 de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;

import de.intevation.artifactdatabase.state.DefaultFacet;
import de.intevation.artifactdatabase.state.Facet;

import de.intevation.flys.artifacts.CrossSectionArtifact;

import de.intevation.flys.artifacts.states.DefaultState.ComputeType;


/**
 * Trival Facet for Cross Sections (profiles).
 */
public class CrossSectionFacet
extends      DefaultFacet
implements   FacetTypes {

    public static String BLACKBOARD_CS_MASTER_DATA
        = "crosssection.masterprofile.data";

    private static Logger logger = Logger.getLogger(CrossSectionFacet.class);

    protected ComputeType type;


    /** Trivial constructor, set (maybe localized) description. */
    public CrossSectionFacet(int idx, String description) {
        super(idx, CROSS_SECTION, description);
        type = ComputeType.ADVANCE;
    }


    /** Tell world we know about crosssection masters data and its index. */
    public List getDataProviderKeys(Artifact art) {
        CrossSectionArtifact artifact = (CrossSectionArtifact) art;
        List keys = new ArrayList();
        if (artifact.isMaster()) {
            keys.add(BLACKBOARD_CS_MASTER_DATA);
        }
        keys.add(artifact.identifier() + getIndex());
        return keys;
    }


    /**
     * Can provide the master cross section lines or its index.
     * @param artifact crosssection-artifact
     * @param key      will respond on BLACKBOARD_CS_MASTER_DATA
     * @param param    ignored
     * @param context  ignored
     * @return data from artifact (cross section master track).
     */
    public Object provideBlackboardData(Artifact artifact,
        Object key,
        Object param,
        CallContext context
    ) {
        CrossSectionArtifact crossSection = (CrossSectionArtifact) artifact;

        if (key.equals(BLACKBOARD_CS_MASTER_DATA)) {
            return crossSection.searchCrossSectionLine();
        }
        else if (key.equals(artifact.identifier() + getIndex())) {
            return getData(artifact, context);
        }
        else {
            logger.warn("Cannot provide data for key: " + key);
            return null;
        }
    }


    /**
     * Gets Cross Section (profile).
     * @param art artifact to get data from.
     * @param context ignored
     */
    public Object getData(Artifact art, CallContext context) {
        logger.debug("Get data for cross section");

        CrossSectionArtifact artifact = (CrossSectionArtifact)art;

        return artifact.getCrossSectionData();
    }


    /** Do a deep copy. */
    @Override 
    public Facet deepCopy() {
        CrossSectionFacet copy = new CrossSectionFacet(this.index, this.description);
        copy.set(this);
        return copy;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org