Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisEventsFacet.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/FixAnalysisEventsFacet.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 | |
8 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9 import org.dive4elements.river.artifacts.model.FacetTypes; | |
10 | |
11 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
12 | |
13 import org.dive4elements.river.utils.KMIndex; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 | |
17 /** | |
18 * Facet to show W values for Q values at km for a date. | |
19 * | |
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
21 */ | |
22 public class FixAnalysisEventsFacet | |
23 extends FixingsFacet | |
24 implements FacetTypes { | |
25 | |
26 /** House logger. */ | |
27 private static Logger logger = Logger.getLogger(FixAnalysisEventsFacet.class); | |
28 | |
29 /** Trivial Constructor. */ | |
30 public FixAnalysisEventsFacet() { | |
31 } | |
32 | |
33 | |
34 /** | |
35 * @param name | |
36 */ | |
37 public FixAnalysisEventsFacet(int index, String name, String description) { | |
38 super(index, | |
39 name, | |
40 description, | |
41 ComputeType.ADVANCE, | |
42 null, | |
43 null); | |
44 } | |
45 | |
46 | |
47 /** | |
48 * Returns the data this facet requires. | |
49 * | |
50 * @param artifact the owner artifact. | |
51 * @param context the CallContext (ignored). | |
52 * | |
53 * @return the data. | |
54 */ | |
55 @Override | |
56 public Object getData(Artifact artifact, CallContext context) { | |
57 logger.debug("FixAnalysisEventsFacet.getData"); | |
58 | |
59 if (artifact instanceof FLYSArtifact) { | |
60 FLYSArtifact flys = (FLYSArtifact)artifact; | |
61 | |
62 CalculationResult res = | |
63 (CalculationResult) flys.compute(context, | |
64 ComputeType.ADVANCE, | |
65 false); | |
66 | |
67 FixAnalysisResult result = (FixAnalysisResult) res.getData(); | |
68 double currentKm = getCurrentKm(context); | |
69 | |
70 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); | |
71 KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry = | |
72 kmPeriods.binarySearch(currentKm); | |
73 | |
74 if(kmPeriodsEntry == null) { | |
75 logger.debug("getData: kmPeriodsEntry == null"); | |
76 return null; | |
77 } | |
78 | |
79 AnalysisPeriod[] periods = kmPeriodsEntry.getValue(); | |
80 if (periods == null) { | |
81 logger.debug("getData: periods == null"); | |
82 return null; | |
83 } | |
84 int ndx = index >> 8; | |
85 QWD[] qwdData = periods[ndx].getQWDs(); | |
86 if (qwdData == null) { | |
87 return null; | |
88 } | |
89 int ndy = index & 255; | |
90 for (int i = 0; i < qwdData.length; i++) { | |
91 if (qwdData[i].getIndex() == ndy) { | |
92 return qwdData[i]; | |
93 } | |
94 } | |
95 return null; | |
96 } | |
97 else { | |
98 logger.debug("Not an instance of FixationArtifact."); | |
99 return null; | |
100 } | |
101 } | |
102 | |
103 | |
104 /** | |
105 * Create a deep copy of this Facet. | |
106 * @return a deep copy. | |
107 */ | |
108 @Override | |
109 public FixAnalysisEventsFacet deepCopy() { | |
110 FixAnalysisEventsFacet copy = new FixAnalysisEventsFacet(); | |
111 copy.set(this); | |
112 return copy; | |
113 } | |
114 } | |
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |