comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java @ 657:af3f56758f59

merged gnv-artifacts/0.5
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:53 +0200
parents 65f09139e9b3
children 79401c871da4
comparison
equal deleted inserted replaced
590:5f5f273c8566 657:af3f56758f59
1 package de.intevation.gnv.chart;
2
3 import java.util.Locale;
4
5 import org.apache.log4j.Logger;
6
7 import org.jfree.chart.ChartFactory;
8 import org.jfree.chart.ChartTheme;
9 import org.jfree.chart.JFreeChart;
10
11 import org.jfree.chart.plot.PlotOrientation;
12 import org.jfree.chart.plot.XYPlot;
13
14 import org.jfree.chart.renderer.xy.XYBarRenderer;
15
16 /**
17 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
18 */
19 public abstract class AbstractHistogram
20 implements Chart
21 {
22 private Logger logger = Logger.getLogger(AbstractHistogram.class);
23
24 protected JFreeChart chart;
25 protected ChartLabels labels;
26 protected ChartTheme theme;
27 protected Object[] data;
28
29 protected Locale locale;
30
31
32 public AbstractHistogram(
33 ChartLabels labels, Object[] data, ChartTheme theme
34 ) {
35 this.labels = labels;
36 this.data = data;
37 this.theme = theme;
38 }
39
40
41 public JFreeChart generateChart() {
42
43 if (chart != null)
44 return chart;
45
46 chart = ChartFactory.createHistogram(
47 labels.getTitle(),
48 labels.getDomainAxisLabel(),
49 labels.getRangeAxisLabel(),
50 null,
51 PlotOrientation.VERTICAL,
52 true,
53 false,
54 false);
55
56 applyDatasets();
57
58 theme.apply(chart);
59 adjustPlot();
60
61 return chart;
62 }
63
64
65 protected void adjustPlot() {
66 XYPlot plot = (XYPlot) chart.getPlot();
67 XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
68
69 renderer.setShadowVisible(false);
70 renderer.setSeriesVisibleInLegend(0, false);
71 }
72
73
74 protected abstract void applyDatasets();
75 }
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org