Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTimerange.java @ 5771:0677aff0ff15
Fixed typo ind i18n string.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 18 Apr 2013 15:03:13 +0200 |
parents | 61f4d4164a30 |
children |
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; |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
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 /** |
5343
61f4d4164a30
Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5335
diff
changeset
|
9 * A collection of triples W,Q,Timerange. |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 * @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
|
11 */ |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 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
|
13 |
5343
61f4d4164a30
Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5335
diff
changeset
|
14 /** Used to sort <w,q,timerange> triples. */ |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
15 public static class TimerangeItem implements Comparable<TimerangeItem> { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
16 public double q; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
17 public double w; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
18 public Timerange timerange; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
19 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
20 public TimerangeItem (Timerange timerange, double q, double w) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
21 this.timerange = timerange; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
22 this.q = q; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
23 this.w = w; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
24 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
25 |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
26 /** Sets [w,q] in wq. */ |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
27 public double[] get(double[] wq) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
28 if (wq.length >= 2) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
29 wq[0] = w; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
30 wq[1] = q; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
31 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
32 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
33 return wq; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
34 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
35 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
36 @Override |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
37 public int compareTo(TimerangeItem other) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
38 if (other.timerange.getStart() < timerange.getStart()) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
39 return 1; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
40 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
41 else if (other.timerange.getStart() > timerange.getStart()) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
42 return -1; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
43 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
44 else if (other.timerange.getEnd() < timerange.getEnd()) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
45 return 1; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
46 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
47 else if (other.timerange.getEnd() > timerange.getEnd()){ |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
48 return -1; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
49 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
50 else { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
51 return 0; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
52 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
53 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
54 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
55 |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
56 protected List<Timerange> timeranges; |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
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 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
|
60 super(""); |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 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
|
65 super(name); |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
66 timeranges = new ArrayList<Timerange>(); |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 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
|
71 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
|
72 qs.add(q); |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
73 timeranges.add(t); |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
2239
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
77 public Timerange getTimerange(int idx) { |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
78 return timeranges.get(idx); |
2239
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
79 } |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
80 |
e7843533f086
Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2217
diff
changeset
|
81 |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 public Timerange[] getTimeranges() { |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
83 return timeranges.toArray(new Timerange[timeranges.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
|
84 } |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
85 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
86 public List<TimerangeItem> sort() { |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4171
diff
changeset
|
87 ArrayList<TimerangeItem> items = new ArrayList<TimerangeItem>(timeranges.size()); |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
88 for (int i = 0, n = size(); i < n; i++) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
89 items.add(new TimerangeItem(getTimerange(i), getQ(i), getW(i))); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
90 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
91 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
92 Collections.sort(items); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
93 return items; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3452
diff
changeset
|
94 } |
2217
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 } |
54422e31dc27
Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |