annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixDerivateFacet.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixDerivateFacet.java@bd047b71ab37
children 4897a58c8746
rev   line source
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
1 package org.dive4elements.river.artifacts.model.fixings;
3203
1b9f791937c3 Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3192
diff changeset
2
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
3 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
4 import org.dive4elements.artifacts.CallContext;
3086
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
5
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
6 import org.dive4elements.river.artifacts.FLYSArtifact;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
8 import org.dive4elements.river.artifacts.access.FixAnalysisAccess;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
9
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
10 import org.dive4elements.river.artifacts.math.fitting.Function;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
11 import org.dive4elements.river.artifacts.math.fitting.FunctionFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
12
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
13 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
14 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
15 import org.dive4elements.river.artifacts.model.Parameters;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
16
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
17 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
3086
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
19 import org.apache.log4j.Logger;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 * Facet to show the W|Q values.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 public class FixDerivateFacet
4442
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3415
diff changeset
28 extends FixingsFacet
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 implements FacetTypes {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 /** House logger. */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 private static Logger logger = Logger.getLogger(FixDerivateFacet.class);
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
3080
dc2765e31e1f Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3067
diff changeset
34
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 /** Trivial Constructor. */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 public FixDerivateFacet() {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 * @param name
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 public FixDerivateFacet(String name, String description) {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 super(0, name, description, ComputeType.ADVANCE, null, null);
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
3192
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
47 public FixDerivateFacet(int index, String name, String description) {
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
48 super(index, name, description, ComputeType.ADVANCE, null, null);
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
49 }
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
50
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 * Returns the data this facet requires.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 * @param artifact the owner artifact.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 * @param context the CallContext (ignored).
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 * @return the data.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 @Override
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 public Object getData(Artifact artifact, CallContext context) {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
63 logger.debug("FixDerivateFacet.getData");
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
64 if (!(artifact instanceof FLYSArtifact)) {
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 logger.debug("Not an instance of FixationArtifact.");
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 return null;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 }
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
68
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
69 FLYSArtifact flys = (FLYSArtifact)artifact;
4866
acfd48384835 Changed data field names in fix analsis to ld_from, ld_to, ld step.
Raimund Renkert <rrenkert@intevation.de>
parents: 4442
diff changeset
70 FixAnalysisAccess access = new FixAnalysisAccess(flys, context);
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
71
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
72 CalculationResult res =
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
73 (CalculationResult) flys.compute(context,
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
74 ComputeType.ADVANCE,
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
75 false);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
76
3415
e3c7a3228bc2 FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
77 FixAnalysisResult result = (FixAnalysisResult) res.getData();
4442
26774405c884 Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3415
diff changeset
78 double currentKm = getCurrentKm(context);
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
79
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
80 String function = access.getFunction();
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
81 Function ff = FunctionFactory.getInstance().getFunction(function);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
82 Function.Derivative fd = ff.getDerivative();
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
83
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
84 Parameters params = result.getParameters();
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
85 double maxQ = FixFacetUtils.getMaxQ(params, currentKm);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
86
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
87 String[] paramNames = ff.getParameterNames();
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
88
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
89 double[] coeffs = params.interpolate("km", currentKm, paramNames);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
90 if (coeffs == null) {
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
91 logger.warn("getData: coeffs == null");
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
92 return null;
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
93 }
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
94
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4866
diff changeset
95 org.dive4elements.river.artifacts.math.Function mf =
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
96 fd.instantiate(coeffs);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
97
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
98 FixFunction fix = new FixFunction(
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
99 "",
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
100 fd.getDescription(),
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
101 mf,
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
102 maxQ);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
103
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
104 return fix;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 * Create a deep copy of this Facet.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 * @return a deep copy.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 @Override
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 public FixDerivateFacet deepCopy() {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 FixDerivateFacet copy = new FixDerivateFacet();
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 copy.set(this);
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 return copy;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org