comparison artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java @ 9104:07d51fd4864c

Added metadata subtitle to all chart export
author gernotbelger
date Tue, 29 May 2018 11:35:44 +0200
parents 3ac9cb0029b2
children 1cc7653ca84f
comparison
equal deleted inserted replaced
9103:e68d4a10c308 9104:07d51fd4864c
78 /** 78 /**
79 * Implementation of the OutGenerator interface for charts. 79 * Implementation of the OutGenerator interface for charts.
80 * It should provide some basic things that equal in all chart types. 80 * It should provide some basic things that equal in all chart types.
81 * 81 *
82 */ 82 */
83 public abstract class ChartGenerator2 implements OutGenerator { 83 // FIXME: copy/paste of ChartGenerator with LOTS of duplicate code... move duplicates to AbstractChartGenrator!
84 public abstract class ChartGenerator2 extends AbstractChartGenerator {
84 85
85 private static Logger log = Logger.getLogger(ChartGenerator2.class); 86 private static Logger log = Logger.getLogger(ChartGenerator2.class);
86 87
87 public static final boolean USE_NOP_GRAPHICS = 88 public static final boolean USE_NOP_GRAPHICS =
88 Boolean.getBoolean("info.rendering.nop.graphics"); 89 Boolean.getBoolean("info.rendering.nop.graphics");
144 145
145 /** 146 /**
146 * Default constructor that initializes internal data structures. 147 * Default constructor that initializes internal data structures.
147 */ 148 */
148 public ChartGenerator2() { 149 public ChartGenerator2() {
149 datasets = new TreeMap<Integer, AxisDataset>(); 150 datasets = new TreeMap<>();
150 yAnnotations = new TreeMap<Integer, RiverAnnotation>(); 151 yAnnotations = new TreeMap<>();
152 }
153
154 @Override
155 protected final D4EArtifact getArtifact() {
156 // FIXME: should already made sure when this member is set
157 return (D4EArtifact) this.master;
158 }
159
160 @Override
161 protected final CallContext getContext() {
162 return this.context;
163 }
164
165 @Override
166 protected final Document getRequest() {
167 return this.request;
151 } 168 }
152 169
153 /** 170 /**
154 * Adds annotations to list. The given annotation will be visible. 171 * Adds annotations to list. The given annotation will be visible.
155 */ 172 */
261 278
262 if (subtitle != null && subtitle.length() > 0) { 279 if (subtitle != null && subtitle.length() > 0) {
263 chart.addSubtitle(new TextTitle(subtitle)); 280 chart.addSubtitle(new TextTitle(subtitle));
264 } 281 }
265 } 282 }
266 283
267 /** 284 /**
268 * Generate chart. 285 * Generate chart.
269 */ 286 */
270 @Override 287 @Override
271 public void generate() throws IOException { 288 public void generate() throws IOException {
1089 1106
1090 public String msg(String key, String def, Object[] args) { 1107 public String msg(String key, String def, Object[] args) {
1091 return Resources.getMsg(context.getMeta(), key, def, args); 1108 return Resources.getMsg(context.getMeta(), key, def, args);
1092 } 1109 }
1093 1110
1094
1095 protected String getRiverName() {
1096 D4EArtifact flys = (D4EArtifact) master;
1097
1098 River river = RiverUtils.getRiver(flys);
1099 return (river != null) ? river.getName() : "";
1100 }
1101
1102
1103 protected double[] getRange() {
1104 D4EArtifact flys = (D4EArtifact) master;
1105
1106 RangeAccess rangeAccess = new RangeAccess(flys);
1107 return rangeAccess.getKmRange();
1108 }
1109
1110
1111 /** 1111 /**
1112 * Returns the size of a chart export as array which has been specified by 1112 * Returns the size of a chart export as array which has been specified by
1113 * the incoming request document. 1113 * the incoming request document.
1114 * 1114 *
1115 * @return the size of a chart as [width, height] or null if no width or 1115 * @return the size of a chart as [width, height] or null if no width or
1161 1161
1162 return format == null || format.length() == 0 1162 return format == null || format.length() == 0
1163 ? DEFAULT_CHART_FORMAT 1163 ? DEFAULT_CHART_FORMAT
1164 : format; 1164 : format;
1165 } 1165 }
1166
1167 1166
1168 /** 1167 /**
1169 * Returns the X-Axis range as String array from request document. 1168 * Returns the X-Axis range as String array from request document.
1170 * If the (x|y)range elements are not found in request document, return 1169 * If the (x|y)range elements are not found in request document, return
1171 * null (i.e. not zoomed). 1170 * null (i.e. not zoomed).

http://dive4elements.wald.intevation.org