# HG changeset patch # User Sascha L. Teichmann # Date 1407425073 -7200 # Node ID bd0dfa57b1fe92673bf6a550d3b8a5b8983d0c0c # Parent 6e6506ec0ae00b55c996b157adfb5202c1be3213 flys/issue1262: Introduce variable $RADIUS to be used in user defined chart sub titles. diff -r 6e6506ec0ae0 -r bd0dfa57b1fe artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Tue Aug 05 18:28:04 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Thu Aug 07 17:24:33 2014 +0200 @@ -131,6 +131,8 @@ 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; @@ -672,6 +674,20 @@ return getDefaultChartTitle(); } + protected String interpolateVariables(String s) { + + Object radius = context.getContextValue("radius"); + if (radius instanceof Double) { + String txt = Resources.getMsg( + context.getMeta(), + I18N_SUBTITLE_RADIUS, + new Object[] { radius }); + + return s.replace("$RADIUS", txt); + + } + return s; + } /** * Returns the subtitle of a chart. The return value depends on the @@ -689,9 +705,13 @@ if (subTitle == null) { return getDefaultChartSubtitle(); } - else { - return subTitle; + String defSubTitle = getDefaultChartSubtitle(); + if (defSubTitle != null + && !defSubTitle.isEmpty() + && !subTitle.equals(defSubTitle)) { + return interpolateVariables(defSubTitle); } + return subTitle; } return getDefaultChartSubtitle(); diff -r 6e6506ec0ae0 -r bd0dfa57b1fe artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java Tue Aug 05 18:28:04 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WDiffProcessor.java Thu Aug 07 17:24:33 2014 +0200 @@ -45,8 +45,9 @@ ZoomScale scales = (ZoomScale)fc.get("zoomscale"); RiverAccess access = new RiverAccess((D4EArtifact)artifact); String river = access.getRiverName(); + double radius = scales.getRadius(river, start, end); + context.putContextValue("radius", radius); - double radius = scales.getRadius(river, start, end); generator.addSubtitle(Resources.getMsg( context.getMeta(), I18N_SUBTITLE_RADIUS,