Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSData.java @ 8024:963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 09 Jul 2014 17:33:57 +0200 |
parents | |
children | a1ceacf15d3a |
comparison
equal
deleted
inserted
replaced
8023:f7f86f4e4c8d | 8024:963ede7b32bb |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.model.minfo; | |
10 | |
11 import java.util.Date; | |
12 import java.util.Map; | |
13 import java.util.Set; | |
14 import java.util.TreeMap; | |
15 | |
16 import org.dive4elements.river.artifacts.model.NamedObjectImpl; | |
17 import org.dive4elements.river.artifacts.model.Range; | |
18 import org.dive4elements.river.utils.EpsilonComparator; | |
19 | |
20 import org.apache.log4j.Logger; | |
21 | |
22 | |
23 /** Gives access to Fractions (at kms). */ | |
24 public class SedimentLoadLSData | |
25 extends NamedObjectImpl | |
26 { | |
27 /** Private logger. */ | |
28 private static final Logger logger = Logger | |
29 .getLogger(SedimentLoadLSData.class); | |
30 | |
31 protected String description; | |
32 protected Date start; | |
33 protected Date end; | |
34 protected boolean isEpoch; | |
35 protected String unit; | |
36 | |
37 protected Map<Double, SedimentLoadFraction> kms; | |
38 | |
39 public SedimentLoadLSData() { | |
40 kms = new TreeMap<Double, SedimentLoadFraction>(EpsilonComparator.CMP); | |
41 } | |
42 | |
43 public SedimentLoadLSData( | |
44 String description, | |
45 Date start, | |
46 Date end, | |
47 boolean isEpoch, | |
48 String unit | |
49 ) { | |
50 this(); | |
51 this.description = description; | |
52 this.start = start; | |
53 this.end = end; | |
54 this.isEpoch = isEpoch; | |
55 this.unit = unit; | |
56 } | |
57 | |
58 public String getDescription() { | |
59 return description; | |
60 } | |
61 | |
62 public void setDescription(String description) { | |
63 this.description = description; | |
64 } | |
65 | |
66 public Date getStart() { | |
67 return start; | |
68 } | |
69 | |
70 public void setStart(Date start) { | |
71 this.start = start; | |
72 } | |
73 | |
74 public Date getEnd() { | |
75 return end; | |
76 } | |
77 | |
78 public void setEnd(Date end) { | |
79 this.end = end; | |
80 } | |
81 | |
82 public boolean isEpoch() { | |
83 return isEpoch; | |
84 } | |
85 | |
86 public void setEpoch(boolean isEpoch) { | |
87 this.isEpoch = isEpoch; | |
88 } | |
89 | |
90 public Set<Double> getKms() { | |
91 return kms.keySet(); | |
92 } | |
93 | |
94 public void addKm(double km, SedimentLoadFraction fraction) { | |
95 kms.put(km, fraction); | |
96 } | |
97 | |
98 public SedimentLoadFraction getFraction(double km) { | |
99 SedimentLoadFraction f = kms.get(km); | |
100 if (f == null) { | |
101 f = new SedimentLoadFraction(); | |
102 kms.put(km, f); | |
103 } | |
104 return f; | |
105 } | |
106 | |
107 public void setCoarse(double km, double coarse, Range range) { | |
108 if (range == null) { | |
109 logger.error("coarse/range is null!"); | |
110 return; | |
111 } | |
112 SedimentLoadFraction f = getFraction(km); | |
113 f.setCoarse(coarse); | |
114 f.setCoarseRange(range); | |
115 } | |
116 | |
117 public void setFineMiddle(double km, double fine_middle, Range range) { | |
118 if (range == null) { | |
119 logger.error("finemiddle/range is null!"); | |
120 return; | |
121 } | |
122 SedimentLoadFraction f = getFraction(km); | |
123 f.setFineMiddle(fine_middle); | |
124 f.setFineMiddleRange(range); | |
125 } | |
126 | |
127 | |
128 public void setSand(double km, double sand, Range range) { | |
129 if (range == null) { | |
130 logger.error("sand/range is null!"); | |
131 return; | |
132 } | |
133 SedimentLoadFraction f = getFraction(km); | |
134 f.setSand(sand); | |
135 f.setSandRange(range); | |
136 } | |
137 | |
138 public void setSuspSand(double km, double susp_sand, Range range) { | |
139 if (range == null) { | |
140 logger.error("suspsand/range is null!"); | |
141 return; | |
142 } | |
143 SedimentLoadFraction f = getFraction(km); | |
144 f.setSuspSand(susp_sand); | |
145 f.setSuspSandRange(range); | |
146 } | |
147 | |
148 public void setSuspSandBed(double km, double susp_sand_bed, Range range) { | |
149 if (range == null) { | |
150 logger.error("suspsandbed/range is null!"); | |
151 return; | |
152 } | |
153 SedimentLoadFraction f = getFraction(km); | |
154 f.setSuspSandBed(susp_sand_bed); | |
155 f.setSuspSandBedRange(range); | |
156 } | |
157 | |
158 public void setSuspSediment(double km, double susp_sediment, Range range) { | |
159 if (range == null) { | |
160 logger.error("suspsed/range is null!"); | |
161 return; | |
162 } | |
163 SedimentLoadFraction f = getFraction(km); | |
164 f.setSuspSediment(susp_sediment); | |
165 f.setSuspSedimentRange(range); | |
166 } | |
167 | |
168 public void setLoadTotal(double km, double total) { | |
169 setLoadTotal(km, total, null); | |
170 } | |
171 | |
172 public void setLoadTotal(double km, double total, Range range) { | |
173 if (range == null) { | |
174 logger.error("loadtotal/range is null!"); | |
175 return; | |
176 } | |
177 SedimentLoadFraction f = getFraction(km); | |
178 f.setLoadTotal(total); | |
179 f.setLoadTotalRange(range); | |
180 } | |
181 | |
182 public void setTotal(double km, double total, Range range) { | |
183 if (range == null) { | |
184 logger.error("total/range is null!"); | |
185 return; | |
186 } | |
187 SedimentLoadFraction f = getFraction(km); | |
188 f.setTotal(total); | |
189 f.setTotalRange(range); | |
190 } | |
191 | |
192 public void setUnknown(double km, double unknown, Range range) { | |
193 if (range == null) { | |
194 logger.error("unknown/range is null!"); | |
195 return; | |
196 } | |
197 SedimentLoadFraction f = getFraction(km); | |
198 f.setUnknown(unknown); | |
199 f.setUnknownRange(range); | |
200 } | |
201 | |
202 public String getUnit() { | |
203 return unit; | |
204 } | |
205 | |
206 public void setUnit(String unit) { | |
207 this.unit = unit; | |
208 } | |
209 | |
210 public boolean hasCoarse() { | |
211 for (SedimentLoadFraction slf : kms.values()) { | |
212 if (slf.getCoarse() > 0d) { | |
213 return true; | |
214 } | |
215 } | |
216 return false; | |
217 } | |
218 | |
219 public boolean hasFineMiddle() { | |
220 for (SedimentLoadFraction slf : kms.values()) { | |
221 if (slf.getFineMiddle() > 0d) { | |
222 return true; | |
223 } | |
224 } | |
225 return false; | |
226 } | |
227 | |
228 public boolean hasSand() { | |
229 for (SedimentLoadFraction slf : kms.values()) { | |
230 if (slf.getSand() > 0d) { | |
231 return true; | |
232 } | |
233 } | |
234 return false; | |
235 } | |
236 | |
237 public boolean hasSuspSand() { | |
238 for (SedimentLoadFraction slf : kms.values()) { | |
239 if (slf.getSuspSand() > 0d) { | |
240 return true; | |
241 } | |
242 } | |
243 return false; | |
244 } | |
245 | |
246 public boolean hasSuspSediment() { | |
247 for (SedimentLoadFraction slf : kms.values()) { | |
248 if (slf.getSuspSediment() > 0d) { | |
249 return true; | |
250 } | |
251 } | |
252 return false; | |
253 } | |
254 | |
255 public boolean hasTotalLoad() { | |
256 for (SedimentLoadFraction slf : kms.values()) { | |
257 if (slf.getLoadTotal() > 0d) { | |
258 return true; | |
259 } | |
260 } | |
261 return false; | |
262 } | |
263 } | |
264 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |