annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java @ 1857:7fc87a67e6f7

Added new WMSFloodplainArtifact for displaying floodplains in maps. flys-artifacts/trunk@3204 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Nov 2011 16:49:58 +0000
parents 8a2cbf947395
children 9d5f339d83a3
rev   line source
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1622
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
3 import java.io.File;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
4
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
5 import org.w3c.dom.Element;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
6
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
7 import org.apache.log4j.Logger;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
8
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
9 import de.intevation.artifacts.CallContext;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
10
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
12
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1622
diff changeset
13 import de.intevation.flys.artifacts.FLYSArtifact;
1622
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
14 import de.intevation.flys.model.DGM;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
15
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
16
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 /**
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 */
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 public class DGMSelect extends DefaultState {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
1622
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
22 private static final Logger logger = Logger.getLogger(DGMSelect.class);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
23
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
24
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 @Override
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 protected String getUIProvider() {
1172
23eb122c8ec1 Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1051
diff changeset
27 return "dgm_datacage_panel";
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 }
1622
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
29
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
30
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
31 @Override
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
32 protected Element createStaticData(
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1622
diff changeset
33 FLYSArtifact flys,
1622
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
34 ElementCreator creator,
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
35 CallContext cc,
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
36 String name,
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
37 String value,
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
38 String type
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
39 ) {
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
40 Element dataElement = creator.create("data");
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
41 creator.addAttr(dataElement, "name", name, true);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
42 creator.addAttr(dataElement, "type", type, true);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
43
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
44 Element itemElement = creator.create("item");
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
45 creator.addAttr(itemElement, "value", value, true);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
46
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
47 creator.addAttr(itemElement, "label", getLabel(cc, value), true);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
48 dataElement.appendChild(itemElement);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
49
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
50 return dataElement;
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
51 }
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
52
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
53
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
54 public static String getLabel(CallContext cc, String value) {
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
55 logger.debug("Create label for value: " + value);
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
56
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
57 try {
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
58 DGM dgm = DGM.getDGM(Integer.parseInt(value));
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
59
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
60 File file = new File(dgm.getPath());
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
61 return file.getName();
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
62 }
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
63 catch (NumberFormatException nfe) {
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
64 logger.warn("Cannot parse int value: '" + value + "'");
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
65 }
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
66
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
67 return "";
6d0299d63819 #325 Create human readable label for the selected DEM (used in the static UI part).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1172
diff changeset
68 }
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org