comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQOutlierFacet.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQOutlierFacet.java@1df6984628c3
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.artifacts.model.sq;
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.DataFacet;
10 import org.dive4elements.river.artifacts.model.FacetTypes;
11
12 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
13
14 import org.apache.log4j.Logger;
15
16 /**
17 * Facet to show the curve in a sq relation.
18 *
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
20 */
21 public class SQOutlierFacet extends DataFacet implements FacetTypes {
22
23 private static final Logger log = Logger.getLogger(SQOutlierFacet.class);
24
25 public static final int BITMASK_ITERATION = (1 << 16) - 1;
26
27 private int fractionIdx;
28
29 public SQOutlierFacet() {
30 }
31
32 public SQOutlierFacet(
33 int idx,
34 int fractionIdx,
35 String name,
36 String description,
37 String hash,
38 String stateId
39 ) {
40 super(idx, name, description, ComputeType.ADVANCE, hash, stateId);
41 this.fractionIdx = fractionIdx;
42 }
43
44
45 @Override
46 public Object getData(Artifact artifact, CallContext context) {
47 log.debug("SQOutlierFacet.getData");
48
49 if (!(artifact instanceof FLYSArtifact)) {
50 return null;
51 }
52
53 FLYSArtifact flys = (FLYSArtifact) artifact;
54
55 CalculationResult res = (CalculationResult) flys.compute(
56 context, ComputeType.ADVANCE, false);
57
58 int idx = this.index >> 16;
59 int iter = this.index & BITMASK_ITERATION;
60
61 boolean debug = log.isDebugEnabled();
62
63 if (debug) {
64 log.debug("Fetch data for index : " + this.index);
65 log.debug(" > index: " + idx);
66 log.debug(" > fraction: " + fractionIdx);
67 log.debug(" > iteration: " + iter);
68 }
69
70 SQResult[] result = (SQResult[]) res.getData();
71 SQFractionResult fResult = result[idx].getFraction(fractionIdx);
72
73 if (fResult == null) {
74 log.warn("No SQFractionResult at " + idx + "|" + fractionIdx);
75 return null;
76 }
77
78 SQ [] outliers = fResult.getOutliers(iter);
79
80 if (debug) {
81 int num = outliers != null ? outliers.length : 0;
82 log.debug("Found " + num + " outliers for iteration " + iter);
83 }
84
85 return outliers;
86 }
87
88
89 @Override
90 public SQOutlierFacet deepCopy() {
91 SQOutlierFacet copy = new SQOutlierFacet();
92 copy.set(this);
93
94 return copy;
95 }
96 }
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org