annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java @ 1710:055f32a5388a

Improved the mapfile templates to create nicer GetLegendGraphic images. flys-artifacts/trunk@2970 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 14 Oct 2011 11:13:04 +0000
parents 2b9f0ca1449b
children d26911cac2e4
rev   line source
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.List;
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
7 import org.w3c.dom.Element;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
8
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
9 import de.intevation.artifacts.Artifact;
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.CallContext;
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
12 import de.intevation.artifactdatabase.ProtocolUtils;
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import de.intevation.artifactdatabase.state.Facet;
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
15 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
16
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.artifacts.FLYSArtifact;
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
18 import de.intevation.flys.artifacts.model.CalculationResult;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
19 import de.intevation.flys.artifacts.model.FacetTypes;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
20 import de.intevation.flys.artifacts.model.WQKms;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
21 import de.intevation.flys.artifacts.resources.Resources;
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
23 import de.intevation.flys.utils.FLYSUtils;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
24 import de.intevation.flys.utils.StringUtil;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
25
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 public class WaterlevelPairSelectState
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 extends DefaultState
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 implements FacetTypes
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 /** The logger that is used in this state. */
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
32 private static Logger logger = Logger.getLogger(
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
33 WaterlevelPairSelectState.class);
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
35
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
36 // TODO fix (state.winfo.waterlevel)
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
37 // own id is state.winfo.waterlevel_pair_select
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
38 public static final String WINFO_WDIFFERENCES_STATE_ID
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
39 = "state.winfo.w_differences";
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
40
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 public WaterlevelPairSelectState() {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 /** Specify to display a datacage_twin_panel. */
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 @Override
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 protected String getUIProvider() {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 return "datacage_twin_panel";
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 @Override
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 public Object computeAdvance(
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 FLYSArtifact artifact,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 String hash,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 CallContext context,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 List<Facet> facets,
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 Object old
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 ) {
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 //Get data and do stuff, do not calculate
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
61 return old;
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
62 }
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
63
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
64
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
65
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
66 /**
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
67 * Create elements for document (prepopulated with data, if any).
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
68 */
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
69 @Override
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
70 protected Element[] createItems(
1694
2b9f0ca1449b Fix import from last commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1693
diff changeset
71 ElementCreator cr,
1693
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
72 Artifact artifact,
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
73 String name,
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
74 CallContext context)
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
75 {
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
76 logger.debug("createItems: " + name);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
77 if (name.equals("diffids")) {
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
78 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
79 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
80 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
81 FLYSArtifact flys = (FLYSArtifact) artifact;
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
82 String s = flys.getDataAsString("diffids");
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
83 value.setTextContent(s);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
84 item.appendChild(label);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
85 item.appendChild(value);
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
86 return new Element[] { item };
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
87 }
5f1156d61e9e Let WaterlevelPairSelect send "old" data.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
88 return new Element[] {};
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 }
1663
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
90
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
91
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
92 /**
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
93 * Creats the data element used for the static part of DESCRIBE document.
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
94 */
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
95 @Override
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
96 protected Element createStaticData(
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
97 ElementCreator creator,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
98 CallContext cc,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
99 String name,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
100 String value,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
101 String type
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
102 ) {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
103 Element dataElement = creator.create("data");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
104 creator.addAttr(dataElement, "name", name, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
105 creator.addAttr(dataElement, "type", type, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
106
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
107 Element itemElement = creator.create("item");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
108 creator.addAttr(itemElement, "value", value, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
109
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
110 String[] labels = getLabels(cc, value);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
111 Object[] obj = new Object[] { labels[0] };
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
112
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
113 // TODO own i18n
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
114 String attrValue = Resources.getMsg(
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
115 cc.getMeta(), "wsp.selected.string", "wsp.selected.string", obj);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
116 //I18N_STATIC_KEY, I18N_STATIC_KEY, obj);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
117
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
118 creator.addAttr(itemElement, "label", attrValue, true);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
119 dataElement.appendChild(itemElement);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
120
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
121 return dataElement;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
122 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
123
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
124
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
125 // TODO merge implementations with WaterlevelSelectState
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
126 /**
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
127 * Get name to display for selected watelerlevels (for example "Q=123")
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
128 * from the CalculationResult.
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
129 */
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
130 public static String[] getLabels(CallContext cc, String value) {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
131 String[] recommendations = value.split("#");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
132 String displayString = "";
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
133
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
134 // Walk over all selected recommendations and create label
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
135 // like "W (Q=1) - W (Q=2)".
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
136 for (int i = 0; i < recommendations.length; i+=2) {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
137 String[] minuendParts = StringUtil
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
138 .unbracket(recommendations[i+0])
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
139 .split(";");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
140 String[] subtrahendParts = StringUtil
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
141 .unbracket(recommendations[i+1])
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
142 .split(";");
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
143
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
144 FLYSArtifact artifact1 = FLYSUtils.getArtifact(minuendParts[0], cc);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
145
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
146 CalculationResult rawData1 = (CalculationResult) artifact1.compute(
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
147 cc,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
148 null,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
149 "state.winfo.waterlevel",
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
150 ComputeType.ADVANCE,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
151 false);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
152 WQKms[] wqkms1 = (WQKms[]) rawData1.getData();
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
153
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
154 int idx1 = -1;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
155 try {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
156 idx1 = Integer.parseInt(minuendParts[2]);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
157 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
158 catch (NumberFormatException nfe) { /* do nothing */ }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
159
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
160 FLYSArtifact artifact2 = FLYSUtils.getArtifact(subtrahendParts[0], cc);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
161
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
162 CalculationResult rawData2 = (CalculationResult) artifact2.compute(
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
163 cc,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
164 null,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
165 "state.winfo.waterlevel",
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
166 ComputeType.ADVANCE,
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
167 false);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
168 WQKms[] wqkms2 = (WQKms[]) rawData2.getData();
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
169
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
170 int idx2 = -1;
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
171 try {
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
172 idx2 = Integer.parseInt(subtrahendParts[2]);
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
173 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
174 catch (NumberFormatException nfe) { /* do nothing */ }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
175
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
176 displayString += "(" + StringUtil.wWrap(wqkms1[idx1].getName())
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
177 + " - " + StringUtil.wWrap(wqkms2[idx2].getName()) + ")";
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
178 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
179
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
180 return new String[] { displayString };
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
181 }
4fbd43061315 Show proper labels for selected differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1624
diff changeset
182
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 }
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org