comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelGroundDifferences.java @ 927:53a2be494765

Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps. flys-artifacts/trunk@2281 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 05 Jul 2011 15:34:54 +0000
parents
children e7664917dbdf
comparison
equal deleted inserted replaced
926:659608128823 927:53a2be494765
1 package de.intevation.flys.artifacts.states;
2
3 import org.w3c.dom.Element;
4
5 import org.apache.log4j.Logger;
6
7 import de.intevation.artifacts.Artifact;
8 import de.intevation.artifacts.CallContext;
9
10 import de.intevation.artifacts.common.utils.XMLUtils;
11
12 import de.intevation.artifactdatabase.ProtocolUtils;
13
14
15 /**
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
17 */
18 public class WaterlevelGroundDifferences extends RangeState {
19
20 public static final String LOWER_FIELD = "diff_from";
21 public static final String UPPER_FIELD = "diff_to";
22 public static final String DIFF_FIELD = "diff_diff";
23
24 public static final double DEFAULT_STEP = 0d;
25
26
27 private static Logger logger =
28 Logger.getLogger(WaterlevelGroundDifferences.class);
29
30
31
32 @Override
33 protected String getLowerField() {
34 return LOWER_FIELD;
35 }
36
37
38 @Override
39 protected String getUpperField() {
40 return UPPER_FIELD;
41 }
42
43
44 @Override
45 protected String getStepField() {
46 return DIFF_FIELD;
47 }
48
49
50 @Override
51 protected double[] getMinMax(Artifact artifact) {
52 return new double[] { -Double.MAX_VALUE, Double.MAX_VALUE };
53 }
54
55
56 @Override
57 protected String getUIProvider() {
58 return "distance_panel";
59 }
60
61
62 protected double getDefaultStep() {
63 return DEFAULT_STEP;
64 }
65
66
67 @Override
68 protected Element[] createItems(
69 XMLUtils.ElementCreator cr,
70 Artifact artifact,
71 String name,
72 CallContext context)
73 {
74 double[] minmax = getMinMax(artifact);
75
76 double minVal = Double.MIN_VALUE;
77 double maxVal = Double.MAX_VALUE;
78
79 if (minmax != null) {
80 minVal = minmax[0];
81 maxVal = minmax[1];
82 }
83 else {
84 logger.warn("Could not read min/max distance values!");
85 }
86
87 if (name.equals(LOWER_FIELD)) {
88 Element min = createItem(
89 cr,
90 new String[] {"min", new Double(minVal).toString()});
91
92 return new Element[] { min };
93 }
94 else if (name.equals(UPPER_FIELD)) {
95 Element max = createItem(
96 cr,
97 new String[] {"max", new Double(maxVal).toString()});
98
99 return new Element[] { max };
100 }
101 else {
102 Element step = createItem(
103 cr,
104 new String[] {"step", String.valueOf(getDefaultStep())});
105 return new Element[] { step };
106 }
107 }
108
109
110 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
111 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
112 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
113 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
114
115 String[] arr = (String[]) obj;
116
117 label.setTextContent(arr[0]);
118 value.setTextContent(arr[1]);
119
120 item.appendChild(label);
121 item.appendChild(value);
122
123 return item;
124 }
125 }
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org