comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 1645:4a8251eae217

Bugfix: #68 Set number format of chart plot axes based on the CallMeta instance for each request. flys-artifacts/trunk@2832 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 27 Sep 2011 10:06:19 +0000
parents 0221451a24fe
children 69929c471646
comparison
equal deleted inserted replaced
1644:2df1f9facd6c 1645:4a8251eae217
3 import java.awt.BasicStroke; 3 import java.awt.BasicStroke;
4 import java.awt.Color; 4 import java.awt.Color;
5 import java.awt.Stroke; 5 import java.awt.Stroke;
6 6
7 import java.io.IOException; 7 import java.io.IOException;
8
9 import java.text.NumberFormat;
8 10
9 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
10 12
11 import org.jfree.chart.ChartFactory; 13 import org.jfree.chart.ChartFactory;
12 import org.jfree.chart.JFreeChart; 14 import org.jfree.chart.JFreeChart;
105 107
106 addDatasets(plot); 108 addDatasets(plot);
107 addSubtitles(chart); 109 addSubtitles(chart);
108 adjustPlot(plot); 110 adjustPlot(plot);
109 adjustAxes(plot); 111 adjustAxes(plot);
112 localizeAxes(plot);
110 113
111 removeEmptyRangeAxes(plot); 114 removeEmptyRangeAxes(plot);
112 115
113 autoZoom(plot); 116 autoZoom(plot);
114 117
333 protected void addSubtitles(JFreeChart chart) { 336 protected void addSubtitles(JFreeChart chart) {
334 // override this method in subclasses that need subtitles 337 // override this method in subclasses that need subtitles
335 } 338 }
336 339
337 340
341 /**
342 * This method walks over all axes (domain and range) of <i>plot</i> and
343 * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for
344 * range axes.
345 *
346 * @param plot The XYPlot.
347 */
348 private void localizeAxes(XYPlot plot) {
349 for (int i = 0, num = plot.getDomainAxisCount(); i < num; i++) {
350 ValueAxis axis = plot.getDomainAxis(i);
351
352 if (axis != null) {
353 localizeDomainAxis(axis);
354 }
355 else {
356 logger.warn("Domain axis at " + i + " is null.");
357 }
358 }
359
360 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
361 ValueAxis axis = plot.getRangeAxis(i);
362
363 if (axis != null) {
364 localizeRangeAxis(axis);
365 }
366 else {
367 logger.warn("Range axis at " + i + " is null.");
368 }
369 }
370 }
371
372
373 /**
374 * Overrides the NumberFormat with the NumberFormat for the current locale
375 * that is provided by getLocale().
376 *
377 * @param domainAxis The domain axis that needs localization.
378 */
379 protected void localizeDomainAxis(ValueAxis domainAxis) {
380 NumberFormat nf = NumberFormat.getInstance(getLocale());
381 ((NumberAxis) domainAxis).setNumberFormatOverride(nf);
382 }
383
384
385 /**
386 * Overrides the NumberFormat with the NumberFormat for the current locale
387 * that is provided by getLocale().
388 *
389 * @param domainAxis The domain axis that needs localization.
390 */
391 protected void localizeRangeAxis(ValueAxis rangeAxis) {
392 NumberFormat nf = NumberFormat.getInstance(getLocale());
393 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf);
394 }
395
396
338 protected void applyThemes(XYPlot plot) { 397 protected void applyThemes(XYPlot plot) {
339 if (first != null) { 398 if (first != null) {
340 applyThemes(plot, first, 0); 399 applyThemes(plot, first, 0);
341 } 400 }
342 401

http://dive4elements.wald.intevation.org