annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java @ 3570:9eba1e2d821d

Set info attribute in datacage, to have tooltips in gui. flys-artifacts/trunk@5170 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 08 Aug 2012 08:13:24 +0000
parents cd5eb8f5f6f1
children cce12c06466f
rev   line source
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.List;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 import java.awt.geom.Point2D;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.Artifact;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.CallContext;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.DataProvider;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.artifacts.StaticWKmsArtifact;
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
13 import de.intevation.flys.artifacts.math.Linear;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 /**
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
16 * Facet to access a point.
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 public class RelativePointFacet
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 extends BlackboardDataFacet
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 implements FacetTypes {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21
2999
703be13ffa74 Cosmetics and ommitted fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2760
diff changeset
22 /** Own logger. */
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 private static Logger logger = Logger.getLogger(RelativePointFacet.class);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 /** Trivial Constructor. */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 public RelativePointFacet(String description) {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 this(RELATIVE_POINT, description);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
30
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 public RelativePointFacet(String name, String description) {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 this.name = name;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 this.description = description;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 this.index = 0;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
38 protected Point2D calculateDurationCurvePoint(CallContext context,
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
39 StaticWKmsArtifact artifact)
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
40 {
2760
23b4ff116015 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2758
diff changeset
41 // TODO here and in reference curve calc: Do warn if more than 1
23b4ff116015 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2758
diff changeset
42 // provider found or (way better) handle it.
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
43 Object wqdays = null;
3442
cd5eb8f5f6f1 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
44 double km = 0d;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 List<DataProvider> providers = context.
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
46 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 if (providers.size() < 1) {
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
48 logger.warn("Could not find durationcurve data provider.");
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 else {
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
51 wqdays = providers.get(0).provideData(
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
52 DurationCurveFacet.BB_DURATIONCURVE,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
53 null,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
54 context);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 }
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
56 List<DataProvider> kmproviders = context.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
57 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
58 if (kmproviders.size() < 1) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
59 logger.warn("Could not find durationcurve.km data provider.");
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
60 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
61 else {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
62 logger.debug("Found durationcurve.km data provider.");
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
63 String dckm = providers.get(0).provideData(
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
64 DurationCurveFacet.BB_DURATIONCURVE_KM,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
65 null,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
66 context).toString();
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
67 km = Double.valueOf(dckm);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
68 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
69
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
70 if (wqdays != null) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
71 // Which W at this km?
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
72 double w = artifact.getWAtKmLin(artifact.getWKms(0), km);
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
73 if (w == -1) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
74 logger.warn("w is -1, already bad sign!");
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
75 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
76 // Where is this W passed by in the wq-curve?
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
77 WQDay wqday = (WQDay) wqdays;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
78 // Doing a linear Day Of KM.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
79 int idx = 0;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
80 boolean wIncreases = wqday.getW(0) < wqday.getW(wqday.size()-1);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
81 if (wIncreases) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
82 while (idx < wqday.size() && wqday.getW(idx) < w) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
83 idx++;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
84 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
85 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
86 else {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
87 idx = wqday.size() -1;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
88 while (idx > 0 && wqday.getW(idx) > w) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
89 idx--;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
90 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
91 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
92
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
93 double day = 0d;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
94 int mod = (wIncreases) ? -1 : +1;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
95 if (idx != 0 && idx <= wqday.size()-1) {
3442
cd5eb8f5f6f1 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
96 day = Linear.linear(w, wqday.getW(idx+mod), wqday.getW(idx),
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
97 wqday.getDay(idx+mod), wqday.getDay(idx));
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
98 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
99
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
100 return new Point2D.Double((double) day, w);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
101 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
102 logger.warn("not wqkms / w / day found");
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
103 // TODO better signal failure.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
104 return new Point2D.Double(0d, 0d);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
105 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
106
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
107
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
108 /**
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
109 * Calculate a reference curve point, that is, a point made of
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
110 * the Ws from start and end km param of the reference curve.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
111 */
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
112 public Point2D calculateReferenceCurvePoint(CallContext context,
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
113 StaticWKmsArtifact artifact) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
114 List<DataProvider> providers = context.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
115 getDataProvider(ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
116 if (providers.size() < 1) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
117 logger.warn("Could not find reference curve startkm data provider.");
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
118 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
119
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
120 Double start = (Double) providers.get(0).
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
121 provideData(ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM, null, context);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
122
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
123 providers = context.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
124 getDataProvider(ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
125 if (providers.size() < 1) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
126 logger.warn("Could not find reference curve endkms data provider.");
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
127 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
128 double[] ends = (double[]) providers.get(0).
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
129 provideData(ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS, null, context);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
130
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
131 logger.debug("Got s " + start + " e " + ends);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
132 double startW = artifact.getWAtKmLin(artifact.getWKms(0), start.doubleValue());
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
133 // TODO handle multiple ends.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
134 double endW = artifact.getWAtKmLin(artifact.getWKms(0), ends[0]);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
135 logger.debug("Gotw s " + startW + " e " + endW);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
136 return new Point2D.Double(startW, endW);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
137 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
138
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
139
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
140 /**
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
141 * Returns the data this facet requires.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
142 *
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
143 * @param artifact the owner artifact.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
144 * @param context the CallContext (ignored).
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
145 *
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
146 * @return the data.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
147 */
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
148 @Override
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
149 public Object getData(Artifact artifact, CallContext context) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
150 StaticWKmsArtifact staticData = (StaticWKmsArtifact) artifact;
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
151 // Find out whether we live in a duration curve context, there we would
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
152 // provide only a single point.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
153
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
154 if (context.getDataProvider(
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
155 DurationCurveFacet.BB_DURATIONCURVE_KM).size() > 0) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
156 return calculateDurationCurvePoint(context, staticData);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
157 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
158 else if (context.getDataProvider(
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
159 ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM).size() > 0) {
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
160 return calculateReferenceCurvePoint(context, staticData);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
161 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
162
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
163 // TODO better signal failure.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
164 return new Point2D.Double(0d, 0d);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 /**
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169 * Create a deep copy of this Facet.
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 * @return a deep copy.
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172 @Override
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173 public RelativePointFacet deepCopy() {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174 RelativePointFacet copy = new RelativePointFacet(description);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 copy.set(this);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176 return copy;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org