Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/AreaArtifact.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 2f7fed1eb4bf |
children | a2735a4bf75e |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import org.w3c.dom.Document; | |
9 | |
10 import de.intevation.artifacts.Artifact; | |
11 import de.intevation.artifacts.ArtifactFactory; | |
12 import de.intevation.artifacts.CallMeta; | |
13 | |
14 import de.intevation.flys.artifacts.model.AreaFacet; | |
15 | |
16 | |
17 import de.intevation.flys.artifacts.states.AreaCreationState; | |
18 import de.intevation.flys.artifacts.states.StaticState; | |
19 | |
20 import de.intevation.artifactdatabase.state.Facet; | |
21 import de.intevation.artifactdatabase.state.State; | |
22 | |
23 | |
24 /** | |
25 * Artifact describing the area between two WKms. | |
26 */ | |
27 public class AreaArtifact extends StaticFLYSArtifact { | |
28 | |
29 /** Name of Artifact. */ | |
30 public static final String AREA_ARTIFACT_NAME = "area_artifact"; | |
31 | |
32 /** Dataitem: Facet name. Facets with this name will be created (important | |
33 * to not have the area calculated in e.g. a CrossSection to be shown in | |
34 * LongitudinalSection. */ | |
35 protected static final String FACET_NAME = "area.facet"; | |
36 | |
37 /** Name of state. */ | |
38 public static final String STATIC_STATE_NAME = "state.area_artifact"; | |
39 | |
40 /** data item name to access upper curve. */ | |
41 protected static final String AREA_CURVE_OVER = "area.curve_over"; | |
42 | |
43 /** data item name to access lower curve. */ | |
44 protected static final String AREA_CURVE_UNDER = "area.curve_under"; | |
45 | |
46 /** data item name to access whether or not paint over and under. */ | |
47 protected static final String AREA_BETWEEN = "area.between"; | |
48 | |
49 /** Name of state. */ | |
50 protected static final String AREA_NAME = "area.name"; | |
51 | |
52 /** Own logger. */ | |
53 private static final Logger logger = | |
54 Logger.getLogger(AreaArtifact.class); | |
55 | |
56 | |
57 /** Return given name. */ | |
58 @Override | |
59 public String getName() { | |
60 return AREA_ARTIFACT_NAME; | |
61 } | |
62 | |
63 | |
64 /** Store ids, create an AreaFacet. */ | |
65 @Override | |
66 public void setup( | |
67 String identifier, | |
68 ArtifactFactory factory, | |
69 Object context, | |
70 CallMeta callMeta, | |
71 Document data) | |
72 { | |
73 logger.info("AreaArtifact.setup"); | |
74 | |
75 super.setup(identifier, factory, context, callMeta, data); | |
76 | |
77 // TODO yet unused. | |
78 String ids = getDatacageIDValue(data); | |
79 | |
80 // TODO this facet will be remodeled during next feed. | |
81 List<Facet> fs = new ArrayList<Facet>(); | |
82 fs.add(new AreaFacet(0, "", "TODO: I am an AreaFacet")); | |
83 | |
84 AreaCreationState state = (AreaCreationState) getCurrentState(context); | |
85 | |
86 if (!fs.isEmpty()) { | |
87 facets.put(getCurrentStateId(), fs); | |
88 } | |
89 } | |
90 | |
91 // TODO Data is not cached in this way. | |
92 | |
93 /** Do not copy data from daddyfact. */ | |
94 @Override | |
95 protected void initialize( | |
96 Artifact artifact, | |
97 Object context, | |
98 CallMeta callMeta) | |
99 { | |
100 // do nothing | |
101 } | |
102 | |
103 | |
104 /** | |
105 * Get name of facets to create. | |
106 */ | |
107 public String getFacetName() { | |
108 return getDataAsString(FACET_NAME); | |
109 } | |
110 | |
111 | |
112 /** | |
113 * Get dataprovider key for the 'lower' curve (we got that information fed | |
114 * from the client and store it as data). | |
115 */ | |
116 public String getLowerDPKey() { | |
117 return getDataAsString(AREA_CURVE_UNDER); | |
118 } | |
119 | |
120 | |
121 /** | |
122 * True if the whole area between the two curves shall be filled. | |
123 */ | |
124 public boolean getPaintBetween() { | |
125 String val = getDataAsString(AREA_BETWEEN); | |
126 | |
127 return val != null && val.equals("true"); | |
128 } | |
129 | |
130 | |
131 /** | |
132 * Get dataprovider key for the 'upper' curve (we got that information fed | |
133 * from the client and store it as data). | |
134 */ | |
135 public String getUpperDPKey() { | |
136 return getDataAsString(AREA_CURVE_OVER); | |
137 } | |
138 | |
139 | |
140 /** Return data item that is used to configure name of area. */ | |
141 public String getAreaName() { | |
142 return getDataAsString(AREA_NAME); | |
143 } | |
144 | |
145 | |
146 /** | |
147 * Create and return a new AreaCreationState with charting output. | |
148 */ | |
149 @Override | |
150 public State getCurrentState(Object cc) { | |
151 final List<Facet> fs = facets.get(getCurrentStateId()); | |
152 | |
153 AreaCreationState state = new AreaCreationState(); | |
154 | |
155 StaticState.addDefaultChartOutput(state, "cross_section", fs); | |
156 | |
157 return state; | |
158 } | |
159 | |
160 | |
161 /** | |
162 * Get a list containing the one and only State. | |
163 * @param context ignored. | |
164 * @return list with one and only state. | |
165 */ | |
166 @Override | |
167 protected List<State> getStates(Object context) { | |
168 ArrayList<State> states = new ArrayList<State>(); | |
169 states.add(getCurrentState(context)); | |
170 | |
171 return states; | |
172 } | |
173 | |
174 | |
175 /** Trivia. */ | |
176 protected State getState(Object context, String stateID) { | |
177 return getCurrentState(null); | |
178 } | |
179 } | |
180 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |