Mercurial > dive4elements > river
changeset 2410:388cd6fc451b
'Reduzierte Bezugslinien' make the code more self explaining.
flys-artifacts/trunk@4040 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 17:28:28 +0000 |
parents | 4e82bcd07550 |
children | 7e0be3e5dfaa |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/AddScaleFunction.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java |
diffstat | 3 files changed, 38 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 10 16:33:36 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 10 17:28:28 2012 +0000 @@ -1,3 +1,13 @@ +2012-02-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java: + Use AddScaleFunction instead of LinearFunction. + + * src/main/java/de/intevation/flys/artifacts/math/AddScaleFunction.java: + New. f(x) = m*(x+b). I know its aequivalent to m*x + m*b but it + makes more clear that the datum [m] (PNP) is substracted before the + scaling to cm is done. + 2012-02-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Bugfix: take
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/AddScaleFunction.java Fri Feb 10 17:28:28 2012 +0000 @@ -0,0 +1,19 @@ +package de.intevation.flys.artifacts.math; + +public class AddScaleFunction +implements Function +{ + protected double b; + protected double m; + + public AddScaleFunction(double b, double m) { + this.b = b; + this.m = m; + } + + @Override + public double value(double x) { + return (x + b)*m; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java Fri Feb 10 16:33:36 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java Fri Feb 10 17:28:28 2012 +0000 @@ -2,7 +2,7 @@ import de.intevation.flys.artifacts.math.Function; import de.intevation.flys.artifacts.math.Identity; -import de.intevation.flys.artifacts.math.LinearFunction; +import de.intevation.flys.artifacts.math.AddScaleFunction; public class WWAxisTypes { @@ -51,6 +51,10 @@ return transform(ww, false); } + private static final double zero(Double d) { + return d == null ? 0 : d; + } + public WW.ApplyFunctionIterator transform(WW ww, boolean normalized) { Function function1; @@ -58,11 +62,11 @@ if (!normalized) { function1 = inCm1 - ? new LinearFunction(100d, -ww.getStartDatum()*100d) + ? new AddScaleFunction(-ww.getStartDatum(), 100d) : Identity.IDENTITY; function2 = inCm2 - ? new LinearFunction(100d, -ww.getEndDatum()*100d) + ? new AddScaleFunction(-ww.getEndDatum(), 100d) : Identity.IDENTITY; } else { @@ -70,8 +74,8 @@ double minW2 = ww.minWs2(); double scale1 = inCm1 ? 100d : 1d; double scale2 = inCm2 ? 100d : 1d; - function1 = new LinearFunction(scale1, -minW1); - function2 = new LinearFunction(scale1, -minW2); + function1 = new AddScaleFunction(-minW1, scale1); + function2 = new AddScaleFunction(-minW2, scale2); } return new WW.ApplyFunctionIterator(ww, function1, function2);