Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | 75146a1261c4 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsImpl.java Fri Sep 28 12:14:39 2012 +0200 @@ -0,0 +1,99 @@ +package de.intevation.flys.artifacts.model; + +import gnu.trove.TDoubleArrayList; + +import de.intevation.flys.utils.DataUtil; + + +public class WKmsImpl +extends NamedObjectImpl +implements WKms +{ + protected TDoubleArrayList kms; + protected TDoubleArrayList ws; + + public WKmsImpl() { + super(""); + kms = new TDoubleArrayList(); + ws = new TDoubleArrayList(); + } + + + /** + * Create named, empty WKms. + */ + public WKmsImpl(String name) { + super(name); + kms = new TDoubleArrayList(); + ws = new TDoubleArrayList(); + } + + + public WKmsImpl(int capacity) { + super(""); + kms = new TDoubleArrayList(capacity); + ws = new TDoubleArrayList(capacity); + } + + + public WKmsImpl(TDoubleArrayList kms, TDoubleArrayList ws) { + this(kms, ws, ""); + } + + + public WKmsImpl( + TDoubleArrayList kms, + TDoubleArrayList ws, + String name + ) { + super(name); + this.kms = kms; + this.ws = ws; + } + + + /** + * Add a W (in NN+m) for a km (in km). + */ + public void add(double km, double w) { + kms.add(km); + ws .add(w); + } + + + @Override + public double getW(int index) { + return ws.getQuick(index); + } + + + @Override + public double getKm(int index) { + return kms.getQuick(index); + } + + @Override + public boolean guessWaterIncreasing() { + return guessWaterIncreasing(0.05f); + } + + protected boolean guessWaterIncreasing(float factor) { + return DataUtil.guessWaterIncreasing(ws, factor); + } + + @Override + public int size() { + return kms.size(); + } + + @Override + public TDoubleArrayList allKms() { + return kms; + } + + @Override + public TDoubleArrayList allWs() { + return ws; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :