annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractChartGenerator.java @ 9524:9dc6427059b2

Added more metadata to chart exports
author gernotbelger
date Mon, 01 Oct 2018 17:45:43 +0200
parents 853f2dafc16e
children ef5754ba5573
rev   line source
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
2 * Software engineering by
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
5 *
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
9 */
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
10 package org.dive4elements.river.exports;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
11
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
12 import java.awt.BasicStroke;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
13 import java.awt.Color;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
14 import java.awt.Font;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
15 import java.awt.Stroke;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
16 import java.io.IOException;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
17 import java.io.OutputStream;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
18 import java.text.DateFormat;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
19 import java.util.ArrayList;
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
20 import java.util.Collection;
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
21 import java.util.Collections;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
22 import java.util.Date;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
23 import java.util.List;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
24 import java.util.Locale;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
25 import java.util.Map;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
26 import java.util.SortedMap;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
27 import java.util.TreeMap;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
28
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
29 import javax.xml.xpath.XPathConstants;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
30
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
31 import org.apache.commons.lang.StringUtils;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
32 import org.apache.log4j.Logger;
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
33 import org.dive4elements.artifactdatabase.CollectionCallContext;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
34 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
35 import org.dive4elements.artifactdatabase.state.Settings;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
36 import org.dive4elements.artifacts.Artifact;
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
37 import org.dive4elements.artifacts.ArtifactCollection;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
38 import org.dive4elements.artifacts.ArtifactNamespaceContext;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
39 import org.dive4elements.artifacts.CallContext;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
40 import org.dive4elements.artifacts.CallMeta;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
41 import org.dive4elements.artifacts.PreferredLocale;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
42 import org.dive4elements.artifacts.common.utils.XMLUtils;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
43 import org.dive4elements.river.FLYS;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
44 import org.dive4elements.river.artifacts.D4EArtifact;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
45 import org.dive4elements.river.artifacts.access.RangeAccess;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
46 import org.dive4elements.river.artifacts.access.RiverAccess;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
47 import org.dive4elements.river.artifacts.resources.Resources;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
48 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
49 import org.dive4elements.river.collections.D4EArtifactCollection;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
50 import org.dive4elements.river.jfree.AxisDataset;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
51 import org.dive4elements.river.jfree.Bounds;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
52 import org.dive4elements.river.jfree.DoubleBounds;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
53 import org.dive4elements.river.jfree.EnhancedLineAndShapeRenderer;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
54 import org.dive4elements.river.jfree.RiverAnnotation;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
55 import org.dive4elements.river.jfree.Style;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
56 import org.dive4elements.river.jfree.StyledSeries;
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
57 import org.dive4elements.river.jfree.StyledXYDataset;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
58 import org.dive4elements.river.themes.ThemeDocument;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
59 import org.jfree.chart.JFreeChart;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
60 import org.jfree.chart.LegendItem;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
61 import org.jfree.chart.LegendItemCollection;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
62 import org.jfree.chart.axis.NumberAxis;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
63 import org.jfree.chart.plot.XYPlot;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
64 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
65 import org.jfree.chart.title.TextTitle;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
66 import org.jfree.data.Range;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
67 import org.jfree.data.general.Series;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
68 import org.jfree.data.xy.XYDataset;
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
69 import org.jfree.ui.HorizontalAlignment;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
70 import org.jfree.ui.RectangleInsets;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
71 import org.w3c.dom.Document;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
72 import org.w3c.dom.Element;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
73
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
74 /**
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
75 * This class re-unites the tremendous copy/paste code from ChartGenerator and ChartGenerator2. Code is still awful and
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
76 * encapsulation is broken in too many places.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
77 * TODO: instead of deep inheritances, delegate to classes that define the various behaviors.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
78 *
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
79 * @author Gernot Belger
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
80 */
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
81 abstract class AbstractChartGenerator implements OutGenerator {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
82
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
83 protected static final Logger log = Logger.getLogger(AbstractChartGenerator.class);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
84
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
85 private static final int DEFAULT_CHART_WIDTH = 600;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
86
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
87 private static final int DEFAULT_CHART_HEIGHT = 400;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
88
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
89 private static final Color DEFAULT_GRID_COLOR = Color.GRAY;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
90
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
91 private static final float DEFAULT_GRID_LINE_WIDTH = 0.3f;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
92
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
93 protected static final String DEFAULT_FONT_NAME = "Tahoma";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
94
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
95 protected static final int DEFAULT_FONT_SIZE = 12;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
96
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
97 private static final String DEFAULT_CHART_FORMAT = "png";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
98
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
99 private static final String XPATH_CHART_EXPORT = "/art:action/art:attributes/art:export/@art:value";
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
100
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
101 private static final String XPATH_CHART_SIZE = "/art:action/art:attributes/art:size";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
102
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
103 private static final String XPATH_CHART_FORMAT = "/art:action/art:attributes/art:format/@art:value";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
104
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
105 private static final String XPATH_CHART_X_RANGE = "/art:action/art:attributes/art:xrange";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
106
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
107 private static final String XPATH_CHART_Y_RANGE = "/art:action/art:attributes/art:yrange";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
108
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
109 /** The document of the incoming out() request. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
110 private Document request;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
111
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
112 /** The output stream where the data should be written to. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
113 private OutputStream out;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
114
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
115 /** Artifact that is used to decorate the chart with meta information. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
116 private Artifact master;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
117
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
118 /** Map of datasets ("index"). */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
119 private final SortedMap<Integer, AxisDataset> datasets = new TreeMap<>();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
120
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
121 /** List of annotations to insert in plot. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
122 private final List<RiverAnnotation> annotations = new ArrayList<>();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
124 private String outName;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
125
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
126 /** The settings that should be used during output creation. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
127 private Settings settings;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
128
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
129 /** The CallContext object. */
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
130 private CallContext context;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
131
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
132 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
133 public void init(final String outName, final Document request, final OutputStream out, final CallContext context) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
134 log.debug("ChartGenerator.init");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
135
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
136 this.outName = outName;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
137 this.request = request;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
138 this.out = out;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
139 this.context = context;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
140 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
141
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
142 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
143 public void setup(final Object config) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
144 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
145
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
146 /** Sets the master artifact. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
147 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
148 public void setMasterArtifact(final Artifact master) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
149 this.master = master;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
150 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
151
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
152 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
153 * Gets the master artifact.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
154 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
155 * @return the master artifact.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
156 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
157 public Artifact getMaster() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
158 return this.master;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
159 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
160
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
161 protected final Map<Integer, AxisDataset> getDatasets() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
162 return this.datasets;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
163 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
164
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
165 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
166 public void setCollection(final D4EArtifactCollection collection) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
167 /* we do not need it */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
168 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
169
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
170 protected final D4EArtifact getArtifact() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
171 // FIXME: should already made sure when this member is set
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
172 return (D4EArtifact) this.master;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
173 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
174
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
175 public final CallContext getContext() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
176 return this.context;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
177 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
178
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
179 /** The document of the incoming out() request. */
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
180 protected final Document getRequest() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
181 return this.request;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
182 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
183
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
184 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
185 * Adds annotations to list. The given annotation will be visible.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
186 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
187 public final void addAnnotations(final RiverAnnotation annotation) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
188 this.annotations.add(annotation);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
189 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
190
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
191 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
192 * This method needs to be implemented by concrete subclasses to create new
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
193 * instances of JFreeChart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
194 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
195 * @param context2
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
196 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
197 * @return a new instance of a JFreeChart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
198 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
199 protected abstract JFreeChart generateChart(CallContext context2);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
200
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
201 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
202 * For every outable (i.e. facets), this function is
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
203 * called and handles the data accordingly.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
204 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
205 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
206 public abstract void doOut(ArtifactAndFacet bundle, ThemeDocument attr, boolean visible);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
207
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
208 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
209 public void generate() throws IOException {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
210 doGenerate(this.context, this.out, this.outName);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
211 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
212
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
213 protected abstract void doGenerate(CallContext context, OutputStream out, String outName) throws IOException;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
214
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
215 protected abstract Series getSeriesOf(XYDataset dataset, int idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
216
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
217 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
218 * Returns the default title of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
219 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
220 * @param context2
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
221 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
222 * @return the default title of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
223 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
224 protected abstract String getDefaultChartTitle(CallContext context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
225
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
226 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
227 * This method is used to create new AxisDataset instances which may differ
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
228 * in concrete subclasses.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
229 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
230 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
231 * The index of an axis.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
232 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
233 protected abstract AxisDataset createAxisDataset(int idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
234
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
235 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
236 * Combines the ranges of the X axis at index <i>idx</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
237 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
238 * @param bounds
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
239 * A new Bounds.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
240 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
241 * The index of the X axis that should be comined with
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
242 * <i>range</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
243 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
244 protected abstract void combineXBounds(Bounds bounds, int idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
245
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
246 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
247 * Combines the ranges of the Y axis at index <i>idx</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
248 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
249 * @param bounds
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
250 * A new Bounds.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
251 * @param index
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
252 * The index of the Y axis that should be comined with.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
253 * <i>range</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
254 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
255 protected abstract void combineYBounds(Bounds bounds, int index);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
256
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
257 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
258 * This method is used to determine the ranges for axes at a given index.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
259 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
260 * @param index
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
261 * The index of the axes at the plot.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
262 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
263 * @return a Range[] with [xrange, yrange];
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
264 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
265 protected abstract Range[] getRangesForAxis(int index);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
266
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
267 protected abstract Bounds getXBounds(int axis);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
268
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
269 protected abstract void setXBounds(int axis, Bounds bounds);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
270
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
271 protected abstract Bounds getYBounds(int axis);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
272
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
273 protected abstract void setYBounds(int axis, Bounds bounds);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
274
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
275 // /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
276 // * Retuns the call context. May be null if init hasn't been called yet.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
277 // *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
278 // * @return the CallContext instance
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
279 // */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
280 // protected final CallContext getCallContext() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
281 // return this.context;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
282 // }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
283 //
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
284
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
285 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
286 public final void setSettings(final Settings settings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
287 this.settings = settings;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
288 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
289
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
290 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
291 * Returns the <i>settings</i> as <i>ChartSettings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
292 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
293 * @return the <i>settings</i> as <i>ChartSettings</i> or null, if
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
294 * <i>settings</i> is not an instance of <i>ChartSettings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
295 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
296 protected final ChartSettings getChartSettings() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
297 if (this.settings instanceof ChartSettings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
298 return (ChartSettings) this.settings;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
299 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
300
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
301 return null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
302 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
303
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
304 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
305 * Return instance of <i>ChartSettings</i> with a chart specific section
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
306 * but with no axes settings.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
307 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
308 * @return an instance of <i>ChartSettings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
309 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
310 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
311 public final Settings getSettings() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
312 if (this.settings != null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
313 return this.settings;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
314
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
315 final ChartSettings settings = new ChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
316
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
317 final ChartSection chartSection = buildChartSection(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
318 final LegendSection legendSection = buildLegendSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
319 final ExportSection exportSection = buildExportSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
320
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
321 settings.setChartSection(chartSection);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
322 settings.setLegendSection(legendSection);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
323 settings.setExportSection(exportSection);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
324
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
325 final List<AxisSection> axisSections = buildAxisSections();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
326 for (final AxisSection axisSection : axisSections)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
327 settings.addAxisSection(axisSection);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
328
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
329 return settings;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
330 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
331
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
332 protected abstract ChartSection buildChartSection(CallContext context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
333
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
334 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
335 * Creates a new <i>LegendSection</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
336 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
337 * @return a new <i>LegendSection</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
338 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
339 private LegendSection buildLegendSection() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
340 final LegendSection legendSection = new LegendSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
341 legendSection.setVisibility(isLegendVisible());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
342 legendSection.setFontSize(getLegendFontSize());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
343 legendSection.setAggregationThreshold(10);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
344 return legendSection;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
345 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
346
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
347 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
348 * Creates a new <i>ExportSection</i> with default values <b>WIDTH=600</b>
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
349 * and <b>HEIGHT=400</b>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
350 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
351 * @return a new <i>ExportSection</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
352 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
353 private ExportSection buildExportSection() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
354 final ExportSection exportSection = new ExportSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
355 exportSection.setWidth(DEFAULT_CHART_WIDTH);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
356 exportSection.setHeight(DEFAULT_CHART_HEIGHT);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
357 exportSection.setMetadata(true);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
358 return exportSection;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
359 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
360
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
361 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
362 * Creates a list of Sections that contains all axes of the chart (including
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
363 * X and Y axes).
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
364 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
365 * @return a list of Sections for each axis in this chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
366 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
367 private List<AxisSection> buildAxisSections() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
368 final List<AxisSection> axisSections = new ArrayList<>();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
369
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
370 axisSections.addAll(buildXAxisSections());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
371 axisSections.addAll(buildYAxisSections());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
372
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
373 return axisSections;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
374 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
375
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
376 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
377 * Creates a new Section for chart's X axis.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
378 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
379 * @return a List that contains a Section for the X axis.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
380 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
381 protected List<AxisSection> buildXAxisSections() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
382 final List<AxisSection> axisSections = new ArrayList<>();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
383
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
384 final String identifier = "X";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
385
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
386 final AxisSection axisSection = new AxisSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
387 axisSection.setIdentifier(identifier);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
388 axisSection.setLabel(getXAxisLabel());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
389 axisSection.setFontSize(14);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
390 axisSection.setFixed(false);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
391
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
392 // XXX We are able to find better default ranges that [0,0], but the Y
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
393 // axes currently have no better ranges set.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
394 axisSection.setUpperRange(0d);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
395 axisSection.setLowerRange(0d);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
396
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
397 axisSections.add(axisSection);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
398
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
399 return axisSections;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
400 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
401
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
402 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
403 * Returns the X-Axis label of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
404 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
405 * @return the X-Axis label of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
406 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
407 protected final String getXAxisLabel() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
408 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
409 if (chartSettings == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
410 return getDefaultXAxisLabel(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
411 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
412
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
413 final AxisSection as = chartSettings.getAxisSection("X");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
414 if (as != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
415 final String label = as.getLabel();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
416
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
417 if (label != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
418 return label;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
419 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
420 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
421
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
422 return getDefaultXAxisLabel(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
423 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
424
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
425 protected abstract List<AxisSection> buildYAxisSections();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
426
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
427 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
428 * Returns the default X-Axis label of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
429 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
430 * @param context2
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
431 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
432 * @return the default X-Axis label of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
433 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
434 protected abstract String getDefaultXAxisLabel(final CallContext context2);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
435
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
436 /** Generate the diagram as an image. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
437 protected final void generateImage(final CallContext context) throws IOException {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
438 log.debug("ChartGenerator2.generateImage");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
439
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
440 final JFreeChart chart = generateChart(context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
441
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
442 final String format = getFormat();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
443 int[] size = getSize();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
444
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
445 if (size == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
446 size = getExportDimension();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
447
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
448 this.context.putContextValue("chart.width", size[0]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
449 this.context.putContextValue("chart.height", size[1]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
450
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
451 if (format.equals(ChartExportHelper.FORMAT_PNG)) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
452 this.context.putContextValue("chart.image.format", "png");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
453
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
454 ChartExportHelper.exportImage(this.out, chart, this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
455 } else if (format.equals(ChartExportHelper.FORMAT_PDF)) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
456 preparePDFContext(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
457
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
458 ChartExportHelper.exportPDF(this.out, chart, this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
459 } else if (format.equals(ChartExportHelper.FORMAT_SVG)) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
460 prepareSVGContext(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
461
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
462 ChartExportHelper.exportSVG(this.out, chart, this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
463 } else if (format.equals(ChartExportHelper.FORMAT_CSV)) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
464 this.context.putContextValue("chart.image.format", "csv");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
465
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
466 ChartExportHelper.exportCSV(this.out, chart, this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
467 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
468 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
469
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
470 protected final void generateTitles(final JFreeChart chart) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
471 /* add metadata title before real title */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
472 addMetadataSubtitle(chart);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
473
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
474 /* add the real chart title, but as subtitle after the metadata */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
475 final String chartTitle = getChartTitle(this.context);
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
476 if (chartTitle != null) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
477 final TextTitle title = new TextTitle(chartTitle, JFreeChart.DEFAULT_TITLE_FONT);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
478 chart.addSubtitle(title);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
479 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
480
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
481 addSubtitles(this.context, chart);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
482 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
483
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
484 /**
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
485 * Adds a metadata sub-title to the chart if it gets exported
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
486 */
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
487 protected final void addMetadataSubtitle(final JFreeChart chart) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
488 if ((!isExport() || !isExportMetadata()))
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
489 return;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
490
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
491 final Collection<String> metadata = buildMetadata();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
492
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
493 for (final String text : metadata) {
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
494
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
495 /** The default font. */
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
496 final Font titleFont = new Font("SansSerif", Font.ITALIC, 10);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
497
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
498 final TextTitle subtitle = new TextTitle(text, titleFont);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
499 subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
500 subtitle.setTextAlignment(HorizontalAlignment.LEFT);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
501 subtitle.setMargin(new RectangleInsets(5, 10, 0, 10));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
502 subtitle.setPadding(RectangleInsets.ZERO_INSETS);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
503 subtitle.getFrame();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
504
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
505 chart.addSubtitle(subtitle);
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
506 }
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
507 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
508
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
509 private Collection<String> buildMetadata() {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
510
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
511 final CallMeta meta = this.context.getMeta();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
512
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
513 if (!(this.context instanceof CollectionCallContext)) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
514 /* should never happen */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
515 return Collections.emptyList();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
516 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
517
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
518 final CollectionCallContext ccc = (CollectionCallContext) this.context;
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
519 final ArtifactCollection collection = ccc.getCollection();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
520
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
521 final List<String> subtitles = new ArrayList<>();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
522
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
523 final List<String> firstLine = new ArrayList<>();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
524 final List<String> secondLine = new ArrayList<>();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
525
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
526 /* version */
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
527 final String version = FLYS.VERSION;
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
528 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.version", "default", version));
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
529
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
530 /* user */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
531 // REMARK: the use inside the collection is a fake user and hence we cant use it here.
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
532 // final User user = collection.getUser();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
533 final String userName = CalculationUtils.findArtifactUser(this.context, getArtifact());
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
534 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.user", "default", userName));
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
535
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
536 /* creation date */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
537 final Locale locale = Resources.getLocale(meta);
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
538 final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
539 final String dateText = df.format(new Date());
9524
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
540 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.creationdate", "default", dateText));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
541
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
542 /* project name */
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
543 final String collectionName = collection.getName();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
544 final String collectionID = collection.identifier();
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
545 final String projectName = collectionName == null || collectionName.isEmpty() ? collectionID : collectionName;
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
546 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.projectname", "default", projectName));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
547
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
548 /* module name */
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
549 final String moduleName = Resources.getMsg(meta, "module." + this.master.getName());
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
550 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.modulename", "default", moduleName));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
551
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
552 /* calculation mode */
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
553 if (this.master instanceof D4EArtifact) {
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
554
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
555 final D4EArtifact artifact = (D4EArtifact) this.master;
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
556 // REMARK: relies on the fact that all modules use the same data-key 'calculation_mode'
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
557 final String calculationMode = artifact.getDataAsString("calculation_mode");
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
558 if (calculationMode != null) {
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
559 /* but not all modules have that (i.e. Chart, Map, ...) */
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
560
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
561 final String calculationName = Resources.getMsg(meta, calculationMode, "XXX");
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
562 if (!"XXX".contentEquals(calculationName))
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
563 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.calcmode", "calcmode", calculationName));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
564 }
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
565 }
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
566
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
567 subtitles.add(StringUtils.join(firstLine, " - "));
9dc6427059b2 Added more metadata to chart exports
gernotbelger
parents: 9499
diff changeset
568 subtitles.add(StringUtils.join(secondLine, " - "));
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
569
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
570 return subtitles;
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
571 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
572
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
573 private boolean isExportMetadata() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
574 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
575 if (chartSettings == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
576 return true;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
577
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
578 final ExportSection exportSection = chartSettings.getExportSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
579 if (exportSection == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
580 return true;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
581
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
582 return exportSection.getMetadata();
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
583 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
584
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
585 /**
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
586 * This method returns the export flag specified in the <i>request</i> document
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
587 * or <i>false</i> if no export is specified in <i>request</i>.
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
588 */
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
589 private boolean isExport() {
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
590 final Boolean export = (Boolean) XMLUtils.xpath(getRequest(), XPATH_CHART_EXPORT, XPathConstants.BOOLEAN, ArtifactNamespaceContext.INSTANCE);
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
591
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
592 return export == null ? false : export;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
593 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
594
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
595 protected final String getRiverName() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
596 return new RiverAccess(getArtifact()).getRiver().getName();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
597 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
598
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
599 protected final String getRiverUnit() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
600 return new RiverAccess(getArtifact()).getRiver().getWstUnit().getName();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
601 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
602
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
603 protected final double[] getRange() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
604 final D4EArtifact flys = getArtifact();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
605
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
606 final RangeAccess rangeAccess = new RangeAccess(flys);
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
607 return rangeAccess.getKmRange();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
608 }
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
609
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
610 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
611 * Returns a boolean object that determines if the chart grid should be
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
612 * visible or not. This information needs to be provided by <i>settings</i>,
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
613 * otherwise the default is true.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
614 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
615 * @param settings
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
616 * A ChartSettings object.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
617 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
618 * @return true, if the chart grid should be visible otherwise false.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
619 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
620 * @throws NullPointerException
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
621 * if <i>settings</i> is null.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
622 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
623 private boolean isGridVisible(final ChartSettings settings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
624 final ChartSection cs = settings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
625 return cs.getDisplayGrid();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
626 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
627
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
628 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
629 * This method is used to determine, if the chart's legend is visible or
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
630 * not. If a <i>settings</i> instance is set, this instance determines the
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
631 * visibility otherwise, this method returns true as default if no
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
632 * <i>settings</i> is set.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
633 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
634 * @return true, if the legend should be visible, otherwise false.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
635 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
636 protected final boolean isLegendVisible() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
637 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
638 if (chartSettings == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
639 return true;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
640
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
641 final LegendSection ls = chartSettings.getLegendSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
642 return ls.getVisibility();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
643 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
644
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
645 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
646 * This method returns the font size for the X axis. If the font size is
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
647 * specified in ChartSettings (if <i>chartSettings</i> is set), this size is
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
648 * returned. Otherwise the default font size 12 is returned.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
649 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
650 * @return the font size for the x axis.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
651 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
652 protected final int getXAxisLabelFontSize() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
653 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
654 if (chartSettings == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
655 return DEFAULT_FONT_SIZE;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
656 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
657
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
658 final AxisSection as = chartSettings.getAxisSection("X");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
659 final Integer fontSize = as.getFontSize();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
660
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
661 return fontSize != null ? fontSize : DEFAULT_FONT_SIZE;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
662 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
663
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
664 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
665 * This method is used to determine the font size of the chart's legend. If
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
666 * a <i>settings</i> instance is set, this instance determines the font
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
667 * size, otherwise this method returns 12 as default if no <i>settings</i>
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
668 * is set or if it doesn't provide a legend font size.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
669 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
670 * @return a legend font size.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
671 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
672 private int getLegendFontSize() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
673
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
674 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
675 if (chartSettings == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
676 return DEFAULT_FONT_SIZE;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
677
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
678 final LegendSection ls = chartSettings.getLegendSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
679 if (ls == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
680 return DEFAULT_FONT_SIZE;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
681
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
682 final Integer fontSize = ls.getFontSize();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
683 if (fontSize == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
684 return DEFAULT_FONT_SIZE;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
685
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
686 return fontSize;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
687 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
688
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
689 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
690 * Creates a new LegendItem with <i>name</i> and font provided by
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
691 * <i>createLegendLabelFont()</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
692 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
693 * @param theme
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
694 * The theme of the chart line.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
695 * @param name
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
696 * The displayed name of the item.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
697 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
698 * @return a new LegendItem instance.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
699 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
700 protected final LegendItem createLegendItem(final ThemeDocument theme, final String name) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
701 // OPTIMIZE Pass font, parsed Theme items.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
702
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
703 Color color = theme.parseLineColorField();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
704 if (color == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
705 color = Color.BLACK;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
706
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
707 final LegendItem legendItem = new LegendItem(name, color);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
708 legendItem.setLabelFont(createLegendLabelFont());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
709 return legendItem;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
710 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
711
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
712 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
713 * Create new legend entries, dependent on settings.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
714 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
715 * @param plot
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
716 * The plot for which to modify the legend.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
717 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
718 protected final void aggregateLegendEntries(final XYPlot plot) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
719
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
720 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
721 if (chartSettings == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
722 return;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
723
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
724 final Integer threshold = chartSettings.getLegendSection().getAggregationThreshold();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
725
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
726 final int aggrThreshold = threshold != null ? threshold.intValue() : 0;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
727
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
728 LegendProcessor.aggregateLegendEntries(plot, aggrThreshold);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
729 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
730
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
731 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
732 * Creates Font (Family and size) to use when creating Legend Items. The
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
733 * font size depends in the return value of <i>getLegendFontSize()</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
734 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
735 * @return a new Font instance with <i>DEFAULT_FONT_NAME</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
736 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
737 private final Font createLegendLabelFont() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
738 return new Font(DEFAULT_FONT_NAME, Font.PLAIN, getLegendFontSize());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
739 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
740
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
741 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
742 * Adjust some Stroke/Grid parameters for <i>plot</i>. The chart
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
743 * <i>Settings</i> are applied in this method.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
744 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
745 * @param plot
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
746 * The XYPlot which is adapted.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
747 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
748 protected void adjustPlot(final XYPlot plot) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
749 final Stroke gridStroke = new BasicStroke(DEFAULT_GRID_LINE_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 3.0f, new float[] { 3.0f }, 0.0f);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
750
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
751 final ChartSettings cs = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
752 final boolean isGridVisible = cs != null ? isGridVisible(cs) : true;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
753
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
754 plot.setDomainGridlineStroke(gridStroke);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
755 plot.setDomainGridlinePaint(DEFAULT_GRID_COLOR);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
756 plot.setDomainGridlinesVisible(isGridVisible);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
757
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
758 plot.setRangeGridlineStroke(gridStroke);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
759 plot.setRangeGridlinePaint(DEFAULT_GRID_COLOR);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
760 plot.setRangeGridlinesVisible(isGridVisible);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
761
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
762 plot.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d));
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
763 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
764
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
765 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
766 * This helper method is used to extract the current locale from instance variable <i>context</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
767 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
768 * @return the current locale.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
769 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
770 protected final Locale getLocale() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
771 final CallMeta meta = this.context.getMeta();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
772 final PreferredLocale[] prefs = meta.getLanguages();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
773
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
774 final int len = prefs != null ? prefs.length : 0;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
775
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
776 final Locale[] locales = new Locale[len];
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
777
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
778 for (int i = 0; i < len; i++) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
779 locales[i] = prefs[i].getLocale();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
780 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
781
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
782 return meta.getPreferredLocale(locales);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
783 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
784
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
785 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
786 * Look up \param key in i18n dictionary.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
787 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
788 * @param key
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
789 * key for which to find i18nd version.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
790 * @param def
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
791 * default, returned if lookup failed.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
792 * @return value found in i18n dictionary, \param def if no value found.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
793 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
794 public final String msg(final String key, final String def) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
795 return Resources.getMsg(this.context.getMeta(), key, def);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
796 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
797
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
798 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
799 * Look up \param key in i18n dictionary.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
800 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
801 * @param key
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
802 * key for which to find i18nd version.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
803 * @return value found in i18n dictionary, key itself if failed.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
804 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
805 public final String msg(final String key) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
806 return Resources.getMsg(this.context.getMeta(), key, key);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
807 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
808
9251
4082b8429353 Using varargs for msg arguments
mschaefer
parents: 9186
diff changeset
809 public final String msg(final String key, final String def, final Object... args) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
810 return Resources.getMsg(this.context.getMeta(), key, def, args);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
811 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
812
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
813 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
814 * Add datasets stored in instance variable <i>datasets</i> to plot.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
815 * <i>datasets</i> actually stores instances of AxisDataset, so each of this
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
816 * datasets is mapped to a specific axis as well.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
817 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
818 * @param plot
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
819 * plot to add datasets to.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
820 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
821 protected void addDatasets(final XYPlot plot) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
822 log.debug("addDatasets()");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
823
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
824 // AxisDatasets are sorted, but some might be empty.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
825 // Thus, generate numbering on the fly.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
826 int axisIndex = 0;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
827 int datasetIndex = 0;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
828
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
829 for (final Map.Entry<Integer, AxisDataset> entry : this.datasets.entrySet()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
830 if (!entry.getValue().isEmpty()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
831 // Add axis and range information.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
832 final AxisDataset axisDataset = entry.getValue();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
833 final NumberAxis axis = createYAxis(entry.getKey());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
834
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
835 plot.setRangeAxis(axisIndex, axis);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
836
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
837 if (axis.getAutoRangeIncludesZero()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
838 axisDataset.setRange(Range.expandToInclude(axisDataset.getRange(), 0d));
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
839 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
840
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
841 setYBounds(axisIndex, expandPointRange(axisDataset.getRange()));
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
842
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
843 // Add contained datasets, mapping to axis.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
844 for (final XYDataset dataset : axisDataset.getDatasets()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
845 try {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
846 plot.setDataset(datasetIndex, dataset);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
847 plot.mapDatasetToRangeAxis(datasetIndex, axisIndex);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
848
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
849 applyThemes(plot, dataset, datasetIndex);
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
850
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
851 datasetIndex++;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
852 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
853 catch (final RuntimeException re) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
854 log.error(re);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
855 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
856 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
857
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
858 axisDataset.setPlotAxisIndex(axisIndex);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
859 axisIndex++;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
860 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
861 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
862 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
863
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
864 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
865 * Create Y (range) axis for given index.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
866 * Shall be implemented by subclasses.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
867 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
868 protected abstract NumberAxis createYAxis(final int index);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
869
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
870 /**
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
871 * @param datasetIndex
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
872 * "index" of dataset/series (first dataset to be drawn has
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
873 * index 0), correlates with renderer index.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
874 * @param isArea
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
875 * true if the series describes an area and shall be rendered
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
876 * as such.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
877 */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
878 private void applyThemes(final XYPlot plot, final XYDataset dataset, final int datasetIndex) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
879
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
880 final Font legendFont = createLegendLabelFont();
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
881
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
882 if (dataset instanceof StyledXYDataset)
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
883 ((StyledXYDataset) dataset).applyTheme(this.context.getMeta(), plot, datasetIndex, legendFont);
9186
eec4df8165a1 Implemented 'ShowLineLabel' for area themes.
gernotbelger
parents: 9123
diff changeset
884 else
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
885 applyLineTheme(plot, dataset, datasetIndex, legendFont);
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
886 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
887
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
888 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
889 * Expands a given range if it collapses into one point.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
890 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
891 * @param range
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
892 * Range to be expanded if upper == lower bound.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
893 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
894 * @return Bounds of point plus 5 percent in each direction.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
895 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
896 private Bounds expandPointRange(final Range range) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
897 if (range == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
898 return null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
899 } else if (range.getLowerBound() == range.getUpperBound()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
900 final Range expandedRange = ChartHelper.expandRange(range, 5d);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
901 return new DoubleBounds(expandedRange.getLowerBound(), expandedRange.getUpperBound());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
902 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
903
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
904 return new DoubleBounds(range.getLowerBound(), range.getUpperBound());
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
905 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
906
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
907 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
908 * Creates a new instance of EnhancedLineAndShapeRenderer.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
909 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
910 * @param plot
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
911 * The plot which is set for the new renderer.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
912 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
913 * This value is not used in the current implementation.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
914 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
915 * @return a new instance of EnhancedLineAndShapeRenderer.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
916 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
917 private XYLineAndShapeRenderer createRenderer(final XYPlot plot, final int idx) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
918 final EnhancedLineAndShapeRenderer r = new EnhancedLineAndShapeRenderer(true, false);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
919 r.setPlot(plot);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
920 return r;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
921 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
922
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
923 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
924 * This method applies the themes defined in the series itself. Therefore,
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
925 * <i>StyledXYSeries.applyTheme()</i> is called, which modifies the renderer
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
926 * for the series.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
927 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
928 * @param plot
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
929 * The plot.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
930 * @param dataset
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
931 * The XYDataset which needs to support Series objects.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
932 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
933 * The index of the renderer / dataset.
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
934 * @param legendFont2
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
935 */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
936 private void applyLineTheme(final XYPlot plot, final XYDataset dataset, final int idx, final Font legendFont) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
937 log.debug("Apply LineTheme for dataset at index: " + idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
938
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
939 final LegendItemCollection lic = new LegendItemCollection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
940 final LegendItemCollection anno = plot.getFixedLegendItems();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
941
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
942 final XYLineAndShapeRenderer renderer = createRenderer(plot, idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
943
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
944 for (int s = 0, num = dataset.getSeriesCount(); s < num; s++) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
945 final Series series = getSeriesOf(dataset, s);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
946
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
947 if (series instanceof StyledSeries) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
948 final Style style = ((StyledSeries) series).getStyle();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
949 style.applyTheme(renderer, s);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
950 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
951
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
952 // special case: if there is just one single item, we need to enable
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
953 // points for this series, otherwise we would not see anything in
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
954 // the chart area.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
955 if (series.getItemCount() == 1) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
956 renderer.setSeriesShapesVisible(s, true);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
957 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
958
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
959 LegendItem legendItem = renderer.getLegendItem(idx, s);
9325
094ed9d1f2ad Fixed: change of point style of interpolated data did not change in WQ chart of fixanalysis
gernotbelger
parents: 9311
diff changeset
960 if (legendItem.getLabel().endsWith(" ")) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
961 legendItem = null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
962 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
963
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
964 if (legendItem != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
965 legendItem.setLabelFont(legendFont);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
966 lic.add(legendItem);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
967 } else {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
968 log.warn("Could not get LegentItem for renderer: " + idx + ", series-idx " + s);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
969 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
970 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
971
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
972 if (anno != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
973 lic.addAll(anno);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
974 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
975
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
976 plot.setFixedLegendItems(lic);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
977
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
978 plot.setRenderer(idx, renderer);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
979 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
980
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
981 private void preparePDFContext(final CallContext context) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
982 final int[] dimension = getExportDimension();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
983
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
984 context.putContextValue("chart.width", dimension[0]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
985 context.putContextValue("chart.height", dimension[1]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
986 context.putContextValue("chart.marginLeft", 5f);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
987 context.putContextValue("chart.marginRight", 5f);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
988 context.putContextValue("chart.marginTop", 5f);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
989 context.putContextValue("chart.marginBottom", 5f);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
990 context.putContextValue("chart.page.format", ChartExportHelper.DEFAULT_PAGE_SIZE);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
991 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
992
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
993 private void prepareSVGContext(final CallContext context) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
994 final int[] dimension = getExportDimension();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
995
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
996 context.putContextValue("chart.width", dimension[0]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
997 context.putContextValue("chart.height", dimension[1]);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
998 context.putContextValue("chart.encoding", ChartExportHelper.DEFAULT_ENCODING);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
999 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1000
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1001 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1002 * This method retrieves the chart subtitle by calling getChartSubtitle()
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1003 * and adds it as TextTitle to the chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1004 * The default implementation of getChartSubtitle() returns the same
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1005 * as getDefaultChartSubtitle() which must be implemented by derived
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1006 * classes. If you want to add multiple subtitles to the chart override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1007 * this method and add your subtitles manually.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1008 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1009 * @param chart
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1010 * The JFreeChart chart object.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1011 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1012 protected void addSubtitles(final CallContext context, final JFreeChart chart) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1013 final String subtitle = getChartSubtitle(this.context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1014
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1015 if (subtitle != null && subtitle.length() > 0) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1016 chart.addSubtitle(new TextTitle(subtitle));
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1017 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1018 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1019
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1020 protected abstract String getChartSubtitle(CallContext context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1021
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1022 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1023 * Adds a new AxisDataset which contains <i>dataset</i> at index <i>idx</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1024 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1025 * @param dataset
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1026 * An XYDataset.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1027 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1028 * The axis index.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1029 * @param visible
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1030 * Determines, if the dataset should be visible or not.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1031 */
9499
853f2dafc16e VegetationZones in CrossSectionsDiagram
gernotbelger
parents: 9496
diff changeset
1032 public final void addAxisDataset(final XYDataset dataset, final int idx, final boolean visible) {
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1033 if (dataset == null || idx < 0) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1034 return;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1035 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1036
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1037 final AxisDataset axisDataset = getAxisDataset(idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1038
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1039 final Bounds[] xyBounds = ChartHelper.getBounds(dataset);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1040
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1041 // if (xyBounds == null) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1042 // log.warn("Skip XYDataset for Axis (invalid ranges): " + idx);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1043 // return;
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1044 // }
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1045
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1046 if (visible) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1047 if (log.isDebugEnabled()) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1048 log.debug("Add new AxisDataset at index: " + idx);
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1049 if (xyBounds != null) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1050 log.debug("X extent: " + xyBounds[0]);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1051 log.debug("Y extent: " + xyBounds[1]);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1052 }
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1053 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1054
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1055 axisDataset.addDataset(dataset);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1056 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1057
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1058 /* No range merging, for areas extending to infinity this causes problems. */
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1059 if (xyBounds == null || StyledSeriesBuilder.isBigDoubleValue(xyBounds[1].getLower()) || StyledSeriesBuilder.isBigDoubleValue(xyBounds[1].getLower()))
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1060 return;
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1061
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1062 combineXBounds(xyBounds[0], 0);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1063 combineYBounds(xyBounds[1], idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1064 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1065
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1066 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1067 * This method grants access to the AxisDatasets stored in <i>datasets</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1068 * If no AxisDataset exists for index <i>idx</i>, a new AxisDataset is
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1069 * created using <i>createAxisDataset()</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1070 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1071 * @param idx
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1072 * The index of the desired AxisDataset.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1073 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1074 * @return an existing or new AxisDataset.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1075 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1076 protected final AxisDataset getAxisDataset(final int idx) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1077 AxisDataset axisDataset = this.datasets.get(idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1078
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1079 if (axisDataset == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1080 axisDataset = createAxisDataset(idx);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1081 this.datasets.put(idx, axisDataset);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1082 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1083
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1084 return axisDataset;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1085 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1086
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1087 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1088 * Returns the size of a chart export as array which has been specified by
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1089 * the incoming request document.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1090 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1091 * @return the size of a chart as [width, height] or null if no width or
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1092 * height are given in the request document.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1093 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1094 protected final int[] getSize() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1095 final int[] size = new int[2];
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1096
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1097 final Element sizeEl = (Element) XMLUtils.xpath(this.request, XPATH_CHART_SIZE, XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1098
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1099 if (sizeEl != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1100 final String uri = ArtifactNamespaceContext.NAMESPACE_URI;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1101
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1102 final String w = sizeEl.getAttributeNS(uri, "width");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1103 final String h = sizeEl.getAttributeNS(uri, "height");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1104
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1105 if (w.length() > 0 && h.length() > 0) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1106 try {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1107 size[0] = Integer.parseInt(w);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1108 size[1] = Integer.parseInt(h);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1109 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1110 catch (final NumberFormatException nfe) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1111 log.warn("Wrong values for chart width/height.");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1112 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1113 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1114 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1115
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1116 return size[0] > 0 && size[1] > 0 ? size : null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1117 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1118
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1119 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1120 * This method returns the format specified in the <i>request</i> document
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1121 * or <i>DEFAULT_CHART_FORMAT</i> if no format is specified in
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1122 * <i>request</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1123 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1124 * @return the format used to export this chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1125 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1126 private String getFormat() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1127 final String format = (String) XMLUtils.xpath(this.request, XPATH_CHART_FORMAT, XPathConstants.STRING, ArtifactNamespaceContext.INSTANCE);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1128
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1129 return format == null || format.length() == 0 ? DEFAULT_CHART_FORMAT : format;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1130 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1131
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1132 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1133 * Returns the X-Axis range as String array from request document.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1134 * If the (x|y)range elements are not found in request document, return
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1135 * null (i.e. not zoomed).
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1136 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1137 * @return a String array with [lower, upper], null if not in document.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1138 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1139 protected final String[] getDomainAxisRangeFromRequest() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1140 final Element xrange = (Element) XMLUtils.xpath(this.request, XPATH_CHART_X_RANGE, XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1141
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1142 if (xrange == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1143 return null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1144 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1145
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1146 final String uri = ArtifactNamespaceContext.NAMESPACE_URI;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1147
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1148 final String lower = xrange.getAttributeNS(uri, "from");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1149 final String upper = xrange.getAttributeNS(uri, "to");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1150
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1151 return new String[] { lower, upper };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1152 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1153
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1154 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1155 * Returns null if the (x|y)range-element was not found in
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1156 * request document.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1157 * This usally means that the axis are not manually zoomed, i.e. showing
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1158 * full data extent.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1159 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1160 protected final String[] getValueAxisRangeFromRequest() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1161 final Element yrange = (Element) XMLUtils.xpath(this.request, XPATH_CHART_Y_RANGE, XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1162
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1163 if (yrange == null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1164 return null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1165 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1166
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1167 final String uri = ArtifactNamespaceContext.NAMESPACE_URI;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1168
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1169 final String lower = yrange.getAttributeNS(uri, "from");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1170 final String upper = yrange.getAttributeNS(uri, "to");
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1171
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1172 return new String[] { lower, upper };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1173 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1174
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1175 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1176 * Returns the default size of a chart export as array.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1177 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1178 * @return the default size of a chart as [width, height].
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1179 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1180 protected final int[] getDefaultSize() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1181 return new int[] { DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1182 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1183
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1184 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1185 * This method returns the export dimension specified in ChartSettings as
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1186 * int array [width,height].
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1187 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1188 * @return an int array with [width,height].
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1189 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1190 private int[] getExportDimension() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1191 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1192 if (chartSettings == null)
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1193 return new int[] { DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1194
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1195 final ExportSection export = chartSettings.getExportSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1196 final Integer width = export.getWidth();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1197 final Integer height = export.getHeight();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1198
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1199 if (width != null && height != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1200 return new int[] { width, height };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1201 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1202
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1203 return new int[] { 600, 400 };
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1204 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1205
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1206 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1207 * Returns the chart title provided by <i>settings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1208 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1209 * @param settings
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1210 * A ChartSettings object.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1211 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1212 * @return the title provided by <i>settings</i> or null if no
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1213 * <i>ChartSection</i> is provided by <i>settings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1214 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1215 * @throws NullPointerException
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1216 * if <i>settings</i> is null.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1217 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1218 private String getChartTitle(final ChartSettings settings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1219 final ChartSection cs = settings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1220 return cs != null ? cs.getTitle() : null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1221 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1222
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1223 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1224 * Returns the chart subtitle provided by <i>settings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1225 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1226 * @param settings
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1227 * A ChartSettings object.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1228 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1229 * @return the subtitle provided by <i>settings</i> or null if no
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1230 * <i>ChartSection</i> is provided by <i>settings</i>.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1231 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1232 * @throws NullPointerException
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1233 * if <i>settings</i> is null.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1234 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1235 protected final String getChartSubtitle(final ChartSettings settings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1236 final ChartSection cs = settings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1237 return cs != null ? cs.getSubtitle() : null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1238 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1239
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1240 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1241 * Returns the title of a chart. The return value depends on the existence
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1242 * of ChartSettings: if there are ChartSettings set, this method returns the
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1243 * chart title provided by those settings. Otherwise, this method returns
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1244 * getDefaultChartTitle().
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1245 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1246 * @return the title of a chart.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1247 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1248 protected String getChartTitle(final CallContext context) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1249 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1250
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1251 if (chartSettings != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1252 return getChartTitle(chartSettings);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1253 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1254
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1255 return getDefaultChartTitle(context);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1256 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1257
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1258 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1259 * This method always returns null. Override it in subclasses that require
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1260 * subtitles.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1261 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1262 * @return null.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1263 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1264 protected String getDefaultChartSubtitle(final CallContext context) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1265 // Override this method in subclasses
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1266 return null;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1267 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1268
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1269 /** Where to place the logo. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1270 protected final String logoHPlace() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1271 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1272 if (chartSettings != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1273 final ChartSection cs = chartSettings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1274 final String place = cs.getLogoHPlacement();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1275
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1276 return place;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1277 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1278 return "center";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1279 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1280
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1281 /** Where to place the logo. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1282 protected final String logoVPlace() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1283 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1284 if (chartSettings != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1285 final ChartSection cs = chartSettings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1286 final String place = cs.getLogoVPlacement();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1287
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1288 return place;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1289 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1290 return "top";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1291 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1292
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1293 /** Return the logo id from settings. */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1294 private String showLogo(final ChartSettings chartSettings) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1295 if (chartSettings != null) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1296 final ChartSection cs = chartSettings.getChartSection();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1297 final String logo = cs.getDisplayLogo();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1298
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1299 return logo;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1300 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1301 return "none";
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1302 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1303
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1304 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1305 * This method is used to determine if a logo should be added to the plot.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1306 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1307 * @return logo name (null if none).
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1308 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1309 protected final String showLogo() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1310 final ChartSettings chartSettings = getChartSettings();
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1311 return showLogo(chartSettings);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1312 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1313
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1314 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1315 * This method is used to determine if the resulting chart should display
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1316 * grid lines or not. <b>Note: this method always returns true!</b>
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1317 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1318 * @return true, if the chart should display grid lines, otherwise false.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1319 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1320 protected final boolean isGridVisible() {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1321 return true;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1322 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1323
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1324 protected final void addAnnotationsToRenderer(final XYPlot plot) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1325
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1326 final AnnotationRenderer annotationRenderer = new AnnotationRenderer(getChartSettings(), this.datasets, DEFAULT_FONT_NAME);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1327 annotationRenderer.addAnnotationsToRenderer(plot, this.annotations);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1328
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1329 doAddFurtherAnnotations(plot, this.annotations);
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1330 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1331
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1332 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1333 * Allow further annotation processing, override to implement.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1334 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1335 * Does nothing by default.
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1336 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1337 protected void doAddFurtherAnnotations(final XYPlot plot, final List<RiverAnnotation> annotations) {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1338
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1339 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
1340 }

http://dive4elements.wald.intevation.org