comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7806:7ac103a49e35 minfo-opt

Added subtitle parts to modify the chart subtitle via the outprocessor.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 07 Mar 2014 11:11:11 +0100
parents 25bce6e8beea
children 43f18dc56c5a e844be34a606
comparison
equal deleted inserted replaced
7805:8c20f16ab650 7806:7ac103a49e35
13 13
14 import java.text.NumberFormat; 14 import java.text.NumberFormat;
15 15
16 import java.util.ArrayList; 16 import java.util.ArrayList;
17 import java.util.HashMap; 17 import java.util.HashMap;
18 import java.util.HashSet;
18 import java.util.LinkedHashSet; 19 import java.util.LinkedHashSet;
19 import java.util.List; 20 import java.util.List;
20 import java.util.Map; 21 import java.util.Map;
21 import java.util.Set; 22 import java.util.Set;
22 23
117 118
118 protected Map<Integer, LinkedHashSet<String>> axesLabels; 119 protected Map<Integer, LinkedHashSet<String>> axesLabels;
119 120
120 protected DiagramAttributes.Instance diagramAttributes; 121 protected DiagramAttributes.Instance diagramAttributes;
121 122
123 protected HashSet<String> subTitleParts;
124
122 public DiagramGenerator() { 125 public DiagramGenerator() {
123 super(); 126 super();
124 127
125 axesLabels = new HashMap<Integer, LinkedHashSet<String>>(); 128 axesLabels = new HashMap<Integer, LinkedHashSet<String>>();
126 xBounds = new HashMap<Integer, Bounds>(); 129 xBounds = new HashMap<Integer, Bounds>();
127 yBounds = new HashMap<Integer, Bounds>(); 130 yBounds = new HashMap<Integer, Bounds>();
131 subTitleParts = new LinkedHashSet<String>();
128 } 132 }
129 133
130 @Override 134 @Override
131 public void setup(Object config) { 135 public void setup(Object config) {
132 136
1039 return dTitle.evaluate((D4EArtifact)getMaster(), context); 1043 return dTitle.evaluate((D4EArtifact)getMaster(), context);
1040 } 1044 }
1041 1045
1042 @Override 1046 @Override
1043 public String getDefaultChartSubtitle() { 1047 public String getDefaultChartSubtitle() {
1048 String parts = "";
1049 if (subTitleParts != null && !subTitleParts.isEmpty()) {
1050 for (String p : subTitleParts) {
1051 parts += ", " + p;
1052 }
1053 }
1044 DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle(); 1054 DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle();
1045 if (dTitle == null) { 1055 if (dTitle == null) {
1046 /* Subtitle is optional */ 1056 /* Subtitle is optional */
1047 return null; 1057 return null;
1048 } 1058 }
1049 1059 return dTitle.evaluate((D4EArtifact)getMaster(), context) + parts;
1050 return dTitle.evaluate((D4EArtifact)getMaster(), context);
1051 } 1060 }
1052 1061
1053 /** 1062 /**
1054 * Get internationalized label for the x axis. 1063 * Get internationalized label for the x axis.
1055 */ 1064 */
1221 if (diagramAttributes.getAxesAttributes().get(index).includeZero()) { 1230 if (diagramAttributes.getAxesAttributes().get(index).includeZero()) {
1222 axis.setAutoRangeIncludesZero(true); 1231 axis.setAutoRangeIncludesZero(true);
1223 } 1232 }
1224 return axis; 1233 return axis;
1225 } 1234 }
1235
1236 /**
1237 * @return the subtitle parts
1238 */
1239 public HashSet<String> getSubTitleParts() {
1240 return subTitleParts;
1241 }
1242
1243 /**
1244 * @param part the subtitle part to set
1245 */
1246 public void addSubtitle(String part) {
1247 this.subTitleParts.add(part);
1248 }
1226 } 1249 }

http://dive4elements.wald.intevation.org