comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 1041:c3902ff2d3bd

Added legend for annotations to LongitudinalSectionDiagram. flys-artifacts/trunk@2502 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 18 Aug 2011 13:46:10 +0000
parents 5411a33014e0
children 3067e700fc13
comparison
equal deleted inserted replaced
1040:5411a33014e0 1041:c3902ff2d3bd
11 import org.jfree.chart.plot.XYPlot; 11 import org.jfree.chart.plot.XYPlot;
12 import org.jfree.chart.title.TextTitle; 12 import org.jfree.chart.title.TextTitle;
13 import org.jfree.data.Range; 13 import org.jfree.data.Range;
14 import org.jfree.data.xy.XYSeries; 14 import org.jfree.data.xy.XYSeries;
15 import org.jfree.ui.TextAnchor; 15 import org.jfree.ui.TextAnchor;
16 import org.jfree.data.xy.XYSeriesCollection;
16 17
17 import org.w3c.dom.Document; 18 import org.w3c.dom.Document;
18 19
19 import de.intevation.artifacts.Artifact; 20 import de.intevation.artifacts.Artifact;
20 21
43 Logger.getLogger(LongitudinalSectionGenerator.class); 44 Logger.getLogger(LongitudinalSectionGenerator.class);
44 45
45 public static final String I18N_CHART_TITLE = 46 public static final String I18N_CHART_TITLE =
46 "chart.longitudinal.section.title"; 47 "chart.longitudinal.section.title";
47 48
49 public static final String I18N_ANNOTATIONS_LABEL =
50 "chart.longitudinal.annotations.label";
51
48 public static final String I18N_CHART_SUBTITLE = 52 public static final String I18N_CHART_SUBTITLE =
49 "chart.longitudinal.section.subtitle"; 53 "chart.longitudinal.section.subtitle";
50 54
51 public static final String I18N_XAXIS_LABEL = 55 public static final String I18N_XAXIS_LABEL =
52 "chart.longitudinal.section.xaxis.label"; 56 "chart.longitudinal.section.xaxis.label";
63 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; 67 public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]";
64 68
65 69
66 protected boolean inverted; 70 protected boolean inverted;
67 71
72 /** List of annotations to insert in plot. */
68 protected List<Annotation> annotations; 73 protected List<Annotation> annotations;
74
75 /** Pseudo-Dataseries to have a legend for the annotations. */
76 protected XYSeriesCollection pseudoAnnotationData = null;
77
69 78
70 public LongitudinalSectionGenerator() { 79 public LongitudinalSectionGenerator() {
71 super(); 80 super();
72 annotations = new ArrayList<Annotation>(); 81 annotations = new ArrayList<Annotation>();
73 } 82 }
233 242
234 /** 243 /**
235 * Register annotations available for the diagram. 244 * Register annotations available for the diagram.
236 * 245 *
237 * @param o list of annotations (data of facet). 246 * @param o list of annotations (data of facet).
238 * @param theme ignored. 247 * @param theme yet ignored.
239 */ 248 */
240 protected void doAnnotationsOut(Object o, Document theme) { 249 protected void doAnnotationsOut(Object o, Document theme) {
241 logger.debug("LongitudinalSectionGenerator.doAnnotationsOut"); 250 logger.debug("LongitudinalSectionGenerator.doAnnotationsOut");
242 this.annotations = (List<Annotation>) o; 251 this.annotations = (List<Annotation>) o;
252
253 // Add (empty) pseudo series.
254 if (pseudoAnnotationData == null) {
255 pseudoAnnotationData = new XYSeriesCollection();
256 }
257 // Localized legend.
258 Object[] args = new Object[] {getRiverName()};
259 String label = msg(I18N_ANNOTATIONS_LABEL, "", args);
260 pseudoAnnotationData.addSeries(new StyledXYSeries(label, theme));
243 } 261 }
244 262
245 263
246 /** 264 /**
247 * Process the output for W facets in a longitudinal section curve. 265 * Process the output for W facets in a longitudinal section curve.
309 setInverted(true); 327 setInverted(true);
310 } 328 }
311 } 329 }
312 330
313 331
332 /**
333 * Add datasets to plot.
334 * @param plot plot to add datasets to.
335 */
336 @Override
337 protected void addDatasets(XYPlot plot) {
338 super.addDatasets(plot);
339 if (pseudoAnnotationData != null) {
340 plot.setDataset(2, pseudoAnnotationData);
341 }
342 }
343
344
345 /**
346 * Get name of series (displayed in legend).
347 * @return name of the series.
348 */
314 protected String getSeriesName(WQKms wqkms, String mode) { 349 protected String getSeriesName(WQKms wqkms, String mode) {
315 String name = wqkms.getName(); 350 String name = wqkms.getName();
316 String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode; 351 String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode;
317 352
318 return prefix != null && prefix.length() > 0 353 return prefix != null && prefix.length() > 0

http://dive4elements.wald.intevation.org