Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisResult.java @ 3786:4adc35aa655c
merged flys-artifacts/2.9.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:47 +0200 |
parents | 487a8cb4a222 |
children |
comparison
equal
deleted
inserted
replaced
3719:e82acd5c86f7 | 3786:4adc35aa655c |
---|---|
1 package de.intevation.flys.artifacts.model.fixings; | |
2 | |
3 import java.util.Collection; | |
4 import java.util.Date; | |
5 import java.util.TreeSet; | |
6 | |
7 import de.intevation.flys.artifacts.model.Parameters; | |
8 | |
9 import de.intevation.flys.utils.KMIndex; | |
10 | |
11 public class FixAnalysisResult | |
12 extends FixResult | |
13 { | |
14 protected KMIndex<AnalysisPeriod []> analysisPeriods; | |
15 | |
16 public FixAnalysisResult() { | |
17 } | |
18 | |
19 public FixAnalysisResult( | |
20 Parameters parameters, | |
21 KMIndex<QWD []> referenced, | |
22 KMIndex<QWI []> outliers, | |
23 KMIndex<AnalysisPeriod []> analysisPeriods | |
24 ) { | |
25 super(parameters, referenced, outliers); | |
26 this.analysisPeriods = analysisPeriods; | |
27 } | |
28 | |
29 public int getUsedSectorsInAnalysisPeriods() { | |
30 int result = 0; | |
31 for (KMIndex.Entry<AnalysisPeriod []> entry: analysisPeriods) { | |
32 for (AnalysisPeriod period: entry.getValue()) { | |
33 for (int i = 0; i < 4; ++i) { | |
34 result |= period.getQSectorAverage(i) != null | |
35 ? (1 << i) | |
36 : 0; | |
37 } | |
38 // XXX: Stop early on result == ~(~0 << 4)) ? | |
39 } | |
40 } | |
41 return result; | |
42 } | |
43 | |
44 public Collection<Date> getReferenceEventsDates() { | |
45 TreeSet<Date> dates = new TreeSet<Date>(); | |
46 for (KMIndex.Entry<QWD []> entry: referenced) { | |
47 QWD [] values = entry.getValue(); | |
48 for (int i = 0; i < values.length; i++) { | |
49 dates.add(values[i].date); | |
50 } | |
51 } | |
52 return dates; | |
53 } | |
54 | |
55 public Collection<Date> getAnalysisEventsDates(int analysisPeriod) { | |
56 TreeSet<Date> dates = new TreeSet<Date>(); | |
57 for (KMIndex.Entry<AnalysisPeriod []> entry: analysisPeriods) { | |
58 QWD [] qwds = entry.getValue()[analysisPeriod].getQWDs(); | |
59 if (qwds == null) { | |
60 continue; | |
61 } | |
62 for (int i = 0; i < qwds.length; i++) { | |
63 dates.add(qwds[i].date); | |
64 } | |
65 } | |
66 return dates; | |
67 } | |
68 | |
69 public KMIndex<AnalysisPeriod []> getAnalysisPeriods() { | |
70 return analysisPeriods; | |
71 } | |
72 | |
73 public void setAnalysisPeriods(KMIndex<AnalysisPeriod []> analysisPeriods) { | |
74 this.analysisPeriods = analysisPeriods; | |
75 } | |
76 } | |
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |