Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java @ 6551:8c226c5089e0
BedDiff*Generator: Refactored to avoid code dupes. The problematic setting
will not crash anymore, but diagram will be empty.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 10 Jul 2013 10:05:52 +0200 |
parents | 7cf3b3bcd439 |
children | ae00ab7025ec |
comparison
equal
deleted
inserted
replaced
6550:7cf3b3bcd439 | 6551:8c226c5089e0 |
---|---|
32 import org.dive4elements.river.utils.DataUtil; | 32 import org.dive4elements.river.utils.DataUtil; |
33 import org.dive4elements.river.utils.RiverUtils; | 33 import org.dive4elements.river.utils.RiverUtils; |
34 | 34 |
35 | 35 |
36 public class BedDifferenceYearGenerator | 36 public class BedDifferenceYearGenerator |
37 extends FixChartGenerator | 37 extends BedDiffBaseGenerator |
38 implements FacetTypes | 38 implements FacetTypes |
39 { | 39 { |
40 public enum YAXIS { | 40 public enum YAXIS { |
41 D(0), M(1), H(2), dW(3), W(4); | 41 D(0), M(1), H(2), dW(3), W(4); |
42 | 42 |
84 return yaxes[idx].toString(); | 84 return yaxes[idx].toString(); |
85 } | 85 } |
86 }; | 86 }; |
87 } | 87 } |
88 | 88 |
89 public void setContextBounds(ArtifactAndFacet bundle) { | |
90 if (getXBounds(0) != null && getDomainAxisRange() != null) { | |
91 Bounds bounds = | |
92 calculateZoom(getXBounds(0), getDomainAxisRange()); | |
93 context.putContextValue("startkm", bounds.getLower()); | |
94 context.putContextValue("endkm", bounds.getUpper()); | |
95 } | |
96 else if (getXBounds(0) != null && getDomainAxisRange() == null) { | |
97 context.putContextValue("startkm", getXBounds(0).getLower()); | |
98 context.putContextValue("endkm", getXBounds(0).getUpper()); | |
99 } | |
100 else if (getXBounds(0) == null && getDomainAxisRange() == null) { | |
101 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
102 if (data.getKms().size() > 0) { | |
103 context.putContextValue("startkm", data.getKms().min()); | |
104 context.putContextValue("endkm", data.getKms().max()); | |
105 } | |
106 else { | |
107 logger.warn("No data to define start and end km"); | |
108 } | |
109 } | |
110 else if (getXBounds(0) == null && getDomainAxisRange() != null){ | |
111 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
112 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); | |
113 Bounds bounds = | |
114 calculateZoom(b, getDomainAxisRange()); | |
115 context.putContextValue("startkm", bounds.getLower()); | |
116 context.putContextValue("endkm", bounds.getUpper()); | |
117 } | |
118 } | |
119 | 89 |
120 @Override | 90 @Override |
121 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { | 91 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { |
122 String name = bundle.getFacetName(); | 92 String name = bundle.getFacetName(); |
123 | 93 |
132 | 102 |
133 if (facet == null) { | 103 if (facet == null) { |
134 return; | 104 return; |
135 } | 105 } |
136 | 106 |
137 setContextBounds(bundle); | 107 if (bundle.getData(context) instanceof BedDifferencesResult) { |
108 setContextBounds(bundle); | |
109 } | |
138 | 110 |
139 Processor processor = new KMIndexProcessor(); | 111 Processor processor = new KMIndexProcessor(); |
140 Processor woutp = new WOutProcessor(); | 112 Processor woutp = new WOutProcessor(); |
141 if (name.equals(BED_DIFFERENCE_YEAR)) { | 113 if (name.equals(BED_DIFFERENCE_YEAR)) { |
142 doBedDifferenceYearOut( | 114 doBedDifferenceYearOut( |