Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2051:4ba5036109d2
Make use of user defined axes labels during chart creation.
flys-artifacts/trunk@3541 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 27 Dec 2011 07:52:25 +0000 |
parents | c4e0e433f825 |
children | c7f18fa0d685 |
comparison
equal
deleted
inserted
replaced
2050:c4e0e433f825 | 2051:4ba5036109d2 |
---|---|
288 /** | 288 /** |
289 * Returns the X-Axis label of a chart. | 289 * Returns the X-Axis label of a chart. |
290 * | 290 * |
291 * @return the X-Axis label of a chart. | 291 * @return the X-Axis label of a chart. |
292 */ | 292 */ |
293 protected abstract String getXAxisLabel(); | 293 protected String getXAxisLabel() { |
294 | 294 ChartSettings chartSettings = getChartSettings(); |
295 | 295 if (chartSettings == null) { |
296 /** | 296 return getDefaultXAxisLabel(); |
297 * Returns the Y-Axis label of a chart. | 297 } |
298 * | 298 |
299 * @return the Y-Axis label of a chart. | 299 AxisSection as = chartSettings.getAxisSection("X"); |
300 */ | 300 if (as != null) { |
301 protected abstract String getYAxisLabel(); | 301 String label = as.getLabel(); |
302 | |
303 if (label != null) { | |
304 return label; | |
305 } | |
306 } | |
307 | |
308 return getDefaultXAxisLabel(); | |
309 } | |
310 | |
311 | |
312 /** | |
313 * Returns the default X-Axis label of a chart. | |
314 * | |
315 * @return the default X-Axis label of a chart. | |
316 */ | |
317 protected abstract String getDefaultXAxisLabel(); | |
302 | 318 |
303 | 319 |
304 /** | 320 /** |
305 * Returns the Y-Axis label of a chart at position <i>pos</i>. | 321 * Returns the Y-Axis label of a chart at position <i>pos</i>. |
306 * | 322 * |
307 * @return the Y-Axis label of a chart at position <i>0</i>. | 323 * @return the Y-Axis label of a chart at position <i>0</i>. |
308 */ | 324 */ |
309 protected String getYAxisLabel(int pos) { | 325 protected String getYAxisLabel(int pos) { |
310 return getYAxisLabel(); | 326 ChartSettings chartSettings = getChartSettings(); |
311 } | 327 if (chartSettings == null) { |
328 return getDefaultYAxisLabel(pos); | |
329 } | |
330 | |
331 YAxisWalker walker = getYAxisWalker(); | |
332 AxisSection as = chartSettings.getAxisSection(walker.getId(pos)); | |
333 if (as != null) { | |
334 String label = as.getLabel(); | |
335 | |
336 if (label != null) { | |
337 return label; | |
338 } | |
339 } | |
340 | |
341 return getDefaultYAxisLabel(pos); | |
342 } | |
343 | |
344 | |
345 /** | |
346 * This method is called to retrieve the default label for an Y axis at | |
347 * position <i>pos</i>. | |
348 * | |
349 * @param pos The position of an Y axis. | |
350 * | |
351 * @return the default Y axis label at position <i>pos</i>. | |
352 */ | |
353 protected abstract String getDefaultYAxisLabel(int pos); | |
354 | |
312 | 355 |
313 /** | 356 /** |
314 * Generate chart. | 357 * Generate chart. |
315 */ | 358 */ |
316 public void generate() | 359 public void generate() |
368 logger.debug("XYChartGenerator.generateChart"); | 411 logger.debug("XYChartGenerator.generateChart"); |
369 | 412 |
370 JFreeChart chart = ChartFactory.createXYLineChart( | 413 JFreeChart chart = ChartFactory.createXYLineChart( |
371 getChartTitle(), | 414 getChartTitle(), |
372 getXAxisLabel(), | 415 getXAxisLabel(), |
373 getYAxisLabel(), | 416 getYAxisLabel(0), |
374 null, | 417 null, |
375 PlotOrientation.VERTICAL, | 418 PlotOrientation.VERTICAL, |
376 isLegendVisible(), | 419 isLegendVisible(), |
377 false, | 420 false, |
378 false); | 421 false); |
584 /** | 627 /** |
585 * Create Y (range) axis for given index. | 628 * Create Y (range) axis for given index. |
586 * Shall be overriden by subclasses. | 629 * Shall be overriden by subclasses. |
587 */ | 630 */ |
588 protected NumberAxis createYAxis(int index) { | 631 protected NumberAxis createYAxis(int index) { |
589 NumberAxis axis = new NumberAxis(getYAxisLabel()); | 632 NumberAxis axis = new NumberAxis(getYAxisLabel(index)); |
590 axis.setAutoRangeIncludesZero(false); | 633 axis.setAutoRangeIncludesZero(false); |
591 return axis; | 634 return axis; |
592 } | 635 } |
593 | 636 |
594 | 637 |