Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 1723:690037105542
Added new Artifact and Facet to access 'static' data via WKmsFactory.
flys-artifacts/trunk@3005 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 18 Oct 2011 12:56:12 +0000 |
parents | 56953439dcae |
children | 1a57027286ce |
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; |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 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
|
23 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
|
24 |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.utils.FLYSUtils; |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1652
diff
changeset
|
26 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
|
27 |
1158
fbe18ad4caff
Removed needless imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1153
diff
changeset
|
28 |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 public class WDifferencesState |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 extends DefaultState |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 implements FacetTypes |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 { |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 /** 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
|
34 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
|
35 |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
36 |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 public WDifferencesState() { |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 } |
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 |
1173
2490d6ef394e
Extended WDifferences bracnh of WINFO to have calculation in dedicated,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1161
diff
changeset
|
41 /** 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
|
42 @Override |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 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
|
44 return "noinput"; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 } |
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 @Override |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
49 public boolean validate(Artifact artifact) |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
50 throws IllegalArgumentException |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
51 { |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
52 FLYSArtifact flys = (FLYSArtifact) artifact; |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
53 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
54 StateData data = flys.getData("diffids"); |
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 if (data == null) { |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
57 throw new IllegalArgumentException("diffids is empty"); |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
58 } |
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 // TODO: Also validate format. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
61 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
62 return true; |
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 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
65 |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
66 /** |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
67 * 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
|
68 * 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
|
69 */ |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
70 @Override |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 public Object computeAdvance( |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 FLYSArtifact artifact, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 String hash, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 CallContext context, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 List<Facet> facets, |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 Object old |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 ) { |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 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
|
79 String id = getID(); |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
81 // 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
|
82 // Expected format is: |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
83 // [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
|
84 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
|
85 String datas[] = diffids.split("#"); |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
86 |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
87 // Validate the Data-Strings. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
88 for (String s: datas) { |
1184
7552ae1061d7
Fix build.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1183
diff
changeset
|
89 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
|
90 // TODO: escalate. |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
91 } |
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 |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
94 if (datas.length < 2) { |
1183
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
95 // TODO crash with style |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
96 ; |
9c1cda9e2bc4
Load given artifacts for w-diff calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1173
diff
changeset
|
97 } |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 |
1643
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
99 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
|
100 |
1661
a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1655
diff
changeset
|
101 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
|
102 // e.g.: |
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
103 // 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
|
104 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
|
105 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
|
106 String uuid1 = def1[0]; |
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
107 String uuid2 = def2[0]; |
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
108 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
|
109 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
|
110 |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
111 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
|
112 uuid1, |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
113 context); |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
114 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
|
115 uuid2, |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
116 context); |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
117 |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
118 if (flys1 == null) { |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
119 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
|
120 } |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
121 if (flys2 == null) { |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
122 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
|
123 } |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
124 // 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
|
125 String facetName = "diff ()"; |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
126 |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
127 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
|
128 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
|
129 getData(); |
ff7bffb7d5f0
Let WDifferences-diagram show more than one difference, if asked to.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1626
diff
changeset
|
130 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
|
131 getData(); |
1626
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
132 |
1661
a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1655
diff
changeset
|
133 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
|
134 + " - " + 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 } |
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 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
|
143 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
|
144 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
|
145 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
|
146 } |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
147 else { |
b9b47af71564
Preparations for ability to display multiple differences in one plot.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
148 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
|
149 } |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 } |
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 |
1652
46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1643
diff
changeset
|
152 // 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
|
153 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
|
154 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
|
155 return result; |
1151
08048bd090e6
Added very stubby WDifferences State/OutGenerator for WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |