teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model.fixings; raimund@3131: teichmann@5831: import org.dive4elements.artifacts.Artifact; teichmann@5831: import org.dive4elements.artifacts.CallContext; raimund@3131: teichmann@5867: import org.dive4elements.river.artifacts.D4EArtifact; raimund@3131: teichmann@5831: import org.dive4elements.river.artifacts.model.CalculationResult; teichmann@5831: import org.dive4elements.river.artifacts.model.FacetTypes; teichmann@5831: import org.dive4elements.river.artifacts.model.Parameters; teichmann@5831: teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; raimund@3131: raimund@3131: import org.apache.log4j.Logger; raimund@3131: raimund@3131: raimund@3131: /** raimund@3131: * Facet to show the W|Q values. raimund@3131: * raimund@3131: * @author Raimund Renkert raimund@3131: */ raimund@3131: public class FixDeviationFacet bjoern@4442: extends FixingsFacet raimund@3131: implements FacetTypes { raimund@3131: teichmann@8202: /** House log. */ teichmann@8202: private static Logger log = Logger.getLogger(FixDeviationFacet.class); raimund@3131: sascha@3415: public static final String [] STD_DEV_COLUMN = { "std-dev" }; raimund@3131: raimund@3131: /** Trivial Constructor. */ raimund@3131: public FixDeviationFacet() { raimund@3131: } raimund@3131: raimund@3131: raimund@3131: /** raimund@3131: * @param name raimund@3131: */ raimund@3131: public FixDeviationFacet(String name, String description) { raimund@3131: super(0, name, description, ComputeType.ADVANCE, null, null); raimund@3131: } raimund@3131: christian@3192: public FixDeviationFacet(int index, String name, String description) { christian@3192: super(index, name, description, ComputeType.ADVANCE, null, null); christian@3192: } christian@3192: raimund@3131: raimund@3131: /** raimund@3131: * Returns the data this facet requires. raimund@3131: * raimund@3131: * @param artifact the owner artifact. raimund@3131: * @param context the CallContext (ignored). raimund@3131: * raimund@3131: * @return the data. raimund@3131: */ raimund@3131: @Override raimund@3131: public Object getData(Artifact artifact, CallContext context) { teichmann@8202: log.debug("FixDeviationFacet.getData"); teichmann@5867: if (artifact instanceof D4EArtifact) { teichmann@5867: D4EArtifact flys = (D4EArtifact)artifact; raimund@3131: raimund@3131: CalculationResult res = raimund@3131: (CalculationResult) flys.compute(context, raimund@3131: ComputeType.ADVANCE, raimund@3131: false); raimund@3131: sascha@3415: FixAnalysisResult result = (FixAnalysisResult) res.getData(); bjoern@4442: double currentKm = getCurrentKm(context); raimund@3131: raimund@3131: Parameters params = result.getParameters(); raimund@3131: raimund@3131: double[] stdDev = sascha@3415: params.interpolate("km", currentKm, STD_DEV_COLUMN); raimund@3131: sascha@3415: if (stdDev == null) { teichmann@8202: log.warn("getData: stdDev == null at km " + currentKm); raimund@3131: return null; raimund@3131: } raimund@3131: raimund@3131: return stdDev; raimund@3131: } raimund@3131: else { teichmann@8202: log.debug("Not an instance of FixationArtifact."); raimund@3131: return null; raimund@3131: } raimund@3131: } raimund@3131: raimund@3131: raimund@3131: /** raimund@3131: * Create a deep copy of this Facet. raimund@3131: * @return a deep copy. raimund@3131: */ raimund@3131: @Override raimund@3131: public FixDerivateFacet deepCopy() { raimund@3131: FixDerivateFacet copy = new FixDerivateFacet(); raimund@3131: copy.set(this); raimund@3131: return copy; raimund@3131: } raimund@3131: } raimund@3131: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :