annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 2268:bad9a0313824

Added a second Y axis for ReferenceCurveGenerator.q flys-artifacts/trunk@3925 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 06 Feb 2012 13:59:28 +0000
parents 65b32220f197
children 5642a83420f2
rev   line source
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
3 import java.util.ArrayList;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 import java.util.List;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
8 import de.intevation.artifactdatabase.state.Facet;
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
9 import de.intevation.artifactdatabase.data.StateData;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
11 import de.intevation.artifacts.CallContext;
1184
7552ae1061d7 Fix build.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1183
diff changeset
12 import de.intevation.artifacts.Artifact;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.artifacts.FLYSArtifact;
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
14 import de.intevation.flys.artifacts.StaticWKmsArtifact;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.artifacts.WINFOArtifact;
2136
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
16 import de.intevation.flys.artifacts.ChartArtifact;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.artifacts.math.WKmsOperation;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
20 import de.intevation.flys.artifacts.model.CalculationResult;
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
21 import de.intevation.flys.artifacts.model.DataFacet;
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
22 import de.intevation.flys.artifacts.model.DifferenceCurveFacet;
2136
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
23 import de.intevation.flys.artifacts.model.EmptyFacet;
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
24
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.artifacts.model.FacetTypes;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.artifacts.model.WKms;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.artifacts.model.WQKms;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 import de.intevation.flys.utils.FLYSUtils;
1655
d251e5929860 Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1652
diff changeset
30 import de.intevation.flys.utils.StringUtil;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
1158
fbe18ad4caff Removed needless imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1153
diff changeset
32
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 public class WDifferencesState
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 extends DefaultState
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 implements FacetTypes
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 {
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 /** The logger that is used in this state. */
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 private static Logger logger = Logger.getLogger(WDifferencesState.class);
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
40
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 public WDifferencesState() {
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
45 /** Specify to display nothing (this is kind of a "final" state). */
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 @Override
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 protected String getUIProvider() {
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
48 return "noinput";
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 @Override
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
53 public boolean validate(Artifact artifact)
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
54 throws IllegalArgumentException
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
55 {
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
56 FLYSArtifact flys = (FLYSArtifact) artifact;
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
57
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
58 StateData data = flys.getData("diffids");
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
59
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
60 if (data == null) {
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
61 throw new IllegalArgumentException("diffids is empty");
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
62 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
63
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
64 // TODO: Also validate format.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
65
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
66 return true;
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
67 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
68
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
69
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
70 protected WKms getWKms(String mingle, CallContext context) {
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
71 String[] def = mingle.split(";");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
72 String uuid = def[0];
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
73 String name = def[1];
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
74 int idx = Integer.parseInt(def[2]);
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
75
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
76 if (name.startsWith("staticwkms")) {
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
77 StaticWKmsArtifact staticWKms =
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
78 (StaticWKmsArtifact) FLYSUtils.getArtifact(
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
79 uuid,
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
80 context);
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
81 logger.debug("WDifferencesState obtain data from StaticWKms");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
82 WKms wkms = staticWKms.getWKms(idx);
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
83 if (wkms == null)
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
84 logger.error("No WKms from artifact.");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
85 return wkms;
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
86 }
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
87
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
88 WINFOArtifact flys = (WINFOArtifact) FLYSUtils.getArtifact(
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
89 uuid,
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
90 context);
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
91
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
92 if (flys == null) {
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
93 logger.warn("One of the artifacts (1) for diff calculation could not be loaded");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
94 return null;
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
95 }
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
96 else{
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
97 WQKms[] wqkms = (WQKms[]) flys.getWaterlevelData().
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
98 getData();
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
99 if (wqkms == null)
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
100 logger.warn("not waterlevels in artifact");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
101 else if (wqkms.length < idx)
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
102 logger.warn("not enough waterlevels in artifact");
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
103 return wqkms[idx];
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
104 }
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
105 }
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
106
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
107
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
108 /**
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
109 * Return CalculationResult with Array of WKms that are difference of
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
110 * Waterlevels. Add respective facets (DifferencesCurveFacet, DataFacet).
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
111 */
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
112 @Override
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 public Object computeAdvance(
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 FLYSArtifact artifact,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 String hash,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116 CallContext context,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 List<Facet> facets,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 Object old
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 ) {
2136
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
120 if (artifact instanceof ChartArtifact) {
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
121 ChartArtifact chart = (ChartArtifact)artifact;
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
122 facets.add(new EmptyFacet());
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
123 return null;
3a5ef4ac8e0f 'New Chart' for w-differences curve.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1886
diff changeset
124 }
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
125 WINFOArtifact winfo = (WINFOArtifact) artifact;
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
126 String id = getID();
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
127
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
128 // Load the Artifacts/facets that we want to subtract and display.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
129 // Expected format is:
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
130 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....]
1661
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
131 String diffids = winfo.getDataAsString("diffids");
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
132 logger.debug("WDifferencesState has: " + diffids);
1661
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
133 String datas[] = diffids.split("#");
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
134
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
135 // Validate the Data-Strings.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
136 for (String s: datas) {
1184
7552ae1061d7 Fix build.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1183
diff changeset
137 if (!WaterlevelSelectState.isValueValid(winfo.getDataAsString("diffids"))) {
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
138 // TODO: escalate.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
139 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
140 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
141
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
142 if (datas.length < 2) {
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
143 // TODO crash with style
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
144 }
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
146 List<WKms> wkmss = new ArrayList<WKms>();
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147
1661
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
148 for(int i = 0; i < datas.length; i+=2) {
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
149 // e.g.:
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
150 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
151 WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]),
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
152 context);
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
153 WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]),
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
154 context);
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
155
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
156 String facetName = "diff ()";
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
157
1732
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
158 if (minuendWKms != null && subtrahendWKms != null) {
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
159 facetName = StringUtil.wWrap(minuendWKms.getName())
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
160 + " - " + StringUtil.wWrap(subtrahendWKms.getName());
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
161 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms,
1a57027286ce Handle StaticWKmsArtifacts in WDifferencesState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1696
diff changeset
162 subtrahendWKms);
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
163 wkms.setName(facetName);
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
164 wkmss.add(wkms);
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
165 logger.debug("WKMSSubtraction happened");
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
166 }
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
167 if (facets != null) {
1696
56953439dcae Fixed incorrect indexing of facets when doing multiple (w)differences.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1670
diff changeset
168 facets.add(new DifferenceCurveFacet(i/2, W_DIFFERENCES, facetName,
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
169 ComputeType.ADVANCE, id, hash));
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
170 }
2180
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
171 }
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
172
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
173 if (facets != null) {
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
174 facets.add(new DataFacet(CSV, "CSV data"));
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
175 facets.add(new DataFacet(PDF, "PDF data"));
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
176 logger.debug("Adding facets in WDifferencesState.");
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
177 }
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
178 else {
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2136
diff changeset
179 logger.debug("Not adding facets in WDifferencesState.");
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
180 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
181
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
182 // TODO Evaluate whether null is okay as reports.
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
183 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]);
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
184 CalculationResult result = new CalculationResult(diffs, null);
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
185 return result;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org