annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractChartGenerator.java @ 9499:853f2dafc16e

VegetationZones in CrossSectionsDiagram
author gernotbelger
date Thu, 27 Sep 2018 18:06:26 +0200
parents d8e753d0fdb9
children 9dc6427059b2
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;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
37 import org.dive4elements.artifacts.ArtifactNamespaceContext;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
38 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
39 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
40 import org.dive4elements.artifacts.PreferredLocale;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
41 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
42 import org.dive4elements.river.FLYS;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
43 import org.dive4elements.river.artifacts.D4EArtifact;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
44 import org.dive4elements.river.artifacts.access.RangeAccess;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 import org.dive4elements.river.jfree.StyledSeries;
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
56 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
57 import org.dive4elements.river.themes.ThemeDocument;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
58 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
59 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
60 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
61 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
62 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
63 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
64 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
65 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
66 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
67 import org.jfree.data.xy.XYDataset;
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
68 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
69 import org.jfree.ui.RectangleInsets;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
70 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
71 import org.w3c.dom.Element;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
72
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
73 /**
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
74 * 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
75 * 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
76 * 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
77 *
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
78 * @author Gernot Belger
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
79 */
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
80 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
81
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
82 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
83
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
84 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
85
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
86 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
87
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
88 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
89
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
90 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
91
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
92 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
93
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
94 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
95
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
96 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
97
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
98 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
99
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
100 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
101
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
102 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
103
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
104 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
105
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
106 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
107
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
108 /** 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
109 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
110
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
111 /** 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
112 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
113
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
114 /** 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
115 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
116
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
117 /** 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
118 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
119
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
120 /** 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
121 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
122
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
123 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
124
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
125 /** 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
126 private Settings settings;
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
127
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
128 /** 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
129 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
130
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
131 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
132 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
133 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
134
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
135 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
136 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
137 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
138 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
139 }
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 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
142 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
143 }
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 /** 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
146 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
147 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
148 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
149 }
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 * 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
153 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
154 * @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
155 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
156 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
157 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
158 }
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 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
161 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
162 }
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 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
165 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
166 /* 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
167 }
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 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
170 // 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
171 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
172 }
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 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
175 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
176 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
177
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
178 /** 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
179 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
180 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
181 }
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 * 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
185 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
186 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
187 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
188 }
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 * 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
192 * 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
193 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
194 * @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
195 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
196 * @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
197 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
198 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
199
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 * 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
202 * 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
203 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
204 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
205 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
206
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
207 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
208 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
209 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
210 }
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 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
213
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
214 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
215
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 * 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
218 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
219 * @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
220 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
221 * @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
222 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
223 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
224
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 * 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
227 * 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
228 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
229 * @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
230 * 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
231 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
232 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
233
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 * 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
236 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
237 * @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
238 * 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
239 * @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
240 * 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
241 * <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
242 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
243 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
244
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 * 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
247 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
248 * @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
249 * 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
250 * @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
251 * 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
252 * <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
253 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
254 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
255
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 * 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
258 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
259 * @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
260 * 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
261 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
262 * @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
263 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
264 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
265
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
266 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
267
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
268 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
269
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
270 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
271
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
272 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
273
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 // * 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
276 // *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
277 // * @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
278 // */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
279 // 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
280 // 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
281 // }
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 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
285 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
286 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
287 }
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 * 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
291 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
292 * @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
293 * <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
294 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
295 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
296 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
297 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
298 }
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 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
301 }
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 * 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
305 * 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
306 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
307 * @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
308 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
309 @Override
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
310 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
311 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
312 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
313
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
314 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
315
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
316 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
317 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
318 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
319
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
320 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
321 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
322 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
323
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
324 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
325 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
326 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
327
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
328 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
329 }
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 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
332
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 * 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
335 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
336 * @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
337 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
338 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
339 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
340 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
341 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
342 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
343 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
344 }
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 * 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
348 * 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
349 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
350 * @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
351 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
352 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
353 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
354 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
355 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
356 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
357 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
358 }
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 * 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
362 * 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
363 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
364 * @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
365 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
366 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
367 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
368
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
369 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
370 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
371
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
372 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
373 }
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 * 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
377 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
378 * @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
379 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
380 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
381 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
382
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
383 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
384
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
385 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
386 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
387 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
388 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
389 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
390
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
391 // 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
392 // 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
393 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
394 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
395
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
396 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
397
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
398 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
399 }
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 * 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
403 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
404 * @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
405 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
406 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
407 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
408 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
409 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
410 }
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 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
413 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
414 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
415
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
416 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
417 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
418 }
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 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
422 }
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 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
425
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 * 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
428 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
429 * @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
430 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
431 * @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
432 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
433 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
434
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
435 /** 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
436 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
437 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
438
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
439 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
440
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
441 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
442 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
443
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
444 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
445 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
446
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
447 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
448 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
449
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
450 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
451 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
452
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
453 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
454 } 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
455 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
456
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
457 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
458 } 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
459 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
460
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
461 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
462 } 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
463 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
464
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
465 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
466 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
467 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
468
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
469 protected final void generateTitles(final JFreeChart chart) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
470 /* add metadata title before real title */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
471 addMetadataSubtitle(chart);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
472
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
473 /* add the real chart title, but as subtitle after the metadata */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
474 final String chartTitle = getChartTitle(this.context);
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
475 if (chartTitle != null) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
476 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
477 chart.addSubtitle(title);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
478 }
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 addSubtitles(this.context, chart);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
481 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
482
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
483 /**
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
484 * Adds a metadata sub-title to the chart if it gets exported
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
485 */
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
486 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
487 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
488 return;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
489
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
490 final Collection<String> metadata = buildMetadata();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
491 final String text = StringUtils.join(metadata, " - ");
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
492
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
493 /** The default font. */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
494 final Font titleFont = new Font("SansSerif", Font.ITALIC, 10);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
495
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
496 final TextTitle subtitle = new TextTitle(text, titleFont);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
497 subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
498 subtitle.setMargin(new RectangleInsets(10, 10, 10, 10));
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
499
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
500 chart.addSubtitle(subtitle);
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
501 }
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
502
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
503 private Collection<String> buildMetadata() {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
504
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
505 final CallMeta meta = this.context.getMeta();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
506
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
507 if (!(this.context instanceof CollectionCallContext)) {
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
508 /* should never happen */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
509 return Collections.emptyList();
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
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
512 final List<String> subtitles = new ArrayList<>();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
513
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
514 /* 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
515 final String version = FLYS.VERSION;
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
516 subtitles.add(Resources.getMsg(meta, "chart.subtitle.metadata.version", "default", version));
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
517
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
518 /* user */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
519 // 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
520 // final User user = collection.getUser();
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
521 final String userName = CalculationUtils.findArtifactUser(this.context, getArtifact());
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
522 subtitles.add(Resources.getMsg(meta, "chart.subtitle.metadata.user", "default", userName));
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
523
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
524 /* creation date */
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
525 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
526 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
527 final String dateText = df.format(new Date());
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
528 subtitles.add(Resources.getMsg(meta, "chart.subtitle.metadata.creationdate", "default", dateText));
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
529
9311
7c7f73e5e01e Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents: 9251
diff changeset
530 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
531 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
532
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
533 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
534 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
535 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
536 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
537
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 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
539 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
540 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
541
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
542 return exportSection.getMetadata();
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
543 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
544
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
545 /**
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
546 * 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
547 * 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
548 */
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
549 private boolean isExport() {
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
550 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
551
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
552 return export == null ? false : export;
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
553 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
554
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
555 protected final String getRiverName() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
556 return new RiverAccess(getArtifact()).getRiver().getName();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
557 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
558
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
559 protected final String getRiverUnit() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
560 return new RiverAccess(getArtifact()).getRiver().getWstUnit().getName();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
561 }
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
562
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
563 protected final double[] getRange() {
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
564 final D4EArtifact flys = getArtifact();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
565
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
566 final RangeAccess rangeAccess = new RangeAccess(flys);
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
567 return rangeAccess.getKmRange();
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
568 }
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
570 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
571 * 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
572 * 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
573 * 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
574 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
575 * @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
576 * 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
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 * @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
579 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
580 * @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
581 * 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
582 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
583 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
584 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
585 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
586 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
587
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
588 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
589 * 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
590 * 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
591 * 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
592 * <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
593 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
594 * @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
595 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
596 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
597 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
598 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
599 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
600
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
601 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
602 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
603 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
604
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
605 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
606 * 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
607 * 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
608 * 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
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 * @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
611 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
612 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
613 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
614 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
615 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
616 }
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 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
619 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
620
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
621 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
624 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
625 * 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
626 * 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
627 * 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
628 * 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
629 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
630 * @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
631 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
632 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
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 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
635 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
636 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
637
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
638 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
639 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
640 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
641
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
642 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
643 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
644 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
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 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
647 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
648
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 * 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
651 * <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
652 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
653 * @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
654 * 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
655 * @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
656 * 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
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 * @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
659 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
660 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
661 // 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
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 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
664 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
665 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
666
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
667 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
668 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
669 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
670 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
673 * 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
674 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
675 * @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
676 * 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
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 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
679
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
680 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
681 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
682 return;
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
683
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
684 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
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 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
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 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
691 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
692 * 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
693 * 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
694 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
695 * @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
696 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
697 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
698 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
701 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
702 * 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
703 * <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
704 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
705 * @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
706 * 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
707 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
708 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
709 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
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 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
712 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
713
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
714 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
715 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
716 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
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 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
719 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
720 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
721
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
722 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
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
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 * 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
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 * @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
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 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
731 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
732 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
733
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
734 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
735
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
736 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
737
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
738 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
739 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
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 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
743 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
746 * 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
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 * @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
749 * 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
750 * @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
751 * 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
752 * @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
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 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
755 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
756 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
759 * 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
760 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
761 * @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
762 * 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
763 * @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
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 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
766 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
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
9251
4082b8429353 Using varargs for msg arguments
mschaefer
parents: 9186
diff changeset
769 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
770 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
771 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
772
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 * 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
775 * <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
776 * 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
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 * @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
779 * 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
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 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
782 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
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 // 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
785 // 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
786 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
787 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
788
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
789 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
790 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
791 // 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
792 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
793 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
794
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
795 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
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 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
798 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
799 }
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 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
802
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
803 // 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
804 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
805 try {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
806 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
807 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
808
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
809 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
810
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
811 datasetIndex++;
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 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
814 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
815 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
816 }
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 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
819 axisIndex++;
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 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
822 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
825 * 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
826 * 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
827 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
828 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
829
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
830 /**
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
831 * @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
832 * "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
833 * 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
834 * @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
835 * 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
836 * 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
837 */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
838 private void applyThemes(final XYPlot plot, final XYDataset dataset, final int datasetIndex) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
839
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
840 final Font legendFont = createLegendLabelFont();
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
841
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
842 if (dataset instanceof StyledXYDataset)
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
843 ((StyledXYDataset) dataset).applyTheme(this.context.getMeta(), plot, datasetIndex, legendFont);
9186
eec4df8165a1 Implemented 'ShowLineLabel' for area themes.
gernotbelger
parents: 9123
diff changeset
844 else
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
845 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
846 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
847
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
848 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
849 * 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
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 * @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
852 * 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
853 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
854 * @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
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 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
857 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
858 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
859 } 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
860 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
861 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
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 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
865 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
866
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 * 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
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 * @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
871 * 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
872 * @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
873 * 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
874 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
875 * @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
876 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
877 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
878 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
879 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
880 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
881 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
882
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
883 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
884 * 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
885 * <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
886 * 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
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 * @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
889 * 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
890 * @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
891 * 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
892 * @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
893 * The index of the renderer / dataset.
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
894 * @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
895 */
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
896 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
897 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
898
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
899 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
900 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
901
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
902 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
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 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
905 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
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 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
908 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
909 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
910 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
911
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
912 // 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
913 // 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
914 // 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
915 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
916 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
917 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
918
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
919 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
920 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
921 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
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 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
925 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
926 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
927 } else {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
928 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
929 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
930 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
931
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
932 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
933 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
934 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
935
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
936 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
937
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
938 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
939 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
940
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
941 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
942 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
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 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
945 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
946 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
947 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
948 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
949 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
950 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
953 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
954 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
955
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
956 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
957 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
958 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
959 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
960
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
961 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
962 * 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
963 * 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
964 * 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
965 * 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
966 * 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
967 * 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
968 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
969 * @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
970 * 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
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 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
973 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
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 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
976 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
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 }
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 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
981
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
982 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
983 * 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
984 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
985 * @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
986 * 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
987 * @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
988 * 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
989 * @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
990 * 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
991 */
9499
853f2dafc16e VegetationZones in CrossSectionsDiagram
gernotbelger
parents: 9496
diff changeset
992 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
993 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
994 return;
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
997 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
998
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
999 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
1000
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1001 // if (xyBounds == null) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1002 // log.warn("Skip XYDataset for Axis (invalid ranges): " + idx);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1003 // return;
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1004 // }
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1005
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1006 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
1007 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
1008 log.debug("Add new AxisDataset at index: " + idx);
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1009 if (xyBounds != null) {
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1010 log.debug("X extent: " + xyBounds[0]);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1011 log.debug("Y extent: " + xyBounds[1]);
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1012 }
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1013 }
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 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
1016 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1017
9496
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1018 /* No range merging, for areas extending to infinity this causes problems. */
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1019 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
1020 return;
d8e753d0fdb9 stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents: 9325
diff changeset
1021
9123
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1022 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
1023 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1026 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1027 * 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
1028 * 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
1029 * 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
1030 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1031 * @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
1032 * 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
1033 *
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 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
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 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
1037 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
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 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
1040 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
1041 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
1042 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1043
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1044 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1047 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1048 * 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
1049 * 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
1050 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1051 * @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
1052 * 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
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 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
1055 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
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 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
1058
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1059 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
1060 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
1061
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1062 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
1063 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
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 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
1066 try {
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1067 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
1068 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
1069 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1070 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
1071 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
1072 }
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 }
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 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
1077 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1080 * 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
1081 * 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
1082 * <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
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 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
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 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
1087 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
1088
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1089 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1092 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1093 * 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
1094 * 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
1095 * 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
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 * @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
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 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
1100 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
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 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
1103 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1106 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
1107
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1108 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
1109 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
1110
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1111 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
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 * 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
1116 * 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
1117 * 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
1118 * 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
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 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
1121 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
1122
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1123 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
1124 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
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
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 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
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 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
1130 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
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 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
1133 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1134
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1135 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1136 * 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
1137 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1138 * @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
1139 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1140 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
1141 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
1142 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1143
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 * 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
1146 * 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
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 * @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
1149 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1150 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
1151 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
1152 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
1153 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
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 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
1156 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
1157 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
1158
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1159 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
1160 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
1161 }
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 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
1164 }
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 * 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
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 * @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
1170 * 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
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 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
1173 * <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
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 * @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
1176 * 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
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 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
1179 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
1180 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
1181 }
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 * 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
1185 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1186 * @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
1187 * 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
1188 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1189 * @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
1190 * <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
1191 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1192 * @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
1193 * 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
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 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
1196 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
1197 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
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
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1200 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1201 * 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
1202 * 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
1203 * 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
1204 * getDefaultChartTitle().
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 * @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
1207 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1208 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
1209 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
1210
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1211 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
1212 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
1213 }
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 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
1216 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1219 * 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
1220 * subtitles.
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 * @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
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 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
1225 // 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
1226 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
1227 }
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 /** 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
1230 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
1231 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
1232 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
1233 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
1234 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
1235
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1236 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
1237 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1238 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
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 /** 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
1242 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
1243 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
1244 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
1245 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
1246 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
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 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
1249 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1250 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
1251 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1252
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1253 /** 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
1254 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
1255 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
1256 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
1257 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
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 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
1260 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1261 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
1262 }
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 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1265 * 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
1266 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1267 * @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
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 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
1270 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
1271 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
1272 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1273
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1274 /**
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1275 * 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
1276 * 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
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 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
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 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
1281 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
1282 }
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1283
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1284 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
1285
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 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
1287 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
1288
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1289 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
1290 }
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 * 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
1294 *
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1295 * 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
1296 */
1cc7653ca84f Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents: 9104
diff changeset
1297 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
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 }
9104
07d51fd4864c Added metadata subtitle to all chart export
gernotbelger
parents:
diff changeset
1300 }

http://dive4elements.wald.intevation.org