# HG changeset patch # User Sascha L. Teichmann # Date 1327687164 0 # Node ID 5781847433d8f385a10af35078575b9e3024a43a # Parent 5f3726f31f00281c6b4c54e67282175cb8e49d39 "Bezugslinienverfahren": Implemented the on-the-flys shift to (0, 0). flys-artifacts/trunk@3813 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5f3726f31f00 -r 5781847433d8 flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/model/NormalizedReferenceCurveFacet.java: diff -r 5f3726f31f00 -r 5781847433d8 flys-artifacts/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. */ diff -r 5f3726f31f00 -r 5781847433d8 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WW.java --- 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 :