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 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; 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; d@9617: import org.dive4elements.river.artifacts.resources.Resources; tom@8559: import org.dive4elements.river.model.BedHeight; tom@8559: import org.dive4elements.river.model.BedHeightValue; raimund@3614: d@9617: public class BedHeightFacet extends BlackboardDataFacet implements FacetTypes { raimund@3614: d@9617: private static final long serialVersionUID = 1L; teichmann@8202: private static final Logger log = Logger.getLogger(BedHeightFacet.class); rrenkert@7984: d@9617: public BedHeightFacet(final String name, final 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: * d@9617: * @param artifact d@9617: * the owner artifact. d@9617: * @param context d@9617: * the CallContext (ignored). raimund@3614: * raimund@3614: * @return the data. raimund@3614: */ raimund@3614: @Override d@9617: public Object getData(final Artifact artifact, final CallContext context) { d@9617: final BedHeightAccess access = new BedHeightAccess((D4EArtifact) artifact); d@9617: final BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); d@9617: final List bedheightValues = BedHeightValue.getBedHeightValues(single, access.getFrom(true), access.getTo(true)); d@9617: final double[][] values = new double[2][bedheightValues.size()]; tom@8714: int i = 0; d@9617: for (final BedHeightValue bedheightValue : bedheightValues) { tom@8714: values[0][i] = bedheightValue.getStation(); tom@8714: values[1][i] = bedheightValue.getHeight(); tom@8714: i++; bjoern@4534: } tom@8714: d@9617: this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.cur.elevation"), single.getCurElevationModel().getName()); tom@8714: if (single.getOldElevationModel() != null) { d@9617: this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.old.elevation"), single.getOldElevationModel().getName()); felix@7357: } d@9617: this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.river.elevation"), 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. d@9617: * raimund@3614: * @return a deep copy. raimund@3614: */ raimund@3614: @Override raimund@3614: public BedHeightFacet deepCopy() { d@9617: final BedHeightFacet copy = new BedHeightFacet(this.name, this.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 :