Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionWaterLineFacet.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | 31168ac9c7e7 |
children | 6153c50f78cf |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import java.util.List; | |
6 | |
7 import de.intevation.artifacts.Artifact; | |
8 import de.intevation.artifacts.CallContext; | |
9 import de.intevation.artifacts.DataProvider; | |
10 | |
11 import de.intevation.artifactdatabase.state.Facet; | |
12 | |
13 import de.intevation.flys.artifacts.WaterLineArtifact; | |
14 | |
15 import de.intevation.flys.model.FastCrossSectionLine; | |
16 | |
17 import de.intevation.flys.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 WaterLineArtifact lineArtifact = (WaterLineArtifact) artifact; | |
75 | |
76 if (crossSection != null) { | |
77 return lineArtifact.getWaterLines(this.getIndex(), | |
78 (FastCrossSectionLine) crossSection, (Double) nextKm, (Double) prevKm); | |
79 } | |
80 else { | |
81 return new Lines.LineData(new double[][] {}, 0d,0d); | |
82 } | |
83 } | |
84 | |
85 | |
86 /** Do a deep copy. */ | |
87 @Override | |
88 public Facet deepCopy() { | |
89 CrossSectionWaterLineFacet copy = new CrossSectionWaterLineFacet( | |
90 this.getIndex(), | |
91 this.description); | |
92 copy.set(this); | |
93 return copy; | |
94 } | |
95 } | |
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |