Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/CrossSectionWaterLineFacet.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/CrossSectionWaterLineFacet.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.model; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import java.util.List; | |
6 | |
7 import org.dive4elements.artifacts.Artifact; | |
8 import org.dive4elements.artifacts.CallContext; | |
9 import org.dive4elements.artifacts.DataProvider; | |
10 | |
11 import org.dive4elements.artifactdatabase.state.Facet; | |
12 | |
13 import org.dive4elements.river.artifacts.WaterLineArtifact; | |
14 | |
15 import org.dive4elements.river.model.FastCrossSectionLine; | |
16 | |
17 import org.dive4elements.river.artifacts.geom.Lines; | |
18 | |
19 | |
20 /** | |
21 * Facet for Waterlines in Cross Sections. | |
22 */ | |
23 public class CrossSectionWaterLineFacet | |
24 extends BlackboardDataFacet | |
25 implements FacetTypes { | |
26 | |
27 /** Private logger to use. */ | |
28 private static Logger logger = | |
29 Logger.getLogger(CrossSectionWaterLineFacet.class); | |
30 | |
31 | |
32 /** Trivial constructor, set (maybe localized) description. */ | |
33 public CrossSectionWaterLineFacet(int idx, String description) { | |
34 super(idx, CROSS_SECTION_WATER_LINE, description); | |
35 } | |
36 | |
37 | |
38 /** | |
39 * Trivial constructor, set (maybe localized) description. | |
40 * @param idx Index of this facet. | |
41 * @param name 'type' of this facet. | |
42 * @param description (maybe) localized user-visible description. | |
43 */ | |
44 public CrossSectionWaterLineFacet(int idx, String name, String description) { | |
45 super(idx, name, description); | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Gets waterline (crossed with cross section) of waterlevel. | |
51 */ | |
52 public Object getData(Artifact artifact, CallContext context) { | |
53 logger.debug("Get data for cross section water line"); | |
54 | |
55 List<DataProvider> providers = context. | |
56 getDataProvider(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA); | |
57 if (providers.size() < 1) { | |
58 logger.warn("Could not find Cross-Section data provider."); | |
59 return new Lines.LineData(new double[][] {}, 0d, 0d); | |
60 } | |
61 | |
62 Object crossSection = providers.get(0) | |
63 .provideData(CrossSectionFacet.BLACKBOARD_CS_MASTER_DATA, | |
64 null, context); | |
65 Object nextKm = providers.get(0). | |
66 provideData(CrossSectionFacet.BLACKBOARD_CS_NEXT_KM, null, context); | |
67 Object prevKm = providers.get(0). | |
68 provideData(CrossSectionFacet.BLACKBOARD_CS_PREV_KM, null, context); | |
69 if (prevKm == null) | |
70 prevKm = new Double(-1d); | |
71 if (nextKm == null) | |
72 nextKm = new Double(-1d); | |
73 | |
74 if (!(artifact instanceof WaterLineArtifact)) { | |
75 logger.error("CrossSectionWaterLineFacet needs WaterLineArtifact"); | |
76 return new Lines.LineData(new double[][] {}, 0d,0d); | |
77 } | |
78 WaterLineArtifact lineArtifact = (WaterLineArtifact) artifact; | |
79 | |
80 if (crossSection != null) { | |
81 return lineArtifact.getWaterLines(this.getIndex(), | |
82 (FastCrossSectionLine) crossSection, (Double) nextKm, | |
83 (Double) prevKm, context); | |
84 } | |
85 else { | |
86 return new Lines.LineData(new double[][] {}, 0d,0d); | |
87 } | |
88 } | |
89 | |
90 | |
91 /** Do a deep copy. */ | |
92 @Override | |
93 public Facet deepCopy() { | |
94 CrossSectionWaterLineFacet copy = new CrossSectionWaterLineFacet( | |
95 this.getIndex(), | |
96 this.description); | |
97 copy.set(this); | |
98 return copy; | |
99 } | |
100 } | |
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |