Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java @ 8732:c0c162d7cb0e
(issue1754) Handle the case if no radius is given.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 30 Apr 2015 18:13:15 +0200 |
parents | 8c60595fd74c |
children | 5e38e2924c07 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Thu Apr 30 17:11:59 2015 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Thu Apr 30 18:13:15 2015 +0200 @@ -108,9 +108,6 @@ public static final String XPATH_CHART_Y_RANGE = "/art:action/art:attributes/art:yrange"; - public static final String I18N_SUBTITLE_RADIUS = - "chart.subtitle.radius"; - /** The document of the incoming out() request.*/ protected Document request; @@ -660,16 +657,22 @@ } protected String interpolateVariables(String s) { + log.debug("Interpolate variables in string '" + s + "'"); Object radius = context.getContextValue("radius"); if (radius instanceof Double) { NumberFormat f = Formatter.getCSVFormatter(context); - return s.replace("$RADIUS", f.format(radius)); + s = s.replace("$RADIUS", f.format(radius) + " km"); } + else { + s = s.replace("$RADIUS", "-"); + } + Object km = context.getContextValue(CURRENT_KM); if (km instanceof Number && s.contains("$KM")) { NumberFormat f = Formatter.getCalculationKm(context.getMeta()); - return s.replace("$KM", f.format(km)); + s = s.replace("$KM", f.format(km)); } + return s; }