Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java @ 1054:8430269ec73b
Removed the parsing for double/integer values specifying the bin width or the number of bins in DefaultHistogram, because these inserted values are no longer i18n strings (issue289).
gnv-artifacts/trunk@1128 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 26 May 2010 17:01:29 +0000 |
parents | 22c18083225e |
children | bb2679624c6a |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java Wed May 26 07:00:55 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/DefaultHistogram.java Wed May 26 17:01:29 2010 +0000 @@ -51,12 +51,6 @@ public static final String REQUEST_KEY_CHART_WIDTH = "width"; /** - * Default key to retrieve the <code>Locale</code> object from {@link - * #requestParameter} used for i18n support. - */ - public static final String REQUEST_KEY_LOCALE = "locale"; - - /** * Default key to retrieve the object from {@link #requestParameter}. It * defines which value this chart has to be used for bin calculation. You * can either adjust the number of bins or the width of a single bin. @@ -212,51 +206,18 @@ protected int getBinCountByWidth(double[] values) { int bins = -1; String param = (String) requestParameter.get(REQUEST_KEY_BIN_WIDTH); - Locale locale = (Locale) requestParameter.get(REQUEST_KEY_LOCALE); - NumberFormat format = NumberFormat.getInstance(locale); - - try { - double[] minmax = getMinMax(values); - double totalWidth = minmax[1] - minmax[0]; - Number number = format.parse(param); - double binWidth = -1d; - - if (number instanceof Double) { - binWidth = ((Double) number).doubleValue(); - } - else if (number instanceof Long) { - binWidth = ((Long) number).doubleValue(); - } - else if (number instanceof Integer) { - binWidth = ((Integer) number).doubleValue(); - } - else { - logger.warn("Invalid bin width for histogram chart: " + param); - logger.warn("Return default bins: " + DEFAULT_BINS); - return DEFAULT_BINS; - } - - double tmpBins = totalWidth / binWidth; - - bins = (int) Math.round(tmpBins); - bins = bins <= 0 ? DEFAULT_BINS : bins; - bins = bins > MAXIMAL_BINS ? MAXIMAL_BINS : bins; + double[] minmax = getMinMax(values); + double totalWidth = minmax[1] - minmax[0]; + double binWidth = Double.parseDouble(param); - return bins; - } - catch (ParseException pe) { - logger.warn("Invalid bin width for histogram chart: " + param); - logger.warn("Return default bins: " + DEFAULT_BINS); + double tmpBins = totalWidth / binWidth; - return DEFAULT_BINS; - } - catch (NumberFormatException nfe) { - logger.warn("Invalid bin width for histogram chart: " + param); - logger.warn("Return default bins: " + DEFAULT_BINS); + bins = (int) Math.round(tmpBins); + bins = bins <= 0 ? DEFAULT_BINS : bins; + bins = bins > MAXIMAL_BINS ? MAXIMAL_BINS : bins; - return DEFAULT_BINS; - } + return bins; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :