Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java @ 8074:bd0dfa57b1fe
flys/issue1262: Introduce variable $RADIUS to be used in user defined chart sub titles.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 07 Aug 2014 17:24:33 +0200 |
parents | 5eb8cd9201d8 |
children | e1b49fc9d2b5 |
comparison
equal
deleted
inserted
replaced
8071:6e6506ec0ae0 | 8074:bd0dfa57b1fe |
---|---|
129 "/art:action/art:attributes/art:xrange"; | 129 "/art:action/art:attributes/art:xrange"; |
130 | 130 |
131 public static final String XPATH_CHART_Y_RANGE = | 131 public static final String XPATH_CHART_Y_RANGE = |
132 "/art:action/art:attributes/art:yrange"; | 132 "/art:action/art:attributes/art:yrange"; |
133 | 133 |
134 public static final String I18N_SUBTITLE_RADIUS = | |
135 "chart.subtitle.radius"; | |
134 | 136 |
135 /** The document of the incoming out() request.*/ | 137 /** The document of the incoming out() request.*/ |
136 protected Document request; | 138 protected Document request; |
137 | 139 |
138 /** The output stream where the data should be written to.*/ | 140 /** The output stream where the data should be written to.*/ |
670 } | 672 } |
671 | 673 |
672 return getDefaultChartTitle(); | 674 return getDefaultChartTitle(); |
673 } | 675 } |
674 | 676 |
677 protected String interpolateVariables(String s) { | |
678 | |
679 Object radius = context.getContextValue("radius"); | |
680 if (radius instanceof Double) { | |
681 String txt = Resources.getMsg( | |
682 context.getMeta(), | |
683 I18N_SUBTITLE_RADIUS, | |
684 new Object[] { radius }); | |
685 | |
686 return s.replace("$RADIUS", txt); | |
687 | |
688 } | |
689 return s; | |
690 } | |
675 | 691 |
676 /** | 692 /** |
677 * Returns the subtitle of a chart. The return value depends on the | 693 * Returns the subtitle of a chart. The return value depends on the |
678 * existence of ChartSettings: if there are ChartSettings set, this method | 694 * existence of ChartSettings: if there are ChartSettings set, this method |
679 * returns the chart title provided by those settings. Otherwise, this | 695 * returns the chart title provided by those settings. Otherwise, this |
687 if (chartSettings != null) { | 703 if (chartSettings != null) { |
688 String subTitle = getChartSubtitle(chartSettings); | 704 String subTitle = getChartSubtitle(chartSettings); |
689 if (subTitle == null) { | 705 if (subTitle == null) { |
690 return getDefaultChartSubtitle(); | 706 return getDefaultChartSubtitle(); |
691 } | 707 } |
692 else { | 708 String defSubTitle = getDefaultChartSubtitle(); |
693 return subTitle; | 709 if (defSubTitle != null |
710 && !defSubTitle.isEmpty() | |
711 && !subTitle.equals(defSubTitle)) { | |
712 return interpolateVariables(defSubTitle); | |
694 } | 713 } |
714 return subTitle; | |
695 } | 715 } |
696 | 716 |
697 return getDefaultChartSubtitle(); | 717 return getDefaultChartSubtitle(); |
698 } | 718 } |
699 | 719 |