Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceYearGenerator.java @ 6791:dd5355775ce1 longitudinal-symmetry
merge changes from default into longitudinal-symmetrie branch and make it build
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 07 Aug 2013 18:53:15 +0200 |
parents | ef3b02034f6a aee8cb5c801a |
children | 23ab795f2f0e |
comparison
equal
deleted
inserted
replaced
6518:1a7f5d09b9d8 | 6791:dd5355775ce1 |
---|---|
19 import org.dive4elements.river.artifacts.model.WKms; | 19 import org.dive4elements.river.artifacts.model.WKms; |
20 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult; | 20 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult; |
21 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; | 21 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; |
22 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth; | 22 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth; |
23 import org.dive4elements.river.exports.StyledSeriesBuilder; | 23 import org.dive4elements.river.exports.StyledSeriesBuilder; |
24 import org.dive4elements.river.exports.LongitudinalSectionGenerator; | 24 import org.dive4elements.river.exports.process.BedDiffYearProcessor; |
25 import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor; | |
25 import org.dive4elements.river.exports.process.KMIndexProcessor; | 26 import org.dive4elements.river.exports.process.KMIndexProcessor; |
26 import org.dive4elements.river.exports.process.Processor; | 27 import org.dive4elements.river.exports.process.Processor; |
27 import org.dive4elements.river.exports.process.WOutProcessor; | 28 import org.dive4elements.river.exports.process.WOutProcessor; |
28 import org.dive4elements.river.jfree.Bounds; | |
29 import org.dive4elements.river.jfree.DoubleBounds; | |
30 import org.dive4elements.river.jfree.RiverAnnotation; | 29 import org.dive4elements.river.jfree.RiverAnnotation; |
31 import org.dive4elements.river.jfree.StyledXYSeries; | 30 import org.dive4elements.river.jfree.StyledXYSeries; |
32 import org.dive4elements.river.utils.DataUtil; | 31 import org.dive4elements.river.utils.DataUtil; |
33 import org.dive4elements.river.utils.RiverUtils; | 32 import org.dive4elements.river.utils.RiverUtils; |
34 | 33 |
35 | 34 |
36 public class BedDifferenceYearGenerator | 35 public class BedDifferenceYearGenerator |
37 extends LongitudinalSectionGenerator | 36 extends BedDiffBaseGenerator |
38 implements FacetTypes | 37 implements FacetTypes |
39 { | 38 { |
40 public enum YAXIS { | 39 public enum YAXIS { |
41 D(0), M(1), H(2), dW(3), W(4); | 40 D(0), M(1), H(2), dW(3), W(4); |
42 | 41 |
43 protected int idx; | 42 protected int idx; |
44 | 43 |
45 private YAXIS(int c) { | 44 private YAXIS(int c) { |
46 idx = c; | 45 idx = c; |
82 return yaxes[idx].toString(); | 81 return yaxes[idx].toString(); |
83 } | 82 } |
84 }; | 83 }; |
85 } | 84 } |
86 | 85 |
86 | |
87 @Override | 87 @Override |
88 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { | 88 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { |
89 String name = bundle.getFacetName(); | 89 String name = bundle.getFacetName(); |
90 | 90 |
91 logger.debug("doOut: " + name); | 91 logger.debug("doOut: " + name); |
99 | 99 |
100 if (facet == null) { | 100 if (facet == null) { |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
104 if (getXBounds(0) != null && getDomainAxisRange() != null) { | 104 if (bundle.getData(context) instanceof BedDifferencesResult) { |
105 Bounds bounds = | 105 setContextBounds(bundle); |
106 calculateZoom(getXBounds(0), getDomainAxisRange()); | 106 } |
107 context.putContextValue("startkm", bounds.getLower()); | 107 |
108 context.putContextValue("endkm", bounds.getUpper()); | |
109 } | |
110 else if (getXBounds(0) != null && getDomainAxisRange() == null) { | |
111 context.putContextValue("startkm", getXBounds(0).getLower()); | |
112 context.putContextValue("endkm", getXBounds(0).getUpper()); | |
113 } | |
114 else if (getXBounds(0) == null && getDomainAxisRange() == null) { | |
115 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
116 context.putContextValue("startkm", data.getKms().min()); | |
117 context.putContextValue("endkm", data.getKms().max()); | |
118 } | |
119 else if (getXBounds(0) == null && getDomainAxisRange() != null){ | |
120 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
121 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); | |
122 Bounds bounds = | |
123 calculateZoom(b, getDomainAxisRange()); | |
124 context.putContextValue("startkm", bounds.getLower()); | |
125 context.putContextValue("endkm", bounds.getUpper()); | |
126 } | |
127 Processor processor = new KMIndexProcessor(); | 108 Processor processor = new KMIndexProcessor(); |
128 Processor woutp = new WOutProcessor(); | 109 Processor woutp = new WOutProcessor(); |
129 if (name.equals(BED_DIFFERENCE_YEAR)) { | 110 Processor bdhyProcessor = new BedDiffHeightYearProcessor(); |
130 doBedDifferenceYearOut( | 111 Processor bdyProcessor = new BedDiffYearProcessor(); |
131 (BedDiffYearResult) bundle.getData(context), | 112 if (name.equals(BED_DIFFERENCE_MORPH_WIDTH)) { |
132 bundle, attr, visible); | |
133 } | |
134 else if (name.equals(BED_DIFFERENCE_MORPH_WIDTH)) { | |
135 doBedDifferenceMorphWidthOut( | 113 doBedDifferenceMorphWidthOut( |
136 (BedDiffYearResult) bundle.getData(context), | 114 (BedDiffYearResult) bundle.getData(context), |
137 bundle, attr, visible); | 115 bundle, attr, visible); |
138 } | |
139 else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT1)) { | |
140 doBedDifferenceHeightsOut( | |
141 (BedDiffYearResult)bundle.getData(context), | |
142 bundle, attr, visible, 0); | |
143 } | |
144 else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT2)) { | |
145 doBedDifferenceHeightsOut( | |
146 (BedDiffYearResult)bundle.getData(context), | |
147 bundle, attr, visible, 1); | |
148 } | |
149 else if (name.equals(BED_DIFFERENCE_YEAR_FILTERED)) { | |
150 doBedDifferenceYearOut( | |
151 (BedDiffYearResult) bundle.getData(context), | |
152 bundle, attr, visible); | |
153 } | |
154 else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED)) { | |
155 doBedDifferenceHeightsOut( | |
156 (BedDiffYearResult)bundle.getData(context), | |
157 bundle, attr, visible, 0); | |
158 } | |
159 else if (name.equals(BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED)) { | |
160 doBedDifferenceHeightsOut( | |
161 (BedDiffYearResult)bundle.getData(context), | |
162 bundle, attr, visible, 1); | |
163 } | 116 } |
164 else if (name.equals(MORPHOLOGIC_WIDTH)) { | 117 else if (name.equals(MORPHOLOGIC_WIDTH)) { |
165 doMorphologicWidthOut( | 118 doMorphologicWidthOut( |
166 (MorphologicWidth)bundle.getData(context), | 119 (MorphologicWidth)bundle.getData(context), |
167 bundle, | 120 bundle, |
176 doAnnotations( | 129 doAnnotations( |
177 (RiverAnnotation) bundle.getData(context), | 130 (RiverAnnotation) bundle.getData(context), |
178 bundle, | 131 bundle, |
179 attr, | 132 attr, |
180 visible); | 133 visible); |
134 } | |
135 else if (bdyProcessor.canHandle(name)) { | |
136 bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.H.idx); | |
137 } | |
138 else if (bdhyProcessor.canHandle(name)) { | |
139 bdhyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx); | |
181 } | 140 } |
182 else if (woutp.canHandle(name)) { | 141 else if (woutp.canHandle(name)) { |
183 woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx); | 142 woutp.doOut(this, bundle, attr, visible, YAXIS.W.idx); |
184 } | 143 } |
185 else if (name.equals(W_DIFFERENCES)) { | 144 else if (name.equals(W_DIFFERENCES)) { |
204 StyledSeriesBuilder.addPoints(series, data.getAsArray(), true); | 163 StyledSeriesBuilder.addPoints(series, data.getAsArray(), true); |
205 | 164 |
206 addAxisSeries(series, YAXIS.M.idx, visible); | 165 addAxisSeries(series, YAXIS.M.idx, visible); |
207 } | 166 } |
208 | 167 |
209 private void doBedDifferenceHeightsOut( | |
210 BedDiffYearResult data, | |
211 ArtifactAndFacet bundle, | |
212 Document attr, | |
213 boolean visible, | |
214 int idx) { | |
215 logger.debug("doBedDifferenceYearOut()"); | |
216 | |
217 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr); | |
218 if (idx == 0) { | |
219 StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true); | |
220 } | |
221 else { | |
222 StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true); | |
223 } | |
224 | |
225 addAxisSeries(series, YAXIS.H.idx, visible); | |
226 } | |
227 | 168 |
228 @Override | 169 @Override |
229 protected String getDefaultChartTitle() { | 170 protected String getDefaultChartTitle() { |
230 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | 171 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); |
231 } | 172 } |
232 | 173 |
233 @Override | |
234 protected String getDefaultXAxisLabel() { | |
235 return msg(I18N_XAXIS_LABEL, | |
236 I18N_XAXIS_LABEL_DEFAULT, | |
237 new Object[] { getRiverName() }); | |
238 } | |
239 | 174 |
240 @Override | 175 @Override |
241 protected String getDefaultYAxisLabel(int pos) { | 176 protected String getDefaultYAxisLabel(int pos) { |
242 String label = "default"; | 177 String label = "default"; |
243 D4EArtifact flys = (D4EArtifact) master; | 178 D4EArtifact flys = (D4EArtifact) master; |
263 } | 198 } |
264 | 199 |
265 return label; | 200 return label; |
266 } | 201 } |
267 | 202 |
268 protected void doBedDifferenceYearOut(BedDiffYearResult data, | |
269 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
270 logger.debug("doBedDifferenceYearOut()"); | |
271 | |
272 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
273 StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true); | |
274 | |
275 addAxisSeries(series, YAXIS.D.idx, visible); | |
276 } | |
277 | 203 |
278 protected void doBedDifferenceMorphWidthOut(BedDiffYearResult data, | 204 protected void doBedDifferenceMorphWidthOut(BedDiffYearResult data, |
279 ArtifactAndFacet aandf, Document theme, boolean visible) { | 205 ArtifactAndFacet aandf, Document theme, boolean visible) { |
280 logger.debug("doBedDifferencesMorphWidthOut()"); | 206 logger.debug("doBedDifferencesMorphWidthOut()"); |
281 | 207 |
303 if (DataUtil.guessWaterIncreasing(wkms.allWs())) { | 229 if (DataUtil.guessWaterIncreasing(wkms.allWs())) { |
304 setInverted(true); | 230 setInverted(true); |
305 } | 231 } |
306 } | 232 } |
307 } | 233 } |
234 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |