comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 3409:97ad960f5579

Add subtitle to Fix W/Q chart and refactor addSubtitle() method(s) flys-artifacts/trunk@5062 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Thu, 19 Jul 2012 12:59:56 +0000
parents 45af081061e7
children 118fe1cc8cc8
comparison
equal deleted inserted replaced
3408:50d61a2494cb 3409:97ad960f5579
51 import org.jfree.chart.annotations.XYLineAnnotation; 51 import org.jfree.chart.annotations.XYLineAnnotation;
52 import org.jfree.chart.annotations.XYTextAnnotation; 52 import org.jfree.chart.annotations.XYTextAnnotation;
53 import org.jfree.chart.axis.NumberAxis; 53 import org.jfree.chart.axis.NumberAxis;
54 import org.jfree.chart.plot.XYPlot; 54 import org.jfree.chart.plot.XYPlot;
55 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; 55 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
56 import org.jfree.chart.title.TextTitle;
56 import org.jfree.data.Range; 57 import org.jfree.data.Range;
57 import org.jfree.data.general.Series; 58 import org.jfree.data.general.Series;
58 import org.jfree.data.xy.XYDataset; 59 import org.jfree.data.xy.XYDataset;
59 import org.jfree.ui.RectangleInsets; 60 import org.jfree.ui.RectangleInsets;
60 import org.jfree.ui.TextAnchor; 61 import org.jfree.ui.TextAnchor;
568 569
569 protected abstract void setYBounds(int axis, Bounds bounds); 570 protected abstract void setYBounds(int axis, Bounds bounds);
570 571
571 572
572 /** 573 /**
573 * This method should be used by concrete subclasses to add subtitle to 574 * This method retrieves the chart subtitle by calling getChartSubtitle()
574 * <i>chart</i>. <b>The method in this implementation is empty</b>. 575 * and adds it as TextTitle to the chart.
576 * The default implementation of getChartSubtitle() returns the same
577 * as getDefaultChartSubtitle() which must be implemented by derived
578 * classes. If you want to add multiple subtitles to the chart override
579 * this method and add your subtitles manually.
575 * 580 *
576 * @param chart The JFreeChart chart object. 581 * @param chart The JFreeChart chart object.
577 */ 582 */
578 protected void addSubtitles(JFreeChart chart) { 583 protected void addSubtitles(JFreeChart chart) {
579 // do nothing 584 String subtitle = getChartSubtitle();
585
586 if (subtitle != null && subtitle.length() > 0) {
587 chart.addSubtitle(new TextTitle(subtitle));
588 }
580 } 589 }
581 590
582 591
583 /** 592 /**
584 * Register annotations like MainValues for later plotting 593 * Register annotations like MainValues for later plotting

http://dive4elements.wald.intevation.org