Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
8731:bccc476e78eb | 8732:c0c162d7cb0e |
---|---|
106 "/art:action/art:attributes/art:xrange"; | 106 "/art:action/art:attributes/art:xrange"; |
107 | 107 |
108 public static final String XPATH_CHART_Y_RANGE = | 108 public static final String XPATH_CHART_Y_RANGE = |
109 "/art:action/art:attributes/art:yrange"; | 109 "/art:action/art:attributes/art:yrange"; |
110 | 110 |
111 public static final String I18N_SUBTITLE_RADIUS = | |
112 "chart.subtitle.radius"; | |
113 | |
114 /** The document of the incoming out() request.*/ | 111 /** The document of the incoming out() request.*/ |
115 protected Document request; | 112 protected Document request; |
116 | 113 |
117 /** The output stream where the data should be written to.*/ | 114 /** The output stream where the data should be written to.*/ |
118 protected OutputStream out; | 115 protected OutputStream out; |
658 | 655 |
659 return getDefaultChartTitle(); | 656 return getDefaultChartTitle(); |
660 } | 657 } |
661 | 658 |
662 protected String interpolateVariables(String s) { | 659 protected String interpolateVariables(String s) { |
660 log.debug("Interpolate variables in string '" + s + "'"); | |
663 Object radius = context.getContextValue("radius"); | 661 Object radius = context.getContextValue("radius"); |
664 if (radius instanceof Double) { | 662 if (radius instanceof Double) { |
665 NumberFormat f = Formatter.getCSVFormatter(context); | 663 NumberFormat f = Formatter.getCSVFormatter(context); |
666 return s.replace("$RADIUS", f.format(radius)); | 664 s = s.replace("$RADIUS", f.format(radius) + " km"); |
667 } | 665 } |
666 else { | |
667 s = s.replace("$RADIUS", "-"); | |
668 } | |
669 | |
668 Object km = context.getContextValue(CURRENT_KM); | 670 Object km = context.getContextValue(CURRENT_KM); |
669 if (km instanceof Number && s.contains("$KM")) { | 671 if (km instanceof Number && s.contains("$KM")) { |
670 NumberFormat f = Formatter.getCalculationKm(context.getMeta()); | 672 NumberFormat f = Formatter.getCalculationKm(context.getMeta()); |
671 return s.replace("$KM", f.format(km)); | 673 s = s.replace("$KM", f.format(km)); |
672 } | 674 } |
675 | |
673 return s; | 676 return s; |
674 } | 677 } |
675 | 678 |
676 /** | 679 /** |
677 * Returns the subtitle of a chart. The return value depends on the | 680 * Returns the subtitle of a chart. The return value depends on the |