view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java @ 4205:0dd8963cec9c

Set also the width of the GaugeTree when resizing the GaugePanel GWT is no longer able to calculate and set the correct width of the GaugeTree since the GaugeTree is added via a Canvas wrapper. Therefore set the width manually when resizing the GaugeTree.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 22 Oct 2012 15:33:16 +0200
parents 5642a83420f2
children
line wrap: on
line source
package de.intevation.flys.artifacts.model;

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

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.FLYSArtifact;
import de.intevation.flys.artifacts.WINFOArtifact;

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


/**
 * Data of a duration curve.
 */
public class DurationCurveFacet extends DefaultFacet {

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

    /** Blackboard data provider key for durationcurve (wqday) data. */
    public static String BB_DURATIONCURVE = "durationcurve";

    /** Blackboard data provider key for km of durationcurve. */
    public static String BB_DURATIONCURVE_KM = "durationcurve.km";

    public DurationCurveFacet() {
    }

    public DurationCurveFacet(String name, String description) {
        super(0, name, description);
    }


    /**
     * Expose state computation from WINFOArtifact.
     */
    public Object getData(Artifact artifact, CallContext context) {
        logger.debug("Get data for duration curve data");

        WINFOArtifact winfo = (WINFOArtifact)artifact;

        CalculationResult cr = (CalculationResult)winfo.compute(
            context, ComputeType.ADVANCE, false);

        return cr.getData();
    }


    @Override
    public List getStaticDataProviderKeys(Artifact art) {
        List list = new ArrayList();
        list.add(BB_DURATIONCURVE);
        list.add(BB_DURATIONCURVE_KM);
        return list;
    }


    /**
     * Can provide whatever getData returns and additionally the location.
     * @param key      will respond on BB_DURATIONCURVE +KM
     * @param param    ignored
     * @param context  ignored
     * @return whatever getData delivers or location.
     */
    @Override
    public Object provideBlackboardData(Artifact artifact,
        Object key,
        Object param,
        CallContext context
    ) {
        if (key.equals(BB_DURATIONCURVE)) {
            return getData(artifact, context);
        }
        else if (key.equals(BB_DURATIONCURVE_KM)) {
            return ((FLYSArtifact)artifact).getDataAsString("ld_locations");
        }
        else {
            return null;
        }
    }


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

http://dive4elements.wald.intevation.org