annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java @ 622:89aca25642d6

Implemented method stubs of MapfileGenerator. Mapfiles are successfully created corresponding meta.xml files. gnv-artifacts/trunk@693 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 19 Feb 2010 13:28:34 +0000
parents 3d13fa281a7e
children 65f09139e9b3
rev   line source
617
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.chart;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.Locale;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.jfree.chart.ChartFactory;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.jfree.chart.ChartTheme;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.jfree.chart.JFreeChart;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.jfree.chart.axis.NumberAxis;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.jfree.chart.plot.PlotOrientation;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.jfree.chart.plot.XYPlot;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.jfree.chart.renderer.xy.XYBarRenderer;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.jfree.data.statistics.HistogramDataset;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 /**
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 */
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 public abstract class AbstractHistogram
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 implements Chart
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 {
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 private Logger logger = Logger.getLogger(AbstractHistogram.class);
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 protected JFreeChart chart;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 protected ChartLabels labels;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 protected ChartTheme theme;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 protected Object[] data;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 protected Locale locale;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public AbstractHistogram(
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 ChartLabels labels, Object[] data, ChartTheme theme
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 ) {
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 this.labels = labels;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 this.data = data;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 this.theme = theme;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 }
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 public JFreeChart generateChart() {
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 if (chart != null)
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 return chart;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 chart = ChartFactory.createHistogram(
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 labels.getTitle(),
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 labels.getDomainAxisLabel(),
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 labels.getRangeAxisLabel(),
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 null,
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 PlotOrientation.VERTICAL,
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 true,
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 false,
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 false);
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 applyDatasets();
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 theme.apply(chart);
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 adjustPlot();
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 return chart;
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 }
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 protected void adjustPlot() {
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 XYPlot plot = (XYPlot) chart.getPlot();
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 renderer.setShadowVisible(false);
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 renderer.setSeriesVisibleInLegend(0, false);
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 protected abstract void applyDatasets();
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
3d13fa281a7e Added new ouput mode: histogram.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org