Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/WWAxisTypes.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWAxisTypes.java@388cd6fc451b |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.model; | |
2 | |
3 import org.dive4elements.river.artifacts.math.Function; | |
4 import org.dive4elements.river.artifacts.math.Identity; | |
5 import org.dive4elements.river.artifacts.math.AddScaleFunction; | |
6 | |
7 public class WWAxisTypes | |
8 { | |
9 protected boolean inCm1; | |
10 protected boolean inCm2; | |
11 | |
12 public WWAxisTypes() { | |
13 inCm1 = inCm2 = true; | |
14 } | |
15 | |
16 public WWAxisTypes(WW ww) { | |
17 this(); | |
18 classify(ww); | |
19 } | |
20 | |
21 public void classify(WW ww) { | |
22 if (!ww.startAtGauge()) inCm1 = false; | |
23 if (!ww.endAtGauge()) inCm2 = false; | |
24 } | |
25 | |
26 public boolean getInCm(int index) { | |
27 switch (index) { | |
28 case 0: return inCm1; | |
29 case 1: return inCm2; | |
30 default: return false; | |
31 } | |
32 } | |
33 | |
34 public boolean getInCm1() { | |
35 return inCm1; | |
36 } | |
37 | |
38 public void setInCm1(boolean inCm1) { | |
39 this.inCm1 = inCm1; | |
40 } | |
41 | |
42 public boolean getInCm2() { | |
43 return inCm2; | |
44 } | |
45 | |
46 public void setInCm2(boolean inCm2) { | |
47 this.inCm2 = inCm2; | |
48 } | |
49 | |
50 public WW.ApplyFunctionIterator transform(WW ww) { | |
51 return transform(ww, false); | |
52 } | |
53 | |
54 private static final double zero(Double d) { | |
55 return d == null ? 0 : d; | |
56 } | |
57 | |
58 public WW.ApplyFunctionIterator transform(WW ww, boolean normalized) { | |
59 | |
60 Function function1; | |
61 Function function2; | |
62 | |
63 if (!normalized) { | |
64 function1 = inCm1 | |
65 ? new AddScaleFunction(-ww.getStartDatum(), 100d) | |
66 : Identity.IDENTITY; | |
67 | |
68 function2 = inCm2 | |
69 ? new AddScaleFunction(-ww.getEndDatum(), 100d) | |
70 : Identity.IDENTITY; | |
71 } | |
72 else { | |
73 double minW1 = ww.minWs(); | |
74 double minW2 = ww.minWs2(); | |
75 double scale1 = inCm1 ? 100d : 1d; | |
76 double scale2 = inCm2 ? 100d : 1d; | |
77 function1 = new AddScaleFunction(-minW1, scale1); | |
78 function2 = new AddScaleFunction(-minW2, scale2); | |
79 } | |
80 | |
81 return new WW.ApplyFunctionIterator(ww, function1, function2); | |
82 } | |
83 } | |
84 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |