comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java @ 1107:86ca3c10523f

Adjust the format of axes labels in histograms corresponding the specified locale (issue316). gnv-artifacts/trunk@1238 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 29 Jun 2010 07:37:36 +0000
parents 79401c871da4
children f953c9a559d8
comparison
equal deleted inserted replaced
1106:8ce8979f51df 1107:86ca3c10523f
5 import org.apache.log4j.Logger; 5 import org.apache.log4j.Logger;
6 6
7 import org.jfree.chart.ChartFactory; 7 import org.jfree.chart.ChartFactory;
8 import org.jfree.chart.ChartTheme; 8 import org.jfree.chart.ChartTheme;
9 import org.jfree.chart.JFreeChart; 9 import org.jfree.chart.JFreeChart;
10
11 import org.jfree.chart.axis.NumberAxis;
12 import org.jfree.chart.axis.TickUnitSource;
10 13
11 import org.jfree.chart.plot.PlotOrientation; 14 import org.jfree.chart.plot.PlotOrientation;
12 import org.jfree.chart.plot.XYPlot; 15 import org.jfree.chart.plot.XYPlot;
13 16
14 import org.jfree.chart.renderer.xy.XYBarRenderer; 17 import org.jfree.chart.renderer.xy.XYBarRenderer;
89 92
90 applyDatasets(); 93 applyDatasets();
91 94
92 theme.apply(chart); 95 theme.apply(chart);
93 adjustPlot(); 96 adjustPlot();
97 adjustDomainAxis(chart);
98 adjustRangeAxis(chart);
94 99
95 return chart; 100 return chart;
96 } 101 }
97 102
98 103
106 renderer.setShadowVisible(false); 111 renderer.setShadowVisible(false);
107 renderer.setSeriesVisibleInLegend(0, false); 112 renderer.setSeriesVisibleInLegend(0, false);
108 } 113 }
109 114
110 115
116 protected void adjustDomainAxis(JFreeChart chart) {
117 XYPlot plot = (XYPlot) chart.getPlot();
118 NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
119
120 TickUnitSource tus = domainAxis.createStandardTickUnits(locale);
121 domainAxis.setStandardTickUnits(tus);
122 }
123
124
125 protected void adjustRangeAxis(JFreeChart chart) {
126 XYPlot plot = (XYPlot) chart.getPlot();
127 NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
128
129 TickUnitSource tus = rangeAxis.createStandardTickUnits(locale);
130 rangeAxis.setStandardTickUnits(tus);
131 }
132
133
134
135
111 /** 136 /**
112 * This method needs to be implemented by subclasses and should add valid 137 * This method needs to be implemented by subclasses and should add valid
113 * <code>HistogramDataset</code> objects to the created chart. It is called 138 * <code>HistogramDataset</code> objects to the created chart. It is called
114 * by {@link #generateChart} after chart creation. 139 * by {@link #generateChart} after chart creation.
115 */ 140 */

http://dive4elements.wald.intevation.org