annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 1661:a890bf077de5

Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics. flys-artifacts/trunk@2860 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 28 Sep 2011 15:47:57 +0000
parents d251e5929860
children fc9719cddbc6
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;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.artifacts.WINFOArtifact;
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 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
17
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
18 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
19 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
20 import de.intevation.flys.artifacts.model.DifferenceCurveFacet;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.artifacts.model.FacetTypes;
1643
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.WaterlevelFacet;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 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
24 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
25
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.utils.FLYSUtils;
1655
d251e5929860 Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1652
diff changeset
27 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
28
1158
fbe18ad4caff Removed needless imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1153
diff changeset
29
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 public class WDifferencesState
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 extends DefaultState
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 implements FacetTypes
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 {
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 /** 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
35 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
36
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
37
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 public WDifferencesState() {
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
1173
2490d6ef394e Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1161
diff changeset
42 /** 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
43 @Override
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 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
45 return "noinput";
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 @Override
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
50 public boolean validate(Artifact artifact)
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
51 throws IllegalArgumentException
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
52 {
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
53 FLYSArtifact flys = (FLYSArtifact) artifact;
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
54
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
55 StateData data = flys.getData("diffids");
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
56
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
57 if (data == null) {
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
58 throw new IllegalArgumentException("diffids is empty");
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
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
61 // TODO: Also validate format.
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 return true;
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
64 }
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
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
67 /**
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
68 * 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
69 * 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
70 */
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
71 @Override
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 public Object computeAdvance(
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 FLYSArtifact artifact,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 String hash,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 CallContext context,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 List<Facet> facets,
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 Object old
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 ) {
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 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
80 String id = getID();
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
82 // 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
83 // Expected format is:
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
84 // [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
85 String diffids = winfo.getDataAsString("diffids");
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
86 String datas[] = diffids.split("#");
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
87
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
88 // Validate the Data-Strings.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
89 for (String s: datas) {
1184
7552ae1061d7 Fix build.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1183
diff changeset
90 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
91 // TODO: escalate.
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
92 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
93 }
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
94
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
95 if (datas.length < 2) {
1183
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
96 // TODO crash with style
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
97 ;
9c1cda9e2bc4 Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1173
diff changeset
98 }
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
100 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
101
1661
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
102 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
103 // e.g.:
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
104 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
1655
d251e5929860 Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1652
diff changeset
105 String[] def1 = StringUtil.unbracket(datas[i+0]).split(";");
d251e5929860 Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1652
diff changeset
106 String[] def2 = StringUtil.unbracket(datas[i+1]).split(";");
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
107 String uuid1 = def1[0];
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
108 String uuid2 = def2[0];
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
109 int idx1 = Integer.parseInt(def1[2]);
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
110 int idx2 = Integer.parseInt(def2[2]);
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
111
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
112 WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact(
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
113 uuid1,
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
114 context);
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
115 WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact(
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
116 uuid2,
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
117 context);
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
118
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
119 if (flys1 == null) {
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
120 logger.warn("One of the artifacts (1) for diff calculation could not be loaded");
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
121 }
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
122 if (flys2 == null) {
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
123 logger.warn("One of the artifacts (2) for diff calculation could not be loaded");
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
124 }
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
125 // TODO: Issue of multiple results in calculation
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
126 String facetName = "diff ()";
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
127
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
128 if (flys1 != null && flys2 != null) {
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
129 WQKms[] minuend = (WQKms[]) flys1.getWaterlevelData().
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
130 getData();
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
131 WQKms[] subtrahend = (WQKms[]) flys2.getWaterlevelData().
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
132 getData();
1626
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
133
1661
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
134 facetName = StringUtil.wWrap(minuend[idx1].getName())
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
135 + " - " + StringUtil.wWrap(subtrahend[idx2].getName());
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
136 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[idx1],
a890bf077de5 Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1655
diff changeset
137 subtrahend[idx2]);
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
138 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
139 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
140 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
141 }
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
142
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
143 if (facets != null) {
1643
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
144 facets.add(new DifferenceCurveFacet(i, W_DIFFERENCES, facetName,
ff7bffb7d5f0 Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1626
diff changeset
145 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
146 facets.add(new DataFacet(CSV, "CSV data"));
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
147 }
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
148 else {
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
149 logger.debug("Not adding facets in WDifferencesState.");
b9b47af71564 Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1187
diff changeset
150 }
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152
1652
46a2a5dc98b7 In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1643
diff changeset
153 // 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
154 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
155 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
156 return result;
1151
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 }
08048bd090e6 Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org