Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDeviationFacet.java @ 3131:bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
flys-artifacts/trunk@4732 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jun 2012 16:10:59 +0000 |
parents | |
children | 5888c4685701 |
comparison
equal
deleted
inserted
replaced
3130:0dd569e9b9f1 | 3131:bac0b2721451 |
---|---|
1 package de.intevation.flys.artifacts.model.fixings; | |
2 | |
3 import de.intevation.artifacts.Artifact; | |
4 import de.intevation.artifacts.CallContext; | |
5 | |
6 import de.intevation.flys.artifacts.FLYSArtifact; | |
7 import de.intevation.flys.artifacts.FixationArtifactAccess; | |
8 | |
9 import de.intevation.flys.artifacts.math.fitting.Function; | |
10 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; | |
11 | |
12 import de.intevation.flys.artifacts.model.CalculationResult; | |
13 import de.intevation.flys.artifacts.model.DataFacet; | |
14 import de.intevation.flys.artifacts.model.FacetTypes; | |
15 import de.intevation.flys.artifacts.model.Parameters; | |
16 | |
17 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
18 | |
19 import org.apache.log4j.Logger; | |
20 | |
21 | |
22 /** | |
23 * Facet to show the W|Q values. | |
24 * | |
25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
26 */ | |
27 public class FixDeviationFacet | |
28 extends DataFacet | |
29 implements FacetTypes { | |
30 | |
31 /** House logger. */ | |
32 private static Logger logger = Logger.getLogger(FixDeviationFacet.class); | |
33 | |
34 | |
35 /** Trivial Constructor. */ | |
36 public FixDeviationFacet() { | |
37 } | |
38 | |
39 | |
40 /** | |
41 * @param name | |
42 */ | |
43 public FixDeviationFacet(String name, String description) { | |
44 super(0, name, description, ComputeType.ADVANCE, null, null); | |
45 } | |
46 | |
47 | |
48 /** | |
49 * Returns the data this facet requires. | |
50 * | |
51 * @param artifact the owner artifact. | |
52 * @param context the CallContext (ignored). | |
53 * | |
54 * @return the data. | |
55 */ | |
56 @Override | |
57 public Object getData(Artifact artifact, CallContext context) { | |
58 logger.debug("FixDeviationFacet.getData"); | |
59 if (artifact instanceof FLYSArtifact) { | |
60 FLYSArtifact flys = (FLYSArtifact)artifact; | |
61 FixationArtifactAccess access = new FixationArtifactAccess(flys); | |
62 | |
63 CalculationResult res = | |
64 (CalculationResult) flys.compute(context, | |
65 ComputeType.ADVANCE, | |
66 false); | |
67 | |
68 FixResult result = (FixResult) res.getData(); | |
69 double currentKm = | |
70 ((Double)context.getContextValue("currentKm")).doubleValue(); | |
71 | |
72 Parameters params = result.getParameters(); | |
73 | |
74 double[] stdDev = | |
75 params.interpolate("km", currentKm, new String[] {"std-dev"}); | |
76 | |
77 if(stdDev == null) { | |
78 logger.warn("getData: stdDev == null at km " + currentKm); | |
79 return null; | |
80 } | |
81 | |
82 return stdDev; | |
83 } | |
84 else { | |
85 logger.debug("Not an instance of FixationArtifact."); | |
86 return null; | |
87 } | |
88 } | |
89 | |
90 | |
91 /** | |
92 * Create a deep copy of this Facet. | |
93 * @return a deep copy. | |
94 */ | |
95 @Override | |
96 public FixDerivateFacet deepCopy() { | |
97 FixDerivateFacet copy = new FixDerivateFacet(); | |
98 copy.set(this); | |
99 return copy; | |
100 } | |
101 } | |
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |