Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java @ 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 | dce0cc856357 |
children |
comparison
equal
deleted
inserted
replaced
2409:4e82bcd07550 | 2410:388cd6fc451b |
---|---|
1 package de.intevation.flys.artifacts.model; | 1 package de.intevation.flys.artifacts.model; |
2 | 2 |
3 import de.intevation.flys.artifacts.math.Function; | 3 import de.intevation.flys.artifacts.math.Function; |
4 import de.intevation.flys.artifacts.math.Identity; | 4 import de.intevation.flys.artifacts.math.Identity; |
5 import de.intevation.flys.artifacts.math.LinearFunction; | 5 import de.intevation.flys.artifacts.math.AddScaleFunction; |
6 | 6 |
7 public class WWAxisTypes | 7 public class WWAxisTypes |
8 { | 8 { |
9 protected boolean inCm1; | 9 protected boolean inCm1; |
10 protected boolean inCm2; | 10 protected boolean inCm2; |
49 | 49 |
50 public WW.ApplyFunctionIterator transform(WW ww) { | 50 public WW.ApplyFunctionIterator transform(WW ww) { |
51 return transform(ww, false); | 51 return transform(ww, false); |
52 } | 52 } |
53 | 53 |
54 private static final double zero(Double d) { | |
55 return d == null ? 0 : d; | |
56 } | |
57 | |
54 public WW.ApplyFunctionIterator transform(WW ww, boolean normalized) { | 58 public WW.ApplyFunctionIterator transform(WW ww, boolean normalized) { |
55 | 59 |
56 Function function1; | 60 Function function1; |
57 Function function2; | 61 Function function2; |
58 | 62 |
59 if (!normalized) { | 63 if (!normalized) { |
60 function1 = inCm1 | 64 function1 = inCm1 |
61 ? new LinearFunction(100d, -ww.getStartDatum()*100d) | 65 ? new AddScaleFunction(-ww.getStartDatum(), 100d) |
62 : Identity.IDENTITY; | 66 : Identity.IDENTITY; |
63 | 67 |
64 function2 = inCm2 | 68 function2 = inCm2 |
65 ? new LinearFunction(100d, -ww.getEndDatum()*100d) | 69 ? new AddScaleFunction(-ww.getEndDatum(), 100d) |
66 : Identity.IDENTITY; | 70 : Identity.IDENTITY; |
67 } | 71 } |
68 else { | 72 else { |
69 double minW1 = ww.minWs(); | 73 double minW1 = ww.minWs(); |
70 double minW2 = ww.minWs2(); | 74 double minW2 = ww.minWs2(); |
71 double scale1 = inCm1 ? 100d : 1d; | 75 double scale1 = inCm1 ? 100d : 1d; |
72 double scale2 = inCm2 ? 100d : 1d; | 76 double scale2 = inCm2 ? 100d : 1d; |
73 function1 = new LinearFunction(scale1, -minW1); | 77 function1 = new AddScaleFunction(-minW1, scale1); |
74 function2 = new LinearFunction(scale1, -minW2); | 78 function2 = new AddScaleFunction(-minW2, scale2); |
75 } | 79 } |
76 | 80 |
77 return new WW.ApplyFunctionIterator(ww, function1, function2); | 81 return new WW.ApplyFunctionIterator(ww, function1, function2); |
78 } | 82 } |
79 } | 83 } |