comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java @ 4005:22abdc45869c

Calculate S(Q) fractions
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 01 Oct 2012 18:32:27 +0200
parents ab3a4ad82ae1
children f02aa4ff3c0f
comparison
equal deleted inserted replaced
4004:3b79e8afca7e 4005:22abdc45869c
6 import org.apache.log4j.Logger; 6 import org.apache.log4j.Logger;
7 7
8 public class Measurements 8 public class Measurements
9 { 9 {
10 private static final Logger log = Logger.getLogger(Measurements.class); 10 private static final Logger log = Logger.getLogger(Measurements.class);
11
12 /**
13 * Gets the accumulated for this instance.
14 *
15 * @return The accumulated.
16 */
17 public List<Measurement> getAccumulated() {
18 return this.accumulated;
19 }
20
21 /**
22 * Sets the accumulated for this instance.
23 *
24 * @param accumulated The accumulated.
25 */
26 public void setAccumulated(List<Measurement> accumulated) {
27 this.accumulated = accumulated;
28 }
29 11
30 public interface SExtractor { 12 public interface SExtractor {
31 double getS(Measurement measument); 13 double getS(Measurement measument);
32 } // interface SExtractor 14 } // interface SExtractor
33 15
85 ) { 67 ) {
86 this.measuments = measuments; 68 this.measuments = measuments;
87 this.accumulated = accumulated; 69 this.accumulated = accumulated;
88 } 70 }
89 71
90 public List<SQ> extractSQ(SExtractor extractor) { 72 public static List<SQ> extractSQ(
91 List<SQ> result = new ArrayList(measuments.size()); 73 List<Measurement> measuments,
74 SExtractor extractor
75 ) {
76 List<SQ> result = new ArrayList<SQ>(measuments.size());
92 for (Measurement measument: measuments) { 77 for (Measurement measument: measuments) {
93 SQ sq = new SQ(extractor.getS(measument), measument.Q()); 78 SQ sq = new SQ(extractor.getS(measument), measument.Q());
94 if (sq.isValid()) { 79 if (sq.isValid()) {
95 result.add(sq); 80 result.add(sq);
96 } 81 }
97 } 82 }
98 return result; 83 return result;
99 } 84 }
100 85
101 public List<SQ> S_SF() { 86 public List<SQ> S_SF() {
102 return extractSQ(S_SF_EXTRACTOR); 87 return extractSQ(measuments, S_SF_EXTRACTOR);
103 } 88 }
104 89
105 public List<SQ> S_SS() { 90 public List<SQ> S_SS() {
106 return extractSQ(S_SS_EXTRACTOR); 91 return extractSQ(measuments, S_SS_EXTRACTOR);
107 } 92 }
108 93
109 public List<SQ> S_BL_S() { 94 public List<SQ> S_BL_S() {
110 return extractSQ(S_BL_S_EXTRACTOR); 95 return extractSQ(accumulated, S_BL_S_EXTRACTOR);
111 } 96 }
112 97
113 public List<SQ> S_BL_FG() { 98 public List<SQ> S_BL_FG() {
114 return extractSQ(S_BL_FG_EXTRACTOR); 99 return extractSQ(accumulated, S_BL_FG_EXTRACTOR);
115 } 100 }
116 101
117 public List<SQ> S_BL_CG() { 102 public List<SQ> S_BL_CG() {
118 return extractSQ(S_BL_CG_EXTRACTOR); 103 return extractSQ(accumulated, S_BL_CG_EXTRACTOR);
119 } 104 }
120 105
121 public List<SQ> S_BL() { 106 public List<SQ> S_BL() {
122 return extractSQ(S_BL_EXTRACTOR); 107 return extractSQ(accumulated, S_BL_EXTRACTOR);
123 } 108 }
124 109
125 public List<SQ> getSQs(int index) { 110 public List<SQ> getSQs(int index) {
126 switch (index) { 111 switch (index) {
127 case 0: return S_SF(); 112 case 0: return S_SF();
133 } 118 }
134 log.error("THIS SHOULD NOT HAPPEN: Tried to access SQ[" + index + "]"); 119 log.error("THIS SHOULD NOT HAPPEN: Tried to access SQ[" + index + "]");
135 return new ArrayList<SQ>(0); 120 return new ArrayList<SQ>(0);
136 } 121 }
137 122
123 /**
124 * Gets the accumulated for this instance.
125 *
126 * @return The accumulated.
127 */
128 public List<Measurement> getAccumulated() {
129 return this.accumulated;
130 }
131
132 /**
133 * Sets the accumulated for this instance.
134 *
135 * @param accumulated The accumulated.
136 */
137 public void setAccumulated(List<Measurement> accumulated) {
138 this.accumulated = accumulated;
139 }
140
141
138 @Override 142 @Override
139 public String toString() { 143 public String toString() {
140 StringBuilder sb = new StringBuilder("Measurements ["); 144 StringBuilder sb = new StringBuilder("Measurements [");
141 for (int i = 0, M = measuments.size(); i < M; ++i) { 145 for (int i = 0, M = measuments.size(); i < M; ++i) {
142 if (i > 0) sb.append(", "); 146 if (i > 0) sb.append(", ");

http://dive4elements.wald.intevation.org