Mercurial > dive4elements > river
changeset 2197:5781847433d8
"Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0).
flys-artifacts/trunk@3813 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 27 Jan 2012 17:59:24 +0000 (2012-01-27) |
parents | 5f3726f31f00 |
children | 672a41efe222 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WW.java |
diffstat | 3 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jan 27 17:45:26 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jan 27 17:59:24 2012 +0000 @@ -1,3 +1,11 @@ +2012-01-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WW.java: + Added method createNormalized() to shift the data to start in (0, 0). + + * src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java: + Returns the 'normalized' data of the reference curve. + 2012-01-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java Fri Jan 27 17:45:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java Fri Jan 27 17:59:24 2012 +0000 @@ -32,7 +32,7 @@ @Override protected Object getInternalData(WW [] wws) { // TODO: On-the-fly generation of normalized WW. - return wws[index]; + return wws[index].createNormalized(); } /** Copy deeply. */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WW.java Fri Jan 27 17:45:26 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WW.java Fri Jan 27 17:59:24 2012 +0000 @@ -29,6 +29,12 @@ this.ws2 = new TDoubleArrayList(ws2); } + public WW(String name, TDoubleArrayList ws, TDoubleArrayList ws2) { + this.name = name; + this.ws = ws; + this.ws2 = ws2; + } + public void add(double w1, double w2) { ws .add(w1); ws2.add(w2); @@ -58,5 +64,23 @@ public void removeNaNs() { removeNaNs(new TDoubleArrayList [] { ws, ws2 }); } + + public WW createNormalized() { + + double minW1 = ws. min(); + double minW2 = ws2.min(); + + int N = size(); + + TDoubleArrayList ws1c = new TDoubleArrayList(N); + TDoubleArrayList ws2c = new TDoubleArrayList(N); + + for (int i = 0; i < N; ++i) { + ws1c.add(ws. getQuick(i) - minW1); + ws2c.add(ws2.getQuick(i) - minW2); + } + + return new WW(getName(), ws1c, ws2c); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :