sascha@925: package de.intevation.flys.artifacts.model;
sascha@925: 
sascha@925: import gnu.trove.TDoubleArrayList;
sascha@925: 
felix@2420: import de.intevation.flys.utils.DataUtil;
felix@2420: 
felix@2420: 
sascha@925: public class WKmsImpl
sascha@925: extends      NamedObjectImpl
sascha@925: implements   WKms
sascha@925: {
sascha@925:     protected TDoubleArrayList kms;
sascha@925:     protected TDoubleArrayList ws;
sascha@925: 
sascha@925:     public WKmsImpl() {
sascha@925:         super("");
sascha@925:         kms = new TDoubleArrayList();
sascha@925:         ws  = new TDoubleArrayList();
sascha@925:     }
sascha@925: 
felix@1162: 
felix@1720:     /**
felix@1720:      * Create named, empty WKms.
felix@1720:      */
felix@1720:     public WKmsImpl(String name) {
felix@1720:         super(name);
felix@1720:         kms = new TDoubleArrayList();
felix@1720:         ws  = new TDoubleArrayList();
felix@1720:     }
felix@1720: 
felix@1720: 
sascha@925:     public WKmsImpl(int capacity) {
sascha@925:         super("");
sascha@925:         kms = new TDoubleArrayList(capacity);
sascha@925:         ws  = new TDoubleArrayList(capacity);
sascha@925:     }
sascha@925: 
felix@1162: 
sascha@925:     public WKmsImpl(TDoubleArrayList kms, TDoubleArrayList ws) {
sascha@925:         this(kms, ws, "");
sascha@925:     }
sascha@925: 
felix@1162: 
sascha@925:     public WKmsImpl(
sascha@925:         TDoubleArrayList kms,
sascha@925:         TDoubleArrayList ws,
sascha@925:         String           name
sascha@925:     ) {
sascha@925:         super(name);
sascha@925:         this.kms = kms;
sascha@925:         this.ws  = ws;
sascha@925:     }
sascha@925: 
felix@1162: 
felix@1720:     /**
felix@1720:      * Add a W (in NN+m) for a km (in km).
felix@1720:      */
sascha@925:     public void add(double km, double w) {
sascha@925:         kms.add(km);
sascha@925:         ws .add(w);
sascha@925:     }
sascha@925: 
felix@1162: 
sascha@1678:     @Override
sascha@925:     public double getW(int index) {
sascha@925:         return ws.getQuick(index);
sascha@925:     }
sascha@925: 
felix@1162: 
sascha@1678:     @Override
sascha@925:     public double getKm(int index) {
sascha@925:         return kms.getQuick(index);
sascha@925:     }
sascha@925: 
felix@2420:     @Override
felix@2420:     public boolean guessWaterIncreasing() {
felix@2420:         return guessWaterIncreasing(0.05f);
felix@2420:     }
felix@2420: 
ingo@2422:     protected boolean guessWaterIncreasing(float factor) {
felix@2420:         return DataUtil.guessWaterIncreasing(ws, factor);
felix@2420:     }
felix@1162: 
sascha@1678:     @Override
sascha@925:     public int size() {
sascha@925:         return kms.size();
sascha@925:     }
sascha@1678: 
sascha@1678:     @Override
sascha@1678:     public TDoubleArrayList allKms() {
sascha@1678:         return kms;
sascha@1678:     }
sascha@1678: 
sascha@1678:     @Override
sascha@1678:     public TDoubleArrayList allWs() {
sascha@1678:         return ws;
sascha@1678:     }
sascha@925: }
sascha@925: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :