Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/AbstractChartGenerator.java @ 9555:ef5754ba5573
Implemented legend aggregation based on type of themes.
Added theme-editor style configuration for aggregated legend entries.
Only configured themes get aggregated.
author | gernotbelger |
---|---|
date | Tue, 23 Oct 2018 16:26:48 +0200 |
parents | 9dc6427059b2 |
children |
rev | line source |
---|---|
9104 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.exports; | |
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 | 29 import javax.xml.xpath.XPathConstants; |
30 | |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
31 import org.apache.commons.lang.StringUtils; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
32 import org.apache.log4j.Logger; |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
33 import org.dive4elements.artifactdatabase.CollectionCallContext; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
34 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
35 import org.dive4elements.artifactdatabase.state.Settings; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
36 import org.dive4elements.artifacts.Artifact; |
9524 | 37 import org.dive4elements.artifacts.ArtifactCollection; |
9104 | 38 import org.dive4elements.artifacts.ArtifactNamespaceContext; |
39 import org.dive4elements.artifacts.CallContext; | |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
40 import org.dive4elements.artifacts.CallMeta; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
41 import org.dive4elements.artifacts.PreferredLocale; |
9104 | 42 import org.dive4elements.artifacts.common.utils.XMLUtils; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
43 import org.dive4elements.river.FLYS; |
9104 | 44 import org.dive4elements.river.artifacts.D4EArtifact; |
45 import org.dive4elements.river.artifacts.access.RangeAccess; | |
46 import org.dive4elements.river.artifacts.access.RiverAccess; | |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
47 import org.dive4elements.river.artifacts.resources.Resources; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
48 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
49 import org.dive4elements.river.collections.D4EArtifactCollection; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
50 import org.dive4elements.river.jfree.AxisDataset; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
51 import org.dive4elements.river.jfree.Bounds; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
52 import org.dive4elements.river.jfree.DoubleBounds; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
53 import org.dive4elements.river.jfree.EnhancedLineAndShapeRenderer; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
54 import org.dive4elements.river.jfree.RiverAnnotation; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
55 import org.dive4elements.river.jfree.Style; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
56 import org.dive4elements.river.jfree.StyledSeries; |
9496
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
57 import org.dive4elements.river.jfree.StyledXYDataset; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
58 import org.dive4elements.river.themes.ThemeDocument; |
9104 | 59 import org.jfree.chart.JFreeChart; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
60 import org.jfree.chart.LegendItem; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
61 import org.jfree.chart.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 | 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 | 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 | 72 |
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 | 78 * @author Gernot Belger |
79 */ | |
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 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
98 private static final int DEFAULT_LEGEND_AGGREGATION_THRESHOLD = 10; |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
99 |
9104 | 100 private static final String XPATH_CHART_EXPORT = "/art:action/art:attributes/art:export/@art:value"; |
101 | |
9123
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_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
|
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_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
|
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_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
|
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 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
|
109 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
110 /** 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
|
111 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
|
112 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
113 /** 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
|
114 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
|
115 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
116 /** 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
|
117 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
|
118 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
119 /** 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
|
120 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
|
121 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
122 /** 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
|
123 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
|
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 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
|
126 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
127 /** 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
|
128 private Settings settings; |
9104 | 129 |
130 /** 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
|
131 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
|
132 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
133 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
134 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
|
135 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
|
136 |
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.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
|
138 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
|
139 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
|
140 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
|
141 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
142 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
143 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
144 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
|
145 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
146 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
147 /** 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
|
148 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
149 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
|
150 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
|
151 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
152 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
153 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
154 * 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
|
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 * @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
|
157 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
158 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
|
159 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
|
160 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
161 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
162 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
|
163 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
|
164 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
165 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
166 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
167 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
|
168 /* 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
|
169 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
170 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
171 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
|
172 // 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
|
173 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
|
174 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
175 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
176 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
|
177 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
|
178 } |
9104 | 179 |
180 /** 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
|
181 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
|
182 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
|
183 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
184 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
185 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
186 * 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
|
187 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
188 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
|
189 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
|
190 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
191 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
192 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
193 * 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
|
194 * 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
|
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 * @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
|
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 * @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
|
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 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
|
201 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
202 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
203 * 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
|
204 * 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
|
205 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
206 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
207 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
|
208 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
209 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
210 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
|
211 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
|
212 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
213 |
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 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
|
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 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
|
217 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
218 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
219 * 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
|
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 * @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
|
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 * @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
|
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 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
|
226 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
227 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
228 * 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
|
229 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
230 * @param bounds |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
231 * 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
|
232 * @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
|
233 * 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
|
234 * <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
|
235 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
236 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
|
237 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
238 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
239 * 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
|
240 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
241 * @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
|
242 * 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
|
243 * @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
|
244 * 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
|
245 * <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
|
246 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
247 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
|
248 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
249 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
250 * 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
|
251 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
252 * @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
|
253 * 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
|
254 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
255 * @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
|
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 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
|
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 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
|
260 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
261 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
|
262 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
263 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
|
264 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
265 protected abstract 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
|
266 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
267 // /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
268 // * 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
|
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 // * @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
|
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 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
|
273 // 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
|
274 // } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
275 // |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
276 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
277 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
278 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
|
279 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
|
280 } |
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 * 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
|
284 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
285 * @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
|
286 * <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
|
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 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
|
289 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
|
290 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
293 return null; |
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
296 /** |
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 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
|
298 * 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
|
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 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
|
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 @Override |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
303 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
|
304 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
|
305 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
|
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 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
|
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 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
|
310 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
|
311 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
|
312 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
317 final 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
|
318 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
|
319 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
|
320 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
321 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
|
322 } |
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 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
|
325 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
326 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
327 * 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
|
328 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
329 * @return 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
|
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 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
|
332 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
|
333 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
|
334 legendSection.setFontSize(getLegendFontSize()); |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
335 legendSection.setAggregationThreshold(DEFAULT_LEGEND_AGGREGATION_THRESHOLD); |
9123
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 legendSection; |
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
339 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
340 * 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
|
341 * 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
|
342 * |
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 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
|
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 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
353 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
354 * 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
|
355 * 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
|
356 * |
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 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
|
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 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
|
360 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
|
361 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
362 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
|
363 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
|
364 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
365 return axisSections; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
366 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
367 |
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 * 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
|
370 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
371 * @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
|
372 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
373 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
|
374 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
|
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 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
|
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 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
384 // 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
|
385 // 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
|
386 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
|
387 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
|
388 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
389 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
|
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 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
|
392 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
393 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
394 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
395 * 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
|
396 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
397 * @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
|
398 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
399 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
|
400 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
|
401 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
|
402 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
405 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
|
406 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
|
407 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
|
408 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
409 if (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
|
410 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
|
411 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
412 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
413 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
414 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
417 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
|
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 * 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
|
421 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
422 * @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
|
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 * @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
|
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 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
|
427 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
428 /** 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
|
429 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
|
430 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
|
431 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
432 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
|
433 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
434 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
|
435 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
|
436 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
437 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
|
438 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
|
439 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
440 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
|
441 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
|
442 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
443 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
|
444 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
|
445 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
446 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
|
447 } 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
|
448 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
|
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 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
|
451 } 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
|
452 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
|
453 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
454 ChartExportHelper.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
|
455 } 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
|
456 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
|
457 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
458 ChartExportHelper.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
|
459 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
460 } |
9104 | 461 |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
462 protected final void generateTitles(final JFreeChart chart) { |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
463 /* add metadata title before real title */ |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
464 addMetadataSubtitle(chart); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
465 |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
466 /* add the real chart title, but as subtitle after the metadata */ |
9496
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
467 final String chartTitle = getChartTitle(this.context); |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
468 if (chartTitle != null) { |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
469 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
|
470 chart.addSubtitle(title); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
471 } |
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 addSubtitles(this.context, chart); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
474 } |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
475 |
9104 | 476 /** |
477 * Adds a metadata sub-title to the chart if it gets exported | |
478 */ | |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
479 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
|
480 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
|
481 return; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
482 |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
483 final Collection<String> metadata = buildMetadata(); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
484 |
9524 | 485 for (final String text : metadata) { |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
486 |
9524 | 487 /** The default font. */ |
488 final Font titleFont = new Font("SansSerif", Font.ITALIC, 10); | |
489 | |
490 final TextTitle subtitle = new TextTitle(text, titleFont); | |
491 subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT); | |
492 subtitle.setTextAlignment(HorizontalAlignment.LEFT); | |
493 subtitle.setMargin(new RectangleInsets(5, 10, 0, 10)); | |
494 subtitle.setPadding(RectangleInsets.ZERO_INSETS); | |
495 subtitle.getFrame(); | |
496 | |
497 chart.addSubtitle(subtitle); | |
498 } | |
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 |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
501 private Collection<String> buildMetadata() { |
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 final CallMeta meta = this.context.getMeta(); |
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 if (!(this.context instanceof CollectionCallContext)) { |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
506 /* should never happen */ |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
507 return Collections.emptyList(); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
508 } |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
509 |
9524 | 510 final CollectionCallContext ccc = (CollectionCallContext) this.context; |
511 final ArtifactCollection collection = ccc.getCollection(); | |
512 | |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
513 final List<String> subtitles = new ArrayList<>(); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
514 |
9524 | 515 final List<String> firstLine = new ArrayList<>(); |
516 final List<String> secondLine = new ArrayList<>(); | |
517 | |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
518 /* 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
|
519 final String version = FLYS.VERSION; |
9524 | 520 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.version", "default", version)); |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
521 |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
522 /* user */ |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
523 // 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
|
524 // final User user = collection.getUser(); |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
525 final String userName = CalculationUtils.findArtifactUser(this.context, getArtifact()); |
9524 | 526 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.user", "default", userName)); |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
527 |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
528 /* creation date */ |
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
529 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
|
530 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
|
531 final String dateText = df.format(new Date()); |
9524 | 532 firstLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.creationdate", "default", dateText)); |
533 | |
534 /* project name */ | |
535 final String collectionName = collection.getName(); | |
536 final String collectionID = collection.identifier(); | |
537 final String projectName = collectionName == null || collectionName.isEmpty() ? collectionID : collectionName; | |
538 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.projectname", "default", projectName)); | |
539 | |
540 /* module name */ | |
541 final String moduleName = Resources.getMsg(meta, "module." + this.master.getName()); | |
542 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.modulename", "default", moduleName)); | |
543 | |
544 /* calculation mode */ | |
545 if (this.master instanceof D4EArtifact) { | |
546 | |
547 final D4EArtifact artifact = (D4EArtifact) this.master; | |
548 // REMARK: relies on the fact that all modules use the same data-key 'calculation_mode' | |
549 final String calculationMode = artifact.getDataAsString("calculation_mode"); | |
550 if (calculationMode != null) { | |
551 /* but not all modules have that (i.e. Chart, Map, ...) */ | |
552 | |
553 final String calculationName = Resources.getMsg(meta, calculationMode, "XXX"); | |
554 if (!"XXX".contentEquals(calculationName)) | |
555 secondLine.add(Resources.getMsg(meta, "chart.subtitle.metadata.calcmode", "calcmode", calculationName)); | |
556 } | |
557 } | |
558 | |
559 subtitles.add(StringUtils.join(firstLine, " - ")); | |
560 subtitles.add(StringUtils.join(secondLine, " - ")); | |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
561 |
9311
7c7f73e5e01e
Moved chart metadata line to top of chart. Minor cleanup.
gernotbelger
parents:
9251
diff
changeset
|
562 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
|
563 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
564 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
565 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
|
566 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
|
567 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
|
568 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
|
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 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
|
571 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
|
572 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
|
573 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
574 return exportSection.getMetadata(); |
9104 | 575 } |
576 | |
577 /** | |
578 * This method returns the export flag specified in the <i>request</i> document | |
579 * or <i>false</i> if no export is specified in <i>request</i>. | |
580 */ | |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
581 private boolean isExport() { |
9104 | 582 final Boolean export = (Boolean) XMLUtils.xpath(getRequest(), XPATH_CHART_EXPORT, XPathConstants.BOOLEAN, ArtifactNamespaceContext.INSTANCE); |
583 | |
584 return export == null ? false : export; | |
585 } | |
586 | |
587 protected final String getRiverName() { | |
588 return new RiverAccess(getArtifact()).getRiver().getName(); | |
589 } | |
590 | |
591 protected final String getRiverUnit() { | |
592 return new RiverAccess(getArtifact()).getRiver().getWstUnit().getName(); | |
593 } | |
594 | |
595 protected final double[] getRange() { | |
596 final D4EArtifact flys = getArtifact(); | |
597 | |
598 final RangeAccess rangeAccess = new RangeAccess(flys); | |
599 return rangeAccess.getKmRange(); | |
600 } | |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
601 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
602 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
603 * 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
|
604 * 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
|
605 * 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
|
606 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
607 * @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
|
608 * 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
|
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 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
|
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 * @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
|
613 * 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
|
614 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
615 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
|
616 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
|
617 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
|
618 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
619 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
620 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
621 * 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
|
622 * 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
|
623 * 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
|
624 * <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
|
625 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
626 * @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
|
627 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
628 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
|
629 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
|
630 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
|
631 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
|
632 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
633 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
|
634 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
|
635 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
636 |
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 * 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
|
639 * 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
|
640 * 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
|
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 * @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
|
643 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
644 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
|
645 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
|
646 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
|
647 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
|
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 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
|
651 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
|
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 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
|
654 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
655 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
656 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
657 * 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
|
658 * 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
|
659 * 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
|
660 * 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
|
661 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
662 * @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
|
663 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
664 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
|
665 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
670 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
|
671 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
|
672 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
|
673 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
674 final 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
|
675 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
|
676 return DEFAULT_FONT_SIZE; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
677 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
678 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
|
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 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
681 protected final LegendAggregator createLegendBuilder() { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
682 return new LegendAggregator(getLegendAggregationThreshold(), createLegendLabelFont()); |
9123
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 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
685 private int getLegendAggregationThreshold() { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
686 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
687 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
|
688 if (chartSettings == null) |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
689 return DEFAULT_LEGEND_AGGREGATION_THRESHOLD; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
690 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
691 final LegendSection legendSection = chartSettings.getLegendSection(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
692 if (legendSection == null) |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
693 return DEFAULT_LEGEND_AGGREGATION_THRESHOLD; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
694 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
695 final Integer threshold = legendSection.getAggregationThreshold(); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
696 if (threshold == null) |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
697 return DEFAULT_LEGEND_AGGREGATION_THRESHOLD; |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
698 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
699 return threshold; |
9123
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 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
703 * 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
|
704 * 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
|
705 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
706 * @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
|
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 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
|
709 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
|
710 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
711 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
712 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
713 * 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
|
714 * <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
|
715 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
716 * @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
|
717 * 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
|
718 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
719 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
|
720 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
|
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 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
|
723 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
|
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 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
|
726 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
|
727 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
|
728 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
729 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
|
730 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
|
731 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
|
732 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
733 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
|
734 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
735 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
736 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
737 * 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
|
738 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
739 * @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
|
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 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
|
742 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
|
743 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
|
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 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
|
746 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
747 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
|
748 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
749 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
|
750 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
|
751 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
752 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
753 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
|
754 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
755 |
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 * 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
|
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 * @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
|
760 * 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
|
761 * @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
|
762 * 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
|
763 * @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
|
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, 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
|
766 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
769 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
770 * 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
|
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 * @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
|
773 * 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
|
774 * @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
|
775 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
776 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
|
777 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
|
778 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
779 |
9251 | 780 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
|
781 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
|
782 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
783 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
784 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
785 * 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
|
786 * <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
|
787 * 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
|
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 * @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
|
790 * 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
|
791 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
792 protected void addDatasets(final XYPlot plot, final LegendAggregator legendBuilder) { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
793 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
|
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 // 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
|
796 // 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
|
797 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
|
798 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
|
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 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
|
801 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
|
802 // 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
|
803 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
|
804 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
|
805 |
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.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
|
807 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
808 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
|
809 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
|
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
812 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
|
813 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
814 // Add 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
|
815 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
|
816 try { |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
817 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
|
818 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
|
819 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
820 applyThemes(plot, legendBuilder, 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
|
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 datasetIndex++; |
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 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
|
825 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
|
826 } |
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 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
829 axisIndex++; |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
830 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
831 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
832 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
833 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
834 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
835 * 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
|
836 * 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
|
837 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
838 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
|
839 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
840 /** |
9496
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
841 * @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
|
842 * "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
|
843 * 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
|
844 * @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
|
845 * 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
|
846 * 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
|
847 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
848 private void applyThemes(final XYPlot plot, final LegendAggregator legendBuilder, final XYDataset dataset, final int datasetIndex) { |
9496
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
849 |
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
850 if (dataset instanceof StyledXYDataset) |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
851 ((StyledXYDataset) dataset).applyTheme(this.context.getMeta(), plot, legendBuilder, datasetIndex); |
9186 | 852 else |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
853 applyLineTheme(plot, legendBuilder, 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
|
854 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
855 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
856 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
857 * 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
|
858 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
859 * @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
|
860 * 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
|
861 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
862 * @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
|
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 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
|
865 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
|
866 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
|
867 } 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
|
868 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
|
869 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
|
870 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
871 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
872 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
|
873 } |
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 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
876 * 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
|
877 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
878 * @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
|
879 * 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
|
880 * @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
|
881 * 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
|
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 * @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
|
884 */ |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
885 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
|
886 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
|
887 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
|
888 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
|
889 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
890 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
891 /** |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
892 * 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
|
893 * <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
|
894 * 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
|
895 * |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
896 * @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
|
897 * 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
|
898 * @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
|
899 * 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
|
900 * @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
|
901 * The index of the renderer / dataset. |
9496
d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
gernotbelger
parents:
9325
diff
changeset
|
902 * @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
|
903 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
904 private void applyLineTheme(final XYPlot plot, final LegendAggregator legendBuilder, final XYDataset dataset, final int idx) { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
905 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
|
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 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
|
908 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
909 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
|
910 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
|
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 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
|
913 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
|
914 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
|
915 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
916 |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
917 // 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
|
918 // 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
|
919 // the chart area. |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
920 // if (series.getItemCount() == 1) { |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
921 // renderer.setSeriesShapesVisible(s, true); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
922 // } |
9123
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 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
|
925 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
|
926 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
|
927 } |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
928 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
929 final String themeType = series instanceof StyledSeries ? ((StyledSeries) series).getThemeType() : null; |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
930 |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
931 if (legendItem != null) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
932 legendBuilder.addLegendItem(themeType, legendItem); |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
933 } else { |
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
934 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
|
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 } |
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 | 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) { |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1040 axisDataset = new AxisDataset(); |
9123
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 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1284 protected final void addAnnotationsToRenderer(final XYPlot plot, final LegendAggregator legendBuilder) { |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
1285 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1286 final AnnotationRenderer annotationRenderer = new AnnotationRenderer(this.datasets); |
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1287 annotationRenderer.addAnnotationsToRenderer(plot, legendBuilder, this.annotations); |
9123
1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
gernotbelger
parents:
9104
diff
changeset
|
1288 |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1289 doAddFurtherAnnotations(plot, legendBuilder, this.annotations); |
9123
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 */ |
9555
ef5754ba5573
Implemented legend aggregation based on type of themes.
gernotbelger
parents:
9524
diff
changeset
|
1297 protected void doAddFurtherAnnotations(final XYPlot plot, final LegendAggregator legendBuilder, final List<RiverAnnotation> annotations) { |
9123
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 | 1300 } |