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.minfo; raimund@3614: rrenkert@7984: import gnu.trove.TDoubleArrayList; rrenkert@7984: rrenkert@7984: import java.util.List; rrenkert@7984: rrenkert@7984: import org.apache.log4j.Logger; teichmann@5831: import org.dive4elements.artifacts.Artifact; teichmann@5831: import org.dive4elements.artifacts.CallContext; teichmann@5867: import org.dive4elements.river.artifacts.D4EArtifact; tom@8714: import org.dive4elements.river.artifacts.resources.Resources; teichmann@5831: import org.dive4elements.river.artifacts.access.BedHeightAccess; teichmann@5831: import org.dive4elements.river.artifacts.model.BlackboardDataFacet; teichmann@5831: import org.dive4elements.river.artifacts.model.FacetTypes; tom@8559: import org.dive4elements.river.model.BedHeight; tom@8559: import org.dive4elements.river.model.BedHeightValue; raimund@3614: raimund@3614: public class BedHeightFacet raimund@3614: extends BlackboardDataFacet raimund@3614: implements FacetTypes { raimund@3614: teichmann@8202: private static final Logger log = Logger.getLogger(BedHeightFacet.class); rrenkert@7984: tom@8714: public BedHeightFacet(String name, String description) { raimund@3614: this.name = name; raimund@3614: this.description = description; raimund@3614: this.index = 0; rrenkert@7894: this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); tom@8267: this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); raimund@3614: } raimund@3614: raimund@3614: /** raimund@3614: * Returns the data this facet requires. raimund@3614: * raimund@3614: * @param artifact the owner artifact. raimund@3614: * @param context the CallContext (ignored). raimund@3614: * raimund@3614: * @return the data. raimund@3614: */ raimund@3614: @Override raimund@3614: public Object getData(Artifact artifact, CallContext context) { teichmann@6101: BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); tom@8714: BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); tom@8714: List bedheightValues = tom@8714: BedHeightValue.getBedHeightValues( tom@8714: single, tom@8714: access.getFrom(true), tom@8714: access.getTo(true)); tom@8714: double[][] values = new double[2][bedheightValues.size()]; tom@8714: int i = 0; tom@8714: for (BedHeightValue bedheightValue : bedheightValues) { tom@8714: values[0][i] = bedheightValue.getStation(); tom@8714: values[1][i] = bedheightValue.getHeight(); tom@8714: i++; bjoern@4534: } tom@8714: tom@8714: this.addMetaData(Resources.getMsg( tom@8714: context.getMeta(), tom@8714: "meta.bedheight.cur.elevation"), tom@8714: single.getCurElevationModel().getName()); tom@8714: if (single.getOldElevationModel() != null) { tom@8714: this.addMetaData(Resources.getMsg( tom@8714: context.getMeta(), tom@8714: "meta.bedheight.old.elevation"), tom@8714: single.getOldElevationModel().getName()); felix@7357: } tom@8714: this.addMetaData(Resources.getMsg( tom@8714: context.getMeta(), tom@8714: "meta.bedheight.river.elevation"), tom@8714: access.getRiver().getWstUnit().getName()); tom@8714: tom@8714: return values; raimund@3614: } felix@7357: raimund@3614: /** raimund@3614: * Create a deep copy of this Facet. raimund@3614: * @return a deep copy. raimund@3614: */ raimund@3614: @Override raimund@3614: public BedHeightFacet deepCopy() { tom@8714: BedHeightFacet copy = new BedHeightFacet(name, description); raimund@3614: copy.set(this); raimund@3614: return copy; raimund@3614: } raimund@3614: } raimund@3614: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :