annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java @ 4282:8b4988815974

Added marker for Ws and Qs in Historical Discharge WQ charts. Therefore, the XYChartGenerator got two new methods addDomainMarker(Marker, boolean) and addValueMarker(Marker, boolean). The boolean parameters determine, if the marker should be visible or not. This is analogous to addAxisSeries(XYSeries, int, boolean).
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 29 Oct 2012 05:59:27 +0100
parents e3c7a3228bc2
children 26774405c884
rev   line source
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model.fixings;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 import de.intevation.artifacts.Artifact;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 import de.intevation.artifacts.CallContext;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 import de.intevation.flys.artifacts.FLYSArtifact;
3203
1b9f791937c3 Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3192
diff changeset
7
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3215
diff changeset
8 import de.intevation.flys.artifacts.access.FixAnalysisAccess;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
3086
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
10 import de.intevation.flys.artifacts.math.fitting.Function;
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
11 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
12
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
13 import de.intevation.flys.artifacts.model.CalculationResult;
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
14 import de.intevation.flys.artifacts.model.DataFacet;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.artifacts.model.FacetTypes;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.artifacts.model.Parameters;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17
3086
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
18 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
3086
ba7df29264cd Removed superfluous import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3081
diff changeset
20 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
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 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 * 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
25 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 * @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
27 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 public class FixDerivateFacet
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 extends DataFacet
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 implements FacetTypes {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 /** House logger. */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 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
34
3080
dc2765e31e1f Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3067
diff changeset
35
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 /** Trivial Constructor. */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 public FixDerivateFacet() {
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 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 * @param name
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 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
45 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
46 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47
3192
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
48 public FixDerivateFacet(int index, String name, String description) {
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
49 super(index, name, description, ComputeType.ADVANCE, null, null);
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
50 }
cd309f8597f6 Fix for 'linecolor ignored' issue
Christian Lins <christian.lins@intevation.de>
parents: 3091
diff changeset
51
3043
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 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 * 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
55 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 * @param artifact the owner artifact.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 * @param context the CallContext (ignored).
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 *
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 * @return the data.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 @Override
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 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
63
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
64 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
65 if (!(artifact instanceof FLYSArtifact)) {
3043
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 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
67 return null;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 }
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
69
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
70 FLYSArtifact flys = (FLYSArtifact)artifact;
3408
50d61a2494cb FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3215
diff changeset
71 FixAnalysisAccess access = new FixAnalysisAccess(flys);
3215
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
72
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 res =
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
74 (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
75 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
76 false);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
77
3415
e3c7a3228bc2 FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3408
diff changeset
78 FixAnalysisResult result = (FixAnalysisResult) res.getData();
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 double currentKm =
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
80 ((Double)context.getContextValue("currentKm")).doubleValue();
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
81
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
82 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
83 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
84 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
85
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
86 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
87 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
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 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
90
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
91 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
92 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
93 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
94 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
95 }
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
96
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
97 de.intevation.flys.artifacts.math.Function mf =
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
98 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
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 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
101 "",
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
102 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
103 mf,
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
104 maxQ);
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
105
750e98fc8b76 FixA: Tweaked the derivate diagram a bit and added chart info.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3203
diff changeset
106 return fix;
3043
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
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 /**
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 * 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
112 * @return a deep copy.
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 */
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 @Override
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 public FixDerivateFacet deepCopy() {
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 FixDerivateFacet copy = new FixDerivateFacet();
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 copy.set(this);
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 return copy;
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 }
22da13d1b180 Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org