Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.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 | 88b9b666872e |
comparison
equal
deleted
inserted
replaced
6550:7cf3b3bcd439 | 6551:8c226c5089e0 |
---|---|
26 import org.dive4elements.river.jfree.RiverAnnotation; | 26 import org.dive4elements.river.jfree.RiverAnnotation; |
27 import org.dive4elements.river.jfree.StyledXYSeries; | 27 import org.dive4elements.river.jfree.StyledXYSeries; |
28 | 28 |
29 | 29 |
30 public class BedDiffHeightYearGenerator | 30 public class BedDiffHeightYearGenerator |
31 extends FixChartGenerator | 31 extends BedDiffBaseGenerator |
32 implements FacetTypes | 32 implements FacetTypes |
33 { | 33 { |
34 public enum YAXIS { | 34 public enum YAXIS { |
35 D(0), dW(1); | 35 D(0), dW(1); |
36 | 36 |
118 else { | 118 else { |
119 logger.warn("Unknown facet name " + name); | 119 logger.warn("Unknown facet name " + name); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 public void setContextBounds(ArtifactAndFacet bundle) { | |
124 if (getXBounds(0) != null && getDomainAxisRange() != null) { | |
125 Bounds bounds = | |
126 calculateZoom(getXBounds(0), getDomainAxisRange()); | |
127 context.putContextValue("startkm", bounds.getLower()); | |
128 context.putContextValue("endkm", bounds.getUpper()); | |
129 } | |
130 else if (getXBounds(0) != null && getDomainAxisRange() == null) { | |
131 context.putContextValue("startkm", getXBounds(0).getLower()); | |
132 context.putContextValue("endkm", getXBounds(0).getUpper()); | |
133 } | |
134 else if (getXBounds(0) == null && getDomainAxisRange() == null) { | |
135 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
136 if (data.getKms().size() > 0) { | |
137 context.putContextValue("startkm", data.getKms().min()); | |
138 context.putContextValue("endkm", data.getKms().max()); | |
139 } | |
140 else { | |
141 logger.warn("No data to define start and end km"); | |
142 } | |
143 } | |
144 else if (getXBounds(0) == null && getDomainAxisRange() != null){ | |
145 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
146 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); | |
147 Bounds bounds = | |
148 calculateZoom(b, getDomainAxisRange()); | |
149 context.putContextValue("startkm", bounds.getLower()); | |
150 context.putContextValue("endkm", bounds.getUpper()); | |
151 } | |
152 } | |
153 | 123 |
154 @Override | 124 @Override |
155 protected String getDefaultChartTitle() { | 125 protected String getDefaultChartTitle() { |
156 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 126 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
157 } | 127 } |