Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTimerange.java @ 4183:1755a1bfe5ce
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 19 Oct 2012 09:20:52 +0200 |
parents | 200e70f31f6f |
children | 05eeedc5b156 |
rev | line source |
---|---|
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
4183 | 4 import java.util.Collections; |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.util.List; |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 /** |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 */ |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 public class WQTimerange extends WQ { |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
4183 | 13 public static class TimerangeItem implements Comparable<TimerangeItem> { |
14 public double q; | |
15 public double w; | |
16 public Timerange timerange; | |
17 | |
18 public TimerangeItem (Timerange timerange, double q, double w) { | |
19 this.timerange = timerange; | |
20 this.q = q; | |
21 this.w = w; | |
22 } | |
23 | |
24 public double[] get(double[] wq) { | |
25 if (wq.length >= 2) { | |
26 wq[0] = w; | |
27 wq[1] = q; | |
28 } | |
29 | |
30 return wq; | |
31 } | |
32 | |
33 @Override | |
34 public int compareTo(TimerangeItem other) { | |
35 if (other.timerange.getStart() < timerange.getStart()) { | |
36 return 1; | |
37 } | |
38 else if (other.timerange.getStart() > timerange.getStart()) { | |
39 return -1; | |
40 } | |
41 else if (other.timerange.getEnd() < timerange.getEnd()) { | |
42 return 1; | |
43 } | |
44 else if (other.timerange.getEnd() > timerange.getEnd()){ | |
45 return -1; | |
46 } | |
47 else { | |
48 return 0; | |
49 } | |
50 } | |
51 } | |
52 | |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 protected List<Timerange> ts; |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 public WQTimerange() { |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 super(""); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 public WQTimerange(String name) { |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 super(name); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 ts = new ArrayList<Timerange>(); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 public void add(double w, double q, Timerange t) { |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 ws.add(w); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 qs.add(q); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 ts.add(t); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
2239
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
74 public Timerange getTimerange(int idx) { |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
75 return ts.get(idx); |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
76 } |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
77 |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
78 |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 public Timerange[] getTimeranges() { |
3452
200e70f31f6f
Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2311
diff
changeset
|
80 return ts.toArray(new Timerange[ts.size()]); |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
4183 | 82 |
83 public List<TimerangeItem> sort() { | |
84 ArrayList<TimerangeItem> items = new ArrayList<TimerangeItem>(ts.size()); | |
85 for (int i = 0, n = size(); i < n; i++) { | |
86 items.add(new TimerangeItem(getTimerange(i), getQ(i), getW(i))); | |
87 } | |
88 | |
89 Collections.sort(items); | |
90 return items; | |
91 } | |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |