Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java @ 9617:1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 10 Oct 2019 15:29:02 +0200 |
parents | 8dbb969091c5 |
children |
comparison
equal
deleted
inserted
replaced
9616:cedcee24a21a | 9617:1d4262a68f1f |
---|---|
12 | 12 |
13 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
14 import org.dive4elements.artifacts.Artifact; | 14 import org.dive4elements.artifacts.Artifact; |
15 import org.dive4elements.artifacts.CallContext; | 15 import org.dive4elements.artifacts.CallContext; |
16 import org.dive4elements.river.artifacts.D4EArtifact; | 16 import org.dive4elements.river.artifacts.D4EArtifact; |
17 import org.dive4elements.river.artifacts.resources.Resources; | |
18 import org.dive4elements.river.artifacts.access.BedHeightAccess; | 17 import org.dive4elements.river.artifacts.access.BedHeightAccess; |
19 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; | 18 import org.dive4elements.river.artifacts.model.BlackboardDataFacet; |
20 import org.dive4elements.river.artifacts.model.FacetTypes; | 19 import org.dive4elements.river.artifacts.model.FacetTypes; |
20 import org.dive4elements.river.artifacts.resources.Resources; | |
21 import org.dive4elements.river.model.BedHeight; | 21 import org.dive4elements.river.model.BedHeight; |
22 import org.dive4elements.river.model.BedHeightValue; | 22 import org.dive4elements.river.model.BedHeightValue; |
23 | 23 |
24 public class BedHeightFacet | 24 public class BedHeightFacet extends BlackboardDataFacet implements FacetTypes { |
25 extends BlackboardDataFacet | |
26 implements FacetTypes { | |
27 | 25 |
26 private static final long serialVersionUID = 1L; | |
28 private static final Logger log = Logger.getLogger(BedHeightFacet.class); | 27 private static final Logger log = Logger.getLogger(BedHeightFacet.class); |
29 | 28 |
30 public BedHeightFacet(String name, String description) { | 29 public BedHeightFacet(final String name, final String description) { |
31 this.name = name; | 30 this.name = name; |
32 this.description = description; | 31 this.description = description; |
33 this.index = 0; | 32 this.index = 0; |
34 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | 33 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); |
35 this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); | 34 this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); |
36 } | 35 } |
37 | 36 |
38 /** | 37 /** |
39 * Returns the data this facet requires. | 38 * Returns the data this facet requires. |
40 * | 39 * |
41 * @param artifact the owner artifact. | 40 * @param artifact |
42 * @param context the CallContext (ignored). | 41 * the owner artifact. |
42 * @param context | |
43 * the CallContext (ignored). | |
43 * | 44 * |
44 * @return the data. | 45 * @return the data. |
45 */ | 46 */ |
46 @Override | 47 @Override |
47 public Object getData(Artifact artifact, CallContext context) { | 48 public Object getData(final Artifact artifact, final CallContext context) { |
48 BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); | 49 final BedHeightAccess access = new BedHeightAccess((D4EArtifact) artifact); |
49 BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); | 50 final BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); |
50 List<BedHeightValue> bedheightValues = | 51 final List<BedHeightValue> bedheightValues = BedHeightValue.getBedHeightValues(single, access.getFrom(true), access.getTo(true)); |
51 BedHeightValue.getBedHeightValues( | 52 final double[][] values = new double[2][bedheightValues.size()]; |
52 single, | |
53 access.getFrom(true), | |
54 access.getTo(true)); | |
55 double[][] values = new double[2][bedheightValues.size()]; | |
56 int i = 0; | 53 int i = 0; |
57 for (BedHeightValue bedheightValue : bedheightValues) { | 54 for (final BedHeightValue bedheightValue : bedheightValues) { |
58 values[0][i] = bedheightValue.getStation(); | 55 values[0][i] = bedheightValue.getStation(); |
59 values[1][i] = bedheightValue.getHeight(); | 56 values[1][i] = bedheightValue.getHeight(); |
60 i++; | 57 i++; |
61 } | 58 } |
62 | 59 |
63 this.addMetaData(Resources.getMsg( | 60 this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.cur.elevation"), single.getCurElevationModel().getName()); |
64 context.getMeta(), | |
65 "meta.bedheight.cur.elevation"), | |
66 single.getCurElevationModel().getName()); | |
67 if (single.getOldElevationModel() != null) { | 61 if (single.getOldElevationModel() != null) { |
68 this.addMetaData(Resources.getMsg( | 62 this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.old.elevation"), single.getOldElevationModel().getName()); |
69 context.getMeta(), | |
70 "meta.bedheight.old.elevation"), | |
71 single.getOldElevationModel().getName()); | |
72 } | 63 } |
73 this.addMetaData(Resources.getMsg( | 64 this.addMetaData(Resources.getMsg(context.getMeta(), "meta.bedheight.river.elevation"), access.getRiver().getWstUnit().getName()); |
74 context.getMeta(), | |
75 "meta.bedheight.river.elevation"), | |
76 access.getRiver().getWstUnit().getName()); | |
77 | 65 |
78 return values; | 66 return values; |
79 } | 67 } |
80 | 68 |
81 /** | 69 /** |
82 * Create a deep copy of this Facet. | 70 * Create a deep copy of this Facet. |
71 * | |
83 * @return a deep copy. | 72 * @return a deep copy. |
84 */ | 73 */ |
85 @Override | 74 @Override |
86 public BedHeightFacet deepCopy() { | 75 public BedHeightFacet deepCopy() { |
87 BedHeightFacet copy = new BedHeightFacet(name, description); | 76 final BedHeightFacet copy = new BedHeightFacet(this.name, this.description); |
88 copy.set(this); | 77 copy.set(this); |
89 return copy; | 78 return copy; |
90 } | 79 } |
91 } | 80 } |
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |