teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model; ingo@446: ingo@446: import gnu.trove.TDoubleArrayList; ingo@446: ingo@446: ingo@446: /** ingo@446: * A model class that is used to store a line of a WST. ingo@446: * ingo@446: * @author Ingo Weinzierl ingo@446: */ ingo@446: public class WstLine { ingo@446: ingo@446: /** The kilometer value of the line.*/ ingo@446: protected double km; ingo@446: ingo@446: /** The W values.*/ ingo@446: protected TDoubleArrayList ws; ingo@446: ingo@446: /** The Q values.*/ ingo@446: protected TDoubleArrayList qs; ingo@446: ingo@446: ingo@446: /** ingo@446: * A constructor that builds a new WstLine for a specific kilometer. ingo@446: * ingo@446: * @param km The kilometer. ingo@446: */ ingo@446: public WstLine(double km) { ingo@446: this.km = km; ingo@446: this.ws = new TDoubleArrayList(); ingo@446: this.qs = new TDoubleArrayList(); ingo@446: } ingo@446: ingo@446: ingo@446: /** ingo@446: * Adds a pair of W/Q to this line. ingo@446: * ingo@446: * @param w The W value. ingo@446: * @param q The Q value. ingo@446: */ ingo@446: public void add(double w, double q) { ingo@446: ws.add(w); ingo@446: qs.add(q); ingo@446: } ingo@446: ingo@446: ingo@446: /** ingo@446: * Returns the kilometer of this line. ingo@446: * ingo@446: * @return the kilomter of this line. ingo@446: */ ingo@446: public double getKm() { ingo@446: return km; ingo@446: } ingo@446: ingo@446: ingo@446: /** ingo@446: * Returns the W value at index idx of this line. ingo@446: * ingo@446: * @param idx The position of the desired W value. ingo@446: * ingo@446: * @return the W at position idx. ingo@446: */ ingo@446: public double getW(int idx) { ingo@446: return ws.size() > idx ? ws.get(idx) : -1d; ingo@446: } ingo@446: felix@7609: aheinecke@7604: /** felix@7609: * Returns the Q value at index idx of this line. aheinecke@7604: * felix@7609: * @param idx The position of the desired Q value. aheinecke@7604: * felix@7609: * @return the Q at position idx. aheinecke@7604: */ aheinecke@7604: public double getQ(int idx) { aheinecke@7604: return qs.size() > idx ? qs.get(idx) : -1d; aheinecke@7604: } ingo@446: felix@7609: ingo@446: /** ingo@446: * Returns the Q values of this line. ingo@446: * ingo@446: * @return the Q values of this line. ingo@446: */ ingo@446: public double[] getQs() { ingo@446: return qs.toNativeArray(); ingo@446: } ingo@446: ingo@446: ingo@446: /** ingo@446: * Returns the number of columns this line consists of. ingo@446: * ingo@446: * @return the columns this line consists of. ingo@446: */ ingo@446: public int getSize() { ingo@446: return qs.size(); ingo@446: } ingo@446: } ingo@446: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :