comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1941:0fa53fa65401

Fix LongitudinalSections multi-axes plotting behavior. flys-artifacts/trunk@3322 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 28 Nov 2011 14:38:46 +0000
parents 0ad05cb691fc
children 21a4d2c677a1
comparison
equal deleted inserted replaced
1940:0d12e70766c8 1941:0fa53fa65401
187 else if (index == YAXIS.D.idx) { 187 else if (index == YAXIS.D.idx) {
188 // TODO: diff label 188 // TODO: diff label
189 label = "TODO: diff"; 189 label = "TODO: diff";
190 } 190 }
191 NumberAxis axis = new NumberAxis(label); 191 NumberAxis axis = new NumberAxis(label);
192 // "Q" Axis shall include 0.
193 if (index == YAXIS.Q.idx) {
194 axis.setAutoRangeIncludesZero(true);
195 }
196 else {
197 axis.setAutoRangeIncludesZero(false);
198 }
192 axis.setLabelFont(labelFont); 199 axis.setLabelFont(labelFont);
193 return axis; 200 return axis;
194 } 201 }
195 202
196 /** 203 /**
215 */ 222 */
216 @Override 223 @Override
217 protected void adjustAxes(XYPlot plot) { 224 protected void adjustAxes(XYPlot plot) {
218 super.adjustAxes(plot); 225 super.adjustAxes(plot);
219 invertXAxis(plot.getDomainAxis()); 226 invertXAxis(plot.getDomainAxis());
220 }
221
222
223 /**
224 * Create a range that includes 0 (for the Q axis).
225 * @param range range with which to look up upper bound.
226 * @return range with 0 included.
227 */
228 protected Range createSecondAxisRange(Range range) {
229 if (range == null) {
230 return null;
231 }
232 return new Range(0d, range.getUpperBound());
233 }
234
235
236 /**
237 * This method overrides the XYChartGenerators zoomY method to be able to
238 * modify the range of the Q axis (here, it shall include 0).
239 */
240 @Override
241 protected boolean zoomY(XYPlot plot, ValueAxis axis, Range range, Range x) {
242 if (plot.getRangeAxisIndex(axis) == 1) {
243 // We want the Q axis to start at 0 if no zooming has been done.
244 range = createSecondAxisRange(range);
245 }
246
247 return super.zoomY(plot, axis, range, x);
248 } 227 }
249 228
250 229
251 /** 230 /**
252 * This method inverts the x-axis based on the kilometer information of the 231 * This method inverts the x-axis based on the kilometer information of the

http://dive4elements.wald.intevation.org