Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AreaFacet.java @ 2021:1ae17b100973
Let StableDifferenceRenderer create a rectangular legenditem.
flys-artifacts/trunk@3476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 20 Dec 2011 06:50:06 +0000 |
parents | 3f1a63da2cf4 |
children | 3c3693e9c538 |
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.ArrayList; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.Artifact; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.DefaultFacet; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifactdatabase.state.Facet; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.DataProvider; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.artifacts.AreaArtifact; |
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 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 /** |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 * 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
|
24 * 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
|
25 * <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
|
26 * <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
|
27 * <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
|
28 * </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
|
29 * 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
|
30 * 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
|
31 */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 public class AreaFacet |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 extends DefaultFacet |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 implements FacetTypes { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 private static Logger logger = Logger.getLogger(AreaFacet.class); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 |
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
|
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 * 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
|
40 * @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
|
41 * @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
|
42 */ |
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
|
43 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
|
44 super(idx, name, description); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 |
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 * Gets Cross Section (profile). |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 * @param art artifact to get data from. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 * @param context ignored |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 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
|
54 logger.debug("Get data for area."); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 // Get information from artifact about which |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 // info to grab from blackboard. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 // |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 // All compatible facets should provide their data |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 // under the key (Artifact-UUID + Facet-Index). |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 AreaArtifact artifact = (AreaArtifact) art; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 Object lowerData = null; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 Object upperData = null; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 List<DataProvider> providers = context. |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 getDataProvider(artifact.getLowerDPKey()); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 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
|
68 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
|
69 artifact.getLowerDPKey() + "]"); |
2001
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 else { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 lowerData = providers.get(0).provideData( |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 artifact.getLowerDPKey(), null, context); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 providers = context.getDataProvider(artifact.getUpperDPKey()); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 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
|
78 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
|
79 artifact.getUpperDPKey() + "]"); |
2001
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 else { |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 upperData = providers.get(0).provideData( |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 artifact.getUpperDPKey(), null, context); |
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 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 if (upperData == null && lowerData == null) { |
2010
7f99845e9499
Store and access area.name data item.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2001
diff
changeset
|
87 logger.warn("Not given 'upper' and 'lower' for area"); |
2001
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 } |
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 return new Object[] {lowerData, upperData}; |
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 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 /** Do a deep copy. */ |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 @Override |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 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
|
97 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
|
98 copy.set(this); |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 return copy; |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 } |
28a5c163f9cd
Added partial area-infrastructure.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |