Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java @ 2302:300d50f74dab
Handle manual points in discharge curve generator.
flys-artifacts/trunk@3970 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 14:45:53 +0000 |
parents | bc23341bf322 |
children | da35b8a23ffb |
rev | line source |
---|---|
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
3 import java.util.ArrayList; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
4 import java.util.List; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
5 |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.Artifact; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.DefaultFacet; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifactdatabase.state.Facet; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
14 import de.intevation.flys.artifacts.CrossSectionArtifact; |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 /** |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
20 * Trival Facet for Cross Sections (profiles). |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 */ |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 public class CrossSectionFacet |
2301
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
23 extends BlackboardDataFacet |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 implements FacetTypes { |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
26 public static String BLACKBOARD_CS_MASTER_DATA |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
27 = "crosssection.masterprofile.data"; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
28 |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 private static Logger logger = Logger.getLogger(CrossSectionFacet.class); |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
1138
d90f5bfa3ddf
Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1122
diff
changeset
|
31 protected ComputeType type; |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
33 |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 /** Trivial constructor, set (maybe localized) description. */ |
1803
51e59f221333
Minor preparations for WINFO/CrossSection to handle multiple cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1138
diff
changeset
|
35 public CrossSectionFacet(int idx, String description) { |
51e59f221333
Minor preparations for WINFO/CrossSection to handle multiple cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1138
diff
changeset
|
36 super(idx, CROSS_SECTION, description); |
1138
d90f5bfa3ddf
Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1122
diff
changeset
|
37 type = ComputeType.ADVANCE; |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 } |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
41 /** Tell world we know about crosssection masters data and its index. */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
42 public List getDataProviderKeys(Artifact art) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
43 CrossSectionArtifact artifact = (CrossSectionArtifact) art; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
44 List keys = new ArrayList(); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
45 if (artifact.isMaster()) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
46 keys.add(BLACKBOARD_CS_MASTER_DATA); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
47 } |
2002
98f3ef8da857
Register under a key on blackboard to meet assumptions by areaartifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
48 keys.add(artifact.identifier() + getIndex()); |
2301
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
49 keys.addAll(super.getDataProviderKeys(art)); |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
50 return keys; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
51 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
52 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
53 |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 /** |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
55 * Can provide the master cross section lines or its index. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
56 * @param artifact crosssection-artifact |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
57 * @param key will respond on BLACKBOARD_CS_MASTER_DATA |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
58 * @param param ignored |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
59 * @param context ignored |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
60 * @return data from artifact (cross section master track). |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 */ |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
62 public Object provideBlackboardData(Artifact artifact, |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
63 Object key, |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
64 Object param, |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
65 CallContext context |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
66 ) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
67 CrossSectionArtifact crossSection = (CrossSectionArtifact) artifact; |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
68 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
69 if (key.equals(BLACKBOARD_CS_MASTER_DATA)) { |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
70 return crossSection.searchCrossSectionLine(); |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
71 } |
2002
98f3ef8da857
Register under a key on blackboard to meet assumptions by areaartifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
72 else if (key.equals(artifact.identifier() + getIndex())) { |
98f3ef8da857
Register under a key on blackboard to meet assumptions by areaartifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
73 return getData(artifact, context); |
98f3ef8da857
Register under a key on blackboard to meet assumptions by areaartifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1967
diff
changeset
|
74 } |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
75 else { |
2301
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
76 Object obj = super.provideBlackboardData(artifact, key, param, |
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
77 context); |
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
78 if (obj == null) { |
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
79 logger.warn("Cannot provide data for key: " + key); |
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
80 } |
bc23341bf322
Repair area over cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2002
diff
changeset
|
81 return obj; |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
82 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
83 } |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
84 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
85 |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
86 /** |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
87 * Gets Cross Section (profile). |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
88 * @param art artifact to get data from. |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
89 * @param context ignored |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
90 */ |
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
91 public Object getData(Artifact art, CallContext context) { |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 logger.debug("Get data for cross section"); |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
94 CrossSectionArtifact artifact = (CrossSectionArtifact)art; |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 |
1967
27bb2e24f7f8
Preparations for better CrossSection diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1803
diff
changeset
|
96 return artifact.getCrossSectionData(); |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 } |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 |
1138
d90f5bfa3ddf
Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1122
diff
changeset
|
99 |
d90f5bfa3ddf
Fix profile loading of cross section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1122
diff
changeset
|
100 /** Do a deep copy. */ |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 @Override |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 public Facet deepCopy() { |
1803
51e59f221333
Minor preparations for WINFO/CrossSection to handle multiple cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1138
diff
changeset
|
103 CrossSectionFacet copy = new CrossSectionFacet(this.index, this.description); |
1116
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 copy.set(this); |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 return copy; |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 } |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 } |
05e4ef0f9489
Improved stub for CrossSections (including Factory and Facet).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |