comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 75146a1261c4
children
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
1 package de.intevation.flys.artifacts.model;
2
3 import gnu.trove.TDoubleArrayList;
4
5 import de.intevation.flys.utils.DataUtil;
6
7
8 public class WKmsImpl
9 extends NamedObjectImpl
10 implements WKms
11 {
12 protected TDoubleArrayList kms;
13 protected TDoubleArrayList ws;
14
15 public WKmsImpl() {
16 super("");
17 kms = new TDoubleArrayList();
18 ws = new TDoubleArrayList();
19 }
20
21
22 /**
23 * Create named, empty WKms.
24 */
25 public WKmsImpl(String name) {
26 super(name);
27 kms = new TDoubleArrayList();
28 ws = new TDoubleArrayList();
29 }
30
31
32 public WKmsImpl(int capacity) {
33 super("");
34 kms = new TDoubleArrayList(capacity);
35 ws = new TDoubleArrayList(capacity);
36 }
37
38
39 public WKmsImpl(TDoubleArrayList kms, TDoubleArrayList ws) {
40 this(kms, ws, "");
41 }
42
43
44 public WKmsImpl(
45 TDoubleArrayList kms,
46 TDoubleArrayList ws,
47 String name
48 ) {
49 super(name);
50 this.kms = kms;
51 this.ws = ws;
52 }
53
54
55 /**
56 * Add a W (in NN+m) for a km (in km).
57 */
58 public void add(double km, double w) {
59 kms.add(km);
60 ws .add(w);
61 }
62
63
64 @Override
65 public double getW(int index) {
66 return ws.getQuick(index);
67 }
68
69
70 @Override
71 public double getKm(int index) {
72 return kms.getQuick(index);
73 }
74
75 @Override
76 public boolean guessWaterIncreasing() {
77 return guessWaterIncreasing(0.05f);
78 }
79
80 protected boolean guessWaterIncreasing(float factor) {
81 return DataUtil.guessWaterIncreasing(ws, factor);
82 }
83
84 @Override
85 public int size() {
86 return kms.size();
87 }
88
89 @Override
90 public TDoubleArrayList allKms() {
91 return kms;
92 }
93
94 @Override
95 public TDoubleArrayList allWs() {
96 return ws;
97 }
98 }
99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org