annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTimerange.java @ 5337:3d7db721a278

Part of i18n fixes for flys/issue1180.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 19 Mar 2013 11:29:10 +0100
parents 05eeedc5b156
children 61f4d4164a30
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 /**
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
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
13 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
14 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
15 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
16 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
17
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 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
19 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
20 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
21 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
22 }
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
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4171
diff changeset
24 /** 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
25 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
26 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
27 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
28 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
29 }
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
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 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
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
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 @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
35 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
36 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
37 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
38 }
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 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
40 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
41 }
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 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
43 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
44 }
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 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
46 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
47 }
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 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
49 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
50 }
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 }
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
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4171
diff changeset
54 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
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
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 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
58 super("");
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
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 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
63 super(name);
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4171
diff changeset
64 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
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
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 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
69 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
70 qs.add(q);
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4171
diff changeset
71 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
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
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
2239
e7843533f086 Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2217
diff changeset
75 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
76 return timeranges.get(idx);
2239
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
e7843533f086 Improved WQTimerange and HistoricalDischargeFacet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2217
diff changeset
79
2217
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 public Timerange[] getTimeranges() {
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4171
diff changeset
81 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
82 }
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
83
1d8faeedda0c Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3452
diff changeset
84 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
85 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
86 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
87 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
88 }
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
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 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
91 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
92 }
2217
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 }
54422e31dc27 Added new model classes which will be used during historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org