Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java @ 2096:bf598599782a
Made old calculation results available for floodmaps.
flys-artifacts/trunk@3644 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 11 Jan 2012 10:17:16 +0000 |
parents | 76cedac30d35 |
children | bb0dede9294f |
rev | line source |
---|---|
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifactdatabase.state.DefaultFacet; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.Facet; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.DataProvider; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.AreaArtifact; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 /** |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 * Trival Facet for areas. |
2018
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
20 * Note that this Facet comes in two "types" (names): |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
21 * <ul> |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
22 * <li>CROSS_SECTION_AREA (cross_section.area) and</li> |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
23 * <li>LONGITUDINAL_SECTION_AREA (longitudinal.area</li> |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
24 * </ul> |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
25 * This is to support different diagram types without being painted in both |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
26 * at the same time. The name has to be given when constructing. |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 public class AreaFacet |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 extends DefaultFacet |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 implements FacetTypes { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 private static Logger logger = Logger.getLogger(AreaFacet.class); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
2018
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
34 /** |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
35 * Constructor, set (maybe localized) description and name. |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
36 * @param idx Index given when querying artifact for data. |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
37 * @param name important to discern areas in different diagram types. |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
38 */ |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
39 public AreaFacet(int idx, String name, String description) { |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
40 super(idx, name, description); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 /** |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 * Gets Cross Section (profile). |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 * @param art artifact to get data from. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 * @param context ignored |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 public Object getData(Artifact art, CallContext context) { |
2010
7f99845e9499
Store and access area.name data item.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2001
diff
changeset
|
50 logger.debug("Get data for area."); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 // Get information from artifact about which |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 // info to grab from blackboard. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 // |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 // All compatible facets should provide their data |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 // under the key (Artifact-UUID + Facet-Index). |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 AreaArtifact artifact = (AreaArtifact) art; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 Object lowerData = null; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 Object upperData = null; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 List<DataProvider> providers = context. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 getDataProvider(artifact.getLowerDPKey()); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 if (providers.size() < 1) { |
2018
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
64 logger.warn("No 'lower' provider given for area [" + |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
65 artifact.getLowerDPKey() + "]"); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 else { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 lowerData = providers.get(0).provideData( |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 artifact.getLowerDPKey(), null, context); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 providers = context.getDataProvider(artifact.getUpperDPKey()); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 if (providers.size() < 1) { |
2018
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
74 logger.warn("No 'upper' provider given for area [" + |
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
75 artifact.getUpperDPKey() + "]"); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 else { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 upperData = providers.get(0).provideData( |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 artifact.getUpperDPKey(), null, context); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 if (upperData == null && lowerData == null) { |
2010
7f99845e9499
Store and access area.name data item.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2001
diff
changeset
|
83 logger.warn("Not given 'upper' and 'lower' for area"); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 |
2033
76cedac30d35
Store additional Parameter in AreaArtifact (paint everything between curve a and b?).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
86 return new Object[] {lowerData, |
76cedac30d35
Store additional Parameter in AreaArtifact (paint everything between curve a and b?).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
87 upperData, |
76cedac30d35
Store additional Parameter in AreaArtifact (paint everything between curve a and b?).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2022
diff
changeset
|
88 Boolean.valueOf(artifact.getPaintBetween())}; |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 /** Do a deep copy. */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 @Override |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 public Facet deepCopy() { |
2018
3f1a63da2cf4
Prepare ability to paint areas in longitudinal section diagrams, too (next to CrossSection diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2010
diff
changeset
|
95 AreaFacet copy = new AreaFacet(this.index, this.name, this.description); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 copy.set(this); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 return copy; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |