Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTimerange.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | 61f4d4164a30 |
children |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
4 import java.util.Collections; | 4 import java.util.Collections; |
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
7 | 7 |
8 /** | 8 /** |
9 * A collection of triples W,Q,Timerange. | |
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 10 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
10 */ | 11 */ |
11 public class WQTimerange extends WQ { | 12 public class WQTimerange extends WQ { |
12 | 13 |
14 /** Used to sort <w,q,timerange> triples. */ | |
13 public static class TimerangeItem implements Comparable<TimerangeItem> { | 15 public static class TimerangeItem implements Comparable<TimerangeItem> { |
14 public double q; | 16 public double q; |
15 public double w; | 17 public double w; |
16 public Timerange timerange; | 18 public Timerange timerange; |
17 | 19 |
19 this.timerange = timerange; | 21 this.timerange = timerange; |
20 this.q = q; | 22 this.q = q; |
21 this.w = w; | 23 this.w = w; |
22 } | 24 } |
23 | 25 |
26 /** Sets [w,q] in wq. */ | |
24 public double[] get(double[] wq) { | 27 public double[] get(double[] wq) { |
25 if (wq.length >= 2) { | 28 if (wq.length >= 2) { |
26 wq[0] = w; | 29 wq[0] = w; |
27 wq[1] = q; | 30 wq[1] = q; |
28 } | 31 } |
48 return 0; | 51 return 0; |
49 } | 52 } |
50 } | 53 } |
51 } | 54 } |
52 | 55 |
53 protected List<Timerange> ts; | 56 protected List<Timerange> timeranges; |
54 | 57 |
55 | 58 |
56 public WQTimerange() { | 59 public WQTimerange() { |
57 super(""); | 60 super(""); |
58 } | 61 } |
59 | 62 |
60 | 63 |
61 public WQTimerange(String name) { | 64 public WQTimerange(String name) { |
62 super(name); | 65 super(name); |
63 ts = new ArrayList<Timerange>(); | 66 timeranges = new ArrayList<Timerange>(); |
64 } | 67 } |
65 | 68 |
66 | 69 |
67 public void add(double w, double q, Timerange t) { | 70 public void add(double w, double q, Timerange t) { |
68 ws.add(w); | 71 ws.add(w); |
69 qs.add(q); | 72 qs.add(q); |
70 ts.add(t); | 73 timeranges.add(t); |
71 } | 74 } |
72 | 75 |
73 | 76 |
74 public Timerange getTimerange(int idx) { | 77 public Timerange getTimerange(int idx) { |
75 return ts.get(idx); | 78 return timeranges.get(idx); |
76 } | 79 } |
77 | 80 |
78 | 81 |
79 public Timerange[] getTimeranges() { | 82 public Timerange[] getTimeranges() { |
80 return ts.toArray(new Timerange[ts.size()]); | 83 return timeranges.toArray(new Timerange[timeranges.size()]); |
81 } | 84 } |
82 | 85 |
83 public List<TimerangeItem> sort() { | 86 public List<TimerangeItem> sort() { |
84 ArrayList<TimerangeItem> items = new ArrayList<TimerangeItem>(ts.size()); | 87 ArrayList<TimerangeItem> items = new ArrayList<TimerangeItem>(timeranges.size()); |
85 for (int i = 0, n = size(); i < n; i++) { | 88 for (int i = 0, n = size(); i < n; i++) { |
86 items.add(new TimerangeItem(getTimerange(i), getQ(i), getW(i))); | 89 items.add(new TimerangeItem(getTimerange(i), getQ(i), getW(i))); |
87 } | 90 } |
88 | 91 |
89 Collections.sort(items); | 92 Collections.sort(items); |