comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixDeviationFacet.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/FixDeviationFacet.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.model.fixings;
2
3 import org.dive4elements.artifacts.Artifact;
4 import org.dive4elements.artifacts.CallContext;
5
6 import org.dive4elements.river.artifacts.FLYSArtifact;
7 import org.dive4elements.river.artifacts.access.FixAnalysisAccess;
8
9 import org.dive4elements.river.artifacts.model.CalculationResult;
10 import org.dive4elements.river.artifacts.model.FacetTypes;
11 import org.dive4elements.river.artifacts.model.Parameters;
12
13 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
14
15 import org.apache.log4j.Logger;
16
17
18 /**
19 * Facet to show the W|Q values.
20 *
21 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
22 */
23 public class FixDeviationFacet
24 extends FixingsFacet
25 implements FacetTypes {
26
27 /** House logger. */
28 private static Logger logger = Logger.getLogger(FixDeviationFacet.class);
29
30 public static final String [] STD_DEV_COLUMN = { "std-dev" };
31
32 /** Trivial Constructor. */
33 public FixDeviationFacet() {
34 }
35
36
37 /**
38 * @param name
39 */
40 public FixDeviationFacet(String name, String description) {
41 super(0, name, description, ComputeType.ADVANCE, null, null);
42 }
43
44 public FixDeviationFacet(int index, String name, String description) {
45 super(index, name, description, ComputeType.ADVANCE, null, null);
46 }
47
48
49 /**
50 * Returns the data this facet requires.
51 *
52 * @param artifact the owner artifact.
53 * @param context the CallContext (ignored).
54 *
55 * @return the data.
56 */
57 @Override
58 public Object getData(Artifact artifact, CallContext context) {
59 logger.debug("FixDeviationFacet.getData");
60 if (artifact instanceof FLYSArtifact) {
61 FLYSArtifact flys = (FLYSArtifact)artifact;
62 FixAnalysisAccess access = new FixAnalysisAccess(flys, context);
63
64 CalculationResult res =
65 (CalculationResult) flys.compute(context,
66 ComputeType.ADVANCE,
67 false);
68
69 FixAnalysisResult result = (FixAnalysisResult) res.getData();
70 double currentKm = getCurrentKm(context);
71
72 Parameters params = result.getParameters();
73
74 double[] stdDev =
75 params.interpolate("km", currentKm, STD_DEV_COLUMN);
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 :

http://dive4elements.wald.intevation.org