Mercurial > dive4elements > gnv-client
changeset 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 | 8ce8979f51df |
children | 337727011de0 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java |
diffstat | 3 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Tue Jun 29 07:09:13 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue Jun 29 07:37:36 2010 +0000 @@ -1,3 +1,13 @@ +2010-06-29 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + Issue316 + + * src/main/java/de/intevation/gnv/chart/DefaultHistogram.java: Set the + specified locale in the constructor which is used to localize the axes. + + * src/main/java/de/intevation/gnv/chart/AbstractHistogram.java: Adjust the + localization of x and y axes corresponding the specified locale. + 2010-06-29 Ingo Weinzierl <ingo.weinzierl@intevation.de> Issue318
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java Tue Jun 29 07:09:13 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractHistogram.java Tue Jun 29 07:37:36 2010 +0000 @@ -8,6 +8,9 @@ import org.jfree.chart.ChartTheme; import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.TickUnitSource; + import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; @@ -91,6 +94,8 @@ theme.apply(chart); adjustPlot(); + adjustDomainAxis(chart); + adjustRangeAxis(chart); return chart; } @@ -108,6 +113,26 @@ } + protected void adjustDomainAxis(JFreeChart chart) { + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); + + TickUnitSource tus = domainAxis.createStandardTickUnits(locale); + domainAxis.setStandardTickUnits(tus); + } + + + protected void adjustRangeAxis(JFreeChart chart) { + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + + TickUnitSource tus = rangeAxis.createStandardTickUnits(locale); + rangeAxis.setStandardTickUnits(tus); + } + + + + /** * This method needs to be implemented by subclasses and should add valid * <code>HistogramDataset</code> objects to the created chart. It is called
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java Tue Jun 29 07:09:13 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java Tue Jun 29 07:37:36 2010 +0000 @@ -1,5 +1,6 @@ package de.intevation.gnv.chart; +import java.util.Locale; import java.util.Map; import org.apache.log4j.Logger; @@ -77,6 +78,7 @@ ) { super(labels, data, theme); this.requestParameter = requestParameter; + this.locale = (Locale) requestParameter.get("locale"); }