comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSoundingWidthFacet.java @ 7995:2f88a98d9aae facet-metadata

Added missing facet.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 02 Jul 2014 15:54:23 +0200
parents
children 99912f51468d
comparison
equal deleted inserted replaced
7994:3c1a16755e61 7995:2f88a98d9aae
1 package org.dive4elements.river.artifacts.model.minfo;
2
3 import java.util.List;
4
5 import org.dive4elements.artifacts.Artifact;
6 import org.dive4elements.artifacts.CallContext;
7 import org.dive4elements.river.artifacts.D4EArtifact;
8 import org.dive4elements.river.artifacts.access.BedHeightAccess;
9 import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
10 import org.dive4elements.river.artifacts.model.FacetTypes;
11 import org.dive4elements.river.model.BedHeightSingle;
12 import org.dive4elements.river.model.BedHeightSingleValue;
13
14
15 public class BedHeightSoundingWidthFacet
16 extends BlackboardDataFacet
17 implements FacetTypes
18 {
19 public BedHeightSoundingWidthFacet(String name, String description) {
20 this.name = name;
21 this.description = description;
22 this.index = 0;
23 this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
24 this.metaData.put("Y", "chart.bedheight.height.yaxis.label");
25 }
26
27 /**
28 * Returns the data this facet requires.
29 *
30 * @param artifact the owner artifact.
31 * @param context the CallContext (ignored).
32 *
33 * @return the data.
34 */
35 @Override
36 public Object getData(Artifact artifact, CallContext context) {
37 BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact);
38 /* Former doc (from BedHeightAccess):
39 * Return a {@link List} of {@link BedHeightSingleValue}s
40 * at the range of the artifact
41 * @return List of {@link BedHeightSingleValue}s */
42 BedHeightSingle single = BedHeightSingle.getBedHeightSingleById(
43 access.getHeightId());
44 List<BedHeightSingleValue> bedheightValues =
45 BedHeightSingleValue.getBedHeightSingleValues(
46 single,
47 access.getFrom(),
48 access.getTo());
49 double[][] values = new double[2][bedheightValues.size()];
50 int i = 0;
51 for (BedHeightSingleValue bedheightValue : bedheightValues) {
52 values[0][i] = bedheightValue.getStation();
53 values[1][i] = bedheightValue.getSoundingWidth();
54 i++;
55 }
56 return values;
57 }
58
59 /**
60 * Create a deep copy of this Facet.
61 * @return a deep copy.
62 */
63 @Override
64 public BedHeightSoundingWidthFacet deepCopy() {
65 BedHeightSoundingWidthFacet copy =
66 new BedHeightSoundingWidthFacet(name, description);
67 copy.set(this);
68 return copy;
69 }
70 }

http://dive4elements.wald.intevation.org