comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixReferenceEventsFacet.java @ 9348:a3f318347707

Show wq outliers within same thems with different symbol: not ready yet
author gernotbelger
date Tue, 31 Jul 2018 11:25:38 +0200
parents e4606eae8ea5
children ddcd52d239cd
comparison
equal deleted inserted replaced
9344:c08003a68478 9348:a3f318347707
7 */ 7 */
8 8
9 package org.dive4elements.river.artifacts.model.fixings; 9 package org.dive4elements.river.artifacts.model.fixings;
10 10
11 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
12
13 import org.dive4elements.artifacts.Artifact; 12 import org.dive4elements.artifacts.Artifact;
14 import org.dive4elements.artifacts.CallContext; 13 import org.dive4elements.artifacts.CallContext;
15 import org.dive4elements.river.artifacts.D4EArtifact; 14 import org.dive4elements.river.artifacts.D4EArtifact;
16 import org.dive4elements.river.artifacts.model.CalculationResult; 15 import org.dive4elements.river.artifacts.model.CalculationResult;
17 import org.dive4elements.river.artifacts.model.FacetTypes; 16 import org.dive4elements.river.artifacts.model.FacetTypes;
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; 17 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
19 import org.dive4elements.river.utils.KMIndex; 18 import org.dive4elements.river.utils.KMIndex;
20 19
21
22 /** 20 /**
23 * Facet to show W values for Q values at km for a date. 21 * Facet to show W values for Q values at km for a date.
24 * 22 *
25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
26 */ 24 */
27 public class FixReferenceEventsFacet 25 public class FixReferenceEventsFacet extends FixingsFacet implements FacetTypes {
28 extends FixingsFacet
29 implements FacetTypes {
30 26
31 /** House log. */ 27 /** House log. */
32 private static Logger log = Logger.getLogger(FixReferenceEventsFacet.class); 28 private static Logger log = Logger.getLogger(FixReferenceEventsFacet.class);
33 29
34 /** Trivial Constructor. */ 30 /** Trivial Constructor. */
35 public FixReferenceEventsFacet() { 31 public FixReferenceEventsFacet() {
36 } 32 }
37 33
38 34 public FixReferenceEventsFacet(final int index, final String name, final String description) {
39 /** 35 super(index, name, description, ComputeType.ADVANCE, null, null);
40 * @param name
41 */
42 public FixReferenceEventsFacet(int index, String name, String description) {
43 super(index,
44 name,
45 description,
46 ComputeType.ADVANCE,
47 null,
48 null);
49 } 36 }
50
51 37
52 /** 38 /**
53 * Returns the data this facet requires. 39 * Returns the data this facet requires.
54 * 40 *
55 * @param artifact the owner artifact. 41 * @param artifact
56 * @param context the CallContext (ignored). 42 * the owner artifact.
43 * @param context
44 * the CallContext (ignored).
57 * 45 *
58 * @return the data. 46 * @return the data.
59 */ 47 */
60 @Override 48 @Override
61 public Object getData(Artifact artifact, CallContext context) { 49 public Object getData(final Artifact artifact, final CallContext context) {
62 log.debug("FixReferenceEventsFacet.getData"); 50 log.debug("FixReferenceEventsFacet.getData");
63 51
64 if (!(artifact instanceof D4EArtifact)) { 52 if (!(artifact instanceof D4EArtifact)) {
65 log.debug("Not an instance of FixationArtifact."); 53 log.debug("Not an instance of FixationArtifact.");
66 return null; 54 return null;
67 } 55 }
68 56
69 D4EArtifact flys = (D4EArtifact)artifact; 57 final D4EArtifact flys = (D4EArtifact) artifact;
70 58
71 CalculationResult res = 59 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false);
72 (CalculationResult) flys.compute(context,
73 ComputeType.ADVANCE,
74 false);
75 60
76 FixResult result = (FixResult) res.getData(); 61 final FixResult result = (FixResult) res.getData();
77 double currentKm = getCurrentKm(context); 62 final double currentKm = getCurrentKm(context);
78 63
79 if (log.isDebugEnabled()) { 64 if (log.isDebugEnabled()) {
80 log.debug("current km in FRE: " + currentKm); 65 log.debug("current km in FRE: " + currentKm);
81 } 66 }
82 67
83 KMIndex<QWD []> kmQWs = result.getReferenced(); 68 /* first search in referenced */
84 KMIndex.Entry<QWD []> kmQWsEntry = kmQWs.binarySearch(currentKm); 69 final KMIndex<QWD[]> referenced = result.getReferenced();
85 if (kmQWsEntry != null) { 70 final QWD foundReferenced = find(referenced, currentKm);
86 int ndx = index & 255; 71 if (foundReferenced != null)
87 for (QWD qwd: kmQWsEntry.getValue()) { 72 return foundReferenced;
88 if (qwd.getIndex() == ndx) { 73
89 return qwd; 74 // FIXME
90 } 75 // /* also search in outliers, should be mutually exclusive, because outliers got removed from referenced */
91 } 76 // final KMIndex<QWD[]> outliers = result.getOutliers();
92 } 77 // final QWD foundOutlier = find(outliers, currentKm);
78 // if (foundOutlier != null)
79 // return foundOutlier;
80
93 return null; 81 return null;
94 } 82 }
95 83
84 private QWD find(final KMIndex<QWD[]> kmQWs, final double currentKm) {
85
86 final KMIndex.Entry<QWD[]> kmQWsEntry = kmQWs.binarySearch(currentKm);
87 if (kmQWsEntry != null) {
88 final int ndx = this.index & 255;
89 for (final QWD qwd : kmQWsEntry.getValue()) {
90 if (qwd.getIndex() == ndx)
91 return qwd;
92 }
93 }
94
95 return null;
96 }
96 97
97 /** 98 /**
98 * Create a deep copy of this Facet. 99 * Create a deep copy of this Facet.
100 *
99 * @return a deep copy. 101 * @return a deep copy.
100 */ 102 */
101 @Override 103 @Override
102 public FixReferenceEventsFacet deepCopy() { 104 public FixReferenceEventsFacet deepCopy() {
103 FixReferenceEventsFacet copy = new FixReferenceEventsFacet(); 105 final FixReferenceEventsFacet copy = new FixReferenceEventsFacet();
104 copy.set(this); 106 copy.set(this);
105 return copy; 107 return copy;
106 } 108 }
107 } 109 }
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org