annotate artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7603:25bce6e8beea

(issue1225) Use label code also when only one item is present
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 25 Nov 2013 17:40:47 +0100
parents fca46ce8e4f5
children 7ac103a49e35
rev   line source
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 import java.awt.Color;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 import java.awt.Font;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
13
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 import java.text.NumberFormat;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
15
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import java.util.ArrayList;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 import java.util.HashMap;
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
18 import java.util.LinkedHashSet;
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import java.util.List;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import java.util.Map;
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
21 import java.util.Set;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
22
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
23 import java.util.regex.Pattern;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
24 import java.util.regex.Matcher;
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
26 import java.io.OutputStream;
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
27
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 import javax.swing.ImageIcon;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 import org.apache.log4j.Logger;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
31
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
32 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
33 import org.dive4elements.artifactdatabase.state.Facet;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
34
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
35 import org.dive4elements.artifacts.CallContext;
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
36
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
37 import org.dive4elements.river.artifacts.D4EArtifact;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
38
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
39 import org.dive4elements.river.exports.process.Processor;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
40
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
41 import org.dive4elements.river.jfree.AnnotationHelper;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
42 import org.dive4elements.river.jfree.AxisDataset;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
43 import org.dive4elements.river.jfree.Bounds;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
44 import org.dive4elements.river.jfree.DoubleBounds;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
45 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
46
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
47 import org.dive4elements.river.themes.ThemeDocument;
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
48 import org.dive4elements.river.utils.RiverUtils;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
49
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 import org.jfree.chart.ChartFactory;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 import org.jfree.chart.JFreeChart;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 import org.jfree.chart.LegendItem;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
53
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 import org.jfree.chart.annotations.XYAnnotation;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 import org.jfree.chart.annotations.XYImageAnnotation;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
56
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
57 import org.jfree.chart.axis.LogarithmicAxis;
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 import org.jfree.chart.axis.NumberAxis;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 import org.jfree.chart.axis.ValueAxis;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
60
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 import org.jfree.chart.plot.Marker;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 import org.jfree.chart.plot.PlotOrientation;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 import org.jfree.chart.plot.XYPlot;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
64
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 import org.jfree.data.Range;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
66
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 import org.jfree.data.general.Series;
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
68
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 import org.jfree.data.xy.XYDataset;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 import org.jfree.data.xy.XYSeries;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 import org.jfree.data.xy.XYSeriesCollection;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
73 import org.w3c.dom.Document;
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
74
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
75 import org.apache.commons.lang.StringUtils;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
76
7051
c4bacc5ddd9b Parse config when setup a new diagram.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7044
diff changeset
77
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 * The main diagram creation class.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
81 * This class is the glue between output processors and facets.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 * The generator creates one diagram and calls the appropiate
7248
1dff8e71c4d6 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7246
diff changeset
83 * processors for the state and
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 * With respect to datasets, ranges and axis, there are following requirements:
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 * <ul>
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 * <li> First in, first drawn: "Early" datasets should be of lower Z-Oder
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
88 * than later ones (only works per-axis). </li>
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
89 * <li> Visible axis should initially show the range of all datasets that
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
90 * show data for this axis (even invisible ones). Motivation: Once
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
91 * a dataset (theme) has been activated, it should be on screen. </li>
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
92 * <li> There should always be a Y-Axis on the "left". </li>
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
93 * </ul>
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
94 */
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
95 public class DiagramGenerator extends ChartGenerator2 {
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
96
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
97 public static final int AXIS_SPACE = 5;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
98
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
99 /** The logger that is used in this generator. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
100 private static Logger logger = Logger.getLogger(DiagramGenerator.class);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
101
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
102 protected List<Marker> domainMarkers = new ArrayList<Marker>();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
103
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
104 protected List<Marker> valueMarkers = new ArrayList<Marker>();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
105
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 /** The max X range to include all X values of all series for each axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
107 protected Map<Integer, Bounds> xBounds;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
108
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
109 /** The max Y range to include all Y values of all series for each axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
110 protected Map<Integer, Bounds> yBounds;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
111
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
112 /** Whether or not the plot is inverted (left-right). */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
113 private boolean inverted;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
114
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
115 private static final Pattern UNIT_PATTERN =
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
116 Pattern.compile("\\s*\\[[\\w\\s\\+\\-]*\\]\\s*");
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
117
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
118 protected Map<Integer, LinkedHashSet<String>> axesLabels;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
119
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
120 protected DiagramAttributes.Instance diagramAttributes;
7051
c4bacc5ddd9b Parse config when setup a new diagram.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7044
diff changeset
121
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
122 public DiagramGenerator() {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
123 super();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
124
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
125 axesLabels = new HashMap<Integer, LinkedHashSet<String>>();
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
126 xBounds = new HashMap<Integer, Bounds>();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
127 yBounds = new HashMap<Integer, Bounds>();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
128 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
129
7051
c4bacc5ddd9b Parse config when setup a new diagram.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7044
diff changeset
130 @Override
7087
ada424214b02 Use Object instead of DOM Element as argument for setup of out generators. First step to remove dependency to XML DOM when using configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7086
diff changeset
131 public void setup(Object config) {
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
132
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
133 if (!(config instanceof DiagramAttributes)) {
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
134 logger.error("invalid config type");
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
135 return;
7086
42e243c640a0 Little workaround to make diagram attribute parsing more thread safe. This is not the right solution.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7084
diff changeset
136 }
7099
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
137 DiagramAttributes da = (DiagramAttributes)config;
24f153ad1f40 Use pre-converted diagram attributes now.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7097
diff changeset
138 diagramAttributes = da.new Instance();
7051
c4bacc5ddd9b Parse config when setup a new diagram.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7044
diff changeset
139 }
c4bacc5ddd9b Parse config when setup a new diagram.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7044
diff changeset
140
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
141 @Override
7143
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
142 public void init(
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
143 String outName,
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
144 Document request,
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
145 OutputStream out,
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
146 CallContext context
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
147 ) {
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
148 super.init(outName, request, out, context);
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
149
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
150 RiverUtils.setKMFromRequestInContext(request, context);
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
151 }
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
152
7143
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
153 private void setInvertedFromConfig() {
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
154 DiagramAttributes.DomainAxisAttributes dx =
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
155 diagramAttributes.getDomainAxis();
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
156
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
157 if (dx != null) {
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
158 inverted = (Boolean)dx.isInverted()
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
159 .evaluate((D4EArtifact)getMaster(), context);
7167
2fd238b681a9 Add debug output triggered by debugging the last commit
Andre Heinecke <aheinecke@intevation.de>
parents: 7143
diff changeset
160 logger.debug("setInvertedFromConfig: " + inverted);
2fd238b681a9 Add debug output triggered by debugging the last commit
Andre Heinecke <aheinecke@intevation.de>
parents: 7143
diff changeset
161 } else {
2fd238b681a9 Add debug output triggered by debugging the last commit
Andre Heinecke <aheinecke@intevation.de>
parents: 7143
diff changeset
162 logger.debug("setInvertedFromConfig no domain axis found?");
7143
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
163 }
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
164 }
7123
1a20738e9a21 Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7122
diff changeset
165
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
166 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
167 * Generate the chart anew (including localized axis and all).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
168 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
169 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
170 public JFreeChart generateChart() {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
171 logger.debug("DiagramGenerator.generateChart");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
172
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
173 JFreeChart chart = ChartFactory.createXYLineChart(
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
174 getChartTitle(),
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
175 "",
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
176 "",
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
177 null,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
178 PlotOrientation.VERTICAL,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
179 isLegendVisible(),
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
180 false,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
181 false);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
182
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
183 XYPlot plot = (XYPlot) chart.getPlot();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
184 ValueAxis axis = createXAxis(getXAxisLabel());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
185 plot.setDomainAxis(axis);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
186
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
187 chart.setBackgroundPaint(Color.WHITE);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
188 plot.setBackgroundPaint(Color.WHITE);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
189 addSubtitles(chart);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
190 adjustPlot(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
191
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
192 //debugAxis(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
193
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
194 addDatasets(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
195
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
196 //debugDatasets(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
197
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
198 addMarkers(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
199
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
200 recoverEmptyPlot(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
201 preparePointRanges(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
202
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
203 //debugAxis(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
204
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
205 localizeAxes(plot);
7246
7ea428c4aca0 Check for inverted setting later.
Andre Heinecke <aheinecke@intevation.de>
parents: 7241
diff changeset
206
7ea428c4aca0 Check for inverted setting later.
Andre Heinecke <aheinecke@intevation.de>
parents: 7241
diff changeset
207 setInvertedFromConfig();
7ea428c4aca0 Check for inverted setting later.
Andre Heinecke <aheinecke@intevation.de>
parents: 7241
diff changeset
208
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
209 adjustAxes(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
210 if (!(axis instanceof LogarithmicAxis)) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
211 // XXX:
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
212 // The auto zoom without a range tries
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
213 // to include 0 in a logarithmic axis
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
214 // which triggers a bug in jfreechart that causes
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
215 // the values to be drawn carthesian
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
216 autoZoom(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
217 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
218
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
219 //debugAxis(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
220
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
221 // These have to go after the autozoom.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
222 AnnotationHelper.addAnnotationsToRenderer(annotations, plot,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
223 getChartSettings(), datasets);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
224
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
225 // Add a logo (maybe).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
226 addLogo(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
227
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
228 aggregateLegendEntries(plot);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
229
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
230 return chart;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
231 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
232
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
233 public String getOutName() {
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
234 return outName;
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
235 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
236
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
237 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
238 * Return left most data points x value (on first axis).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
239 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
240 protected double getLeftX() {
7106
ed8623b989f3 Minor cleanup / doc
Andre Heinecke <aheinecke@intevation.de>
parents: 7104
diff changeset
241 if (inverted) {
7104
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
242 return (Double)getXBounds(0).getUpper();
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
243 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
244 return (Double)getXBounds(0).getLower();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
245 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
246
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
247
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
248 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
249 * Return right most data points x value (on first axis).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
250 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
251 protected double getRightX() {
7106
ed8623b989f3 Minor cleanup / doc
Andre Heinecke <aheinecke@intevation.de>
parents: 7104
diff changeset
252 if (inverted) {
7104
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
253 return (Double)getXBounds(0).getLower();
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
254 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
255 return (Double)getXBounds(0).getUpper();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
256 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
257
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
258
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
259 /** Add a logo as background annotation to plot. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
260 protected void addLogo(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
261 String logo = showLogo();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
262 if (logo == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
263 logger.debug("No logo to show chosen");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
264 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
265 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
266
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
267 ImageIcon imageIcon = null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
268 if (logo.equals("none")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
269 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
270 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
271 /*
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
272 If you want to add images, remember to change code in these places:
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
273 flys-artifacts:
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
274 DiagramGenerator.java
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
275 Timeseries*Generator.java and
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
276 in the flys-client projects Chart*Propert*Editor.java.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
277 Also, these images have to be put in
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
278 flys-artifacts/src/main/resources/images/
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
279 flys-client/src/main/webapp/images/
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
280 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
281 java.net.URL imageURL;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
282 if (logo.equals("Intevation")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
283 imageURL = DiagramGenerator.class.getResource("/images/intevation.png");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
284 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
285 else { // TODO else if ...
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
286 imageURL = DiagramGenerator.class.getResource("/images/bfg_logo.gif");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
287 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
288 imageIcon = new ImageIcon(imageURL);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
289
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
290
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
291 double xPos = 0d, yPos = 0d;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
292
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
293 String placeh = logoHPlace();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
294 String placev = logoVPlace();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
295
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
296 if (placev == null || placev.equals("none")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
297 placev = "top";
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
298 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
299 if (placev.equals("top")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
300 yPos = (Double)getYBounds(0).getUpper();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
301 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
302 else if (placev.equals("bottom")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
303 yPos = (Double)getYBounds(0).getLower();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
304 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
305 else if (placev.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
306 yPos = ((Double)getYBounds(0).getUpper() + (Double)getYBounds(0).getLower())/2d;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
307 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
308 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
309 logger.debug("Unknown place-v value: " + placev);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
310 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
311
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
312 if (placeh == null || placeh.equals("none")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
313 placeh = "center";
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
314 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
315 if (placeh.equals("left")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
316 xPos = getLeftX();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
317 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
318 else if (placeh.equals("right")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
319 xPos = getRightX();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
320 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
321 else if (placeh.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
322 xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
323 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
324 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
325 logger.debug("Unknown place-h value: " + placeh);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
326 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
327
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
328 logger.debug("logo position: " + xPos + "/" + yPos);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
329
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
330 org.jfree.ui.RectangleAnchor anchor
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
331 = org.jfree.ui.RectangleAnchor.TOP;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
332 if (placev.equals("top")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
333 if (placeh.equals("left")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
334 anchor = org.jfree.ui.RectangleAnchor.TOP_LEFT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
335 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
336 else if (placeh.equals("right")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
337 anchor = org.jfree.ui.RectangleAnchor.TOP_RIGHT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
338 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
339 else if (placeh.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
340 anchor = org.jfree.ui.RectangleAnchor.TOP;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
341 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
342 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
343 else if (placev.equals("bottom")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
344 if (placeh.equals("left")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
345 anchor = org.jfree.ui.RectangleAnchor.BOTTOM_LEFT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
346 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
347 else if (placeh.equals("right")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
348 anchor = org.jfree.ui.RectangleAnchor.BOTTOM_RIGHT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
349 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
350 else if (placeh.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
351 anchor = org.jfree.ui.RectangleAnchor.BOTTOM;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
352 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
353 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
354 else if (placev.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
355 if (placeh.equals("left")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
356 anchor = org.jfree.ui.RectangleAnchor.LEFT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
357 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
358 else if (placeh.equals("right")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
359 anchor = org.jfree.ui.RectangleAnchor.RIGHT;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
360 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
361 else if (placeh.equals("center")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
362 anchor = org.jfree.ui.RectangleAnchor.CENTER;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
363 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
364 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
365
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
366 XYAnnotation xyannotation =
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
367 new XYImageAnnotation(xPos, yPos, imageIcon.getImage(), anchor);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
368 plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
369 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
370
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
371
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
372 protected NumberAxis createXAxis(String label) {
7241
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
373 boolean logarithmic = (Boolean)diagramAttributes.getDomainAxis().
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
374 isLog().evaluate((D4EArtifact)getMaster(), context);
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
375
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
376 if (logarithmic) {
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
377 return new LogarithmicAxis(label);
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
378 } else {
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
379 return new NumberAxis(label);
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
380 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
381 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
382
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
383
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
384 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
385 protected Series getSeriesOf(XYDataset dataset, int idx) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
386 return ((XYSeriesCollection) dataset).getSeries(idx);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
387 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
388
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
389
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
390 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
391 protected AxisDataset createAxisDataset(int idx) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
392 logger.debug("Create new AxisDataset for index: " + idx);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
393 return new AxisDataset(idx);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
394 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
395
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
396
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
397 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
398 * Put debug output about datasets.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
399 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
400 public void debugDatasets(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
401 logger.debug("Number of datasets: " + plot.getDatasetCount());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
402 for (int i = 0, P = plot.getDatasetCount(); i < P; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
403 if (plot.getDataset(i) == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
404 logger.debug("Dataset #" + i + " is null");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
405 continue;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
406 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
407 logger.debug("Dataset #" + i + ":" + plot.getDataset(i));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
408 XYSeriesCollection series = (XYSeriesCollection) plot.getDataset(i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
409 logger.debug("X-Extend of Dataset: " + series.getSeries(0).getMinX()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
410 + " " + series.getSeries(0).getMaxX());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
411 logger.debug("Y-Extend of Dataset: " + series.getSeries(0).getMinY()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
412 + " " + series.getSeries(0).getMaxY());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
413 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
414 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
415
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
416
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
417 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
418 * Put debug output about axes.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
419 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
420 public void debugAxis(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
421 logger.debug("...............");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
422 for (int i = 0, P = plot.getRangeAxisCount(); i < P; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
423 if (plot.getRangeAxis(i) == null)
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
424 logger.debug("Range-Axis #" + i + " == null");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
425 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
426 logger.debug("Range-Axis " + i + " != null [" +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
427 plot.getRangeAxis(i).getRange().getLowerBound() +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
428 " " + plot.getRangeAxis(i).getRange().getUpperBound() +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
429 "]");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
430 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
431 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
432 for (int i = 0, P = plot.getDomainAxisCount(); i < P; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
433 if (plot.getDomainAxis(i) == null)
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
434 logger.debug("Domain-Axis #" + i + " == null");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
435 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
436 logger.debug("Domain-Axis " + i + " != null [" +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
437 plot.getDomainAxis(i).getRange().getLowerBound() +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
438 " " + plot.getDomainAxis(i).getRange().getUpperBound() +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
439 "]");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
440 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
441 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
442 logger.debug("...............");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
443 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
444
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
445 /**
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
446 * Registers an area to be drawn.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
447 * @param area Area to be drawn.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
448 * @param axisName Name of the axis.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
449 * @param visible Whether or not to be visible (important for range calculations).
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
450 */
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
451 public void addAreaSeries(StyledAreaSeriesCollection area, String axisName, boolean visible) {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
452 addAreaSeries(area, diagramAttributes.getAxisIndex(axisName), visible);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
453 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
454
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
455 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
456 * Registers an area to be drawn.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
457 * @param area Area to be drawn.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
458 * @param index 'axis index'
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
459 * @param visible Whether or not to be visible (important for range calculations).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
460 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
461 public void addAreaSeries(StyledAreaSeriesCollection area, int index, boolean visible) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
462 if (area == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
463 logger.warn("Cannot yet render above/under curve.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
464 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
465 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
466
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
467 AxisDataset axisDataset = (AxisDataset) getAxisDataset(index);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
468
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
469 if (visible) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
470 axisDataset.addArea(area);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
471 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
472 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
473 /* No range merging, for areas extending to infinity this
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
474 * causes problems. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
475 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
476 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
477
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
478 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
479 * Add given series if visible, if not visible adjust ranges (such that
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
480 * all points in data would be plotted once visible).
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
481 * @param series the data series to include in plot.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
482 * @param index index of the axis.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
483 * @param visible whether or not the data should be plotted.
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
484 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
485 public void addAxisSeries(XYSeries series, int index, boolean visible) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
486 if (series == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
487 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
488 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
489
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
490 logger.debug("Y Range of XYSeries: " +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
491 series.getMinY() + " | " + series.getMaxY());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
492
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
493 addAxisDataset(new XYSeriesCollection(series), index, visible);
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
494 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
495
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
496 /**
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
497 * Add given series if visible, if not visible adjust ranges (such that
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
498 * all points in data would be plotted once visible).
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
499 * @param series the data series to include in plot.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
500 * @param axisName name of the axis.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
501 * @param visible whether or not the data should be plotted.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
502 */
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
503 public void addAxisSeries(XYSeries series, String axisName, boolean visible) {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
504 addAxisSeries(series, diagramAttributes.getAxisIndex(axisName), visible);
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
505 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
506
7124
49ceab5f2263 Configure Longitudinal section diagram to use the new way.
Andre Heinecke <aheinecke@intevation.de>
parents: 7123
diff changeset
507 public void addAxisDataset(XYDataset dataset, String axisName, boolean visible) {
49ceab5f2263 Configure Longitudinal section diagram to use the new way.
Andre Heinecke <aheinecke@intevation.de>
parents: 7123
diff changeset
508 addAxisDataset(dataset, diagramAttributes.getAxisIndex(axisName), visible);
49ceab5f2263 Configure Longitudinal section diagram to use the new way.
Andre Heinecke <aheinecke@intevation.de>
parents: 7123
diff changeset
509 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
510
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
511 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
512 * Add the given vertical marker to the chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
513 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
514 public void addDomainMarker(Marker marker) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
515 addDomainMarker(marker, true);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
516 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
517
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
518
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
519 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
520 * Add the given vertical marker to the chart.<b>Note:</b> the marker is
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
521 * added to the chart only if it is not null and if <i>visible</i> is true.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
522 * @param marker The marker that should be added to the chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
523 * @param visible The visibility of the marker.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
524 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
525 public void addDomainMarker(Marker marker, boolean visible) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
526 if (visible && marker != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
527 domainMarkers.add(marker);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
528 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
529 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
530
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
531
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
532 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
533 * Add the given vertical marker to the chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
534 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
535 public void addValueMarker(Marker marker) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
536 addValueMarker(marker, true);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
537 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
538
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
539
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
540 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
541 * Add the given horizontal marker to the chart.<b>Note:</b> the marker is
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
542 * added to the chart only if it is not null and if <i>visible</i> is true.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
543 * @param marker The marker that should be added to the chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
544 * @param visible The visibility of the marker.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
545 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
546 public void addValueMarker(Marker marker, boolean visible) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
547 if (visible && marker != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
548 valueMarkers.add(marker);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
549 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
550 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
551
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
552
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
553 protected void addMarkers(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
554 for(Marker marker : domainMarkers) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
555 plot.addDomainMarker(marker);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
556 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
557 for(Marker marker : valueMarkers) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
558 plot.addRangeMarker(marker);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
559 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
560 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
561
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
562
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
563 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
564 * Effect: extend range of x axis to include given limits.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
565 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
566 * @param bounds the given ("minimal") bounds.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
567 * @param index index of axis to be merged.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
568 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
569 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
570 protected void combineXBounds(Bounds bounds, int index) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
571 if (!(bounds instanceof DoubleBounds)) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
572 logger.warn("Unsupported Bounds type: " + bounds.getClass());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
573 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
574 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
575
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
576 DoubleBounds dBounds = (DoubleBounds) bounds;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
577
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
578 if (dBounds == null
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
579 || Double.isNaN((Double) dBounds.getLower())
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
580 || Double.isNaN((Double) dBounds.getUpper())) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
581 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
582 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
583
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
584 Bounds old = getXBounds(index);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
585
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
586 if (old != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
587 dBounds = (DoubleBounds) dBounds.combine(old);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
588 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
589
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
590 setXBounds(index, dBounds);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
591 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
592
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
593
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
594 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
595 protected void combineYBounds(Bounds bounds, int index) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
596 if (!(bounds instanceof DoubleBounds)) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
597 logger.warn("Unsupported Bounds type: " + bounds.getClass());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
598 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
599 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
600
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
601 DoubleBounds dBounds = (DoubleBounds) bounds;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
602
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
603 if (dBounds == null
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
604 || Double.isNaN((Double) dBounds.getLower())
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
605 || Double.isNaN((Double) dBounds.getUpper())) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
606 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
607 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
608
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
609 Bounds old = getYBounds(index);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
610
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
611 if (old != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
612 dBounds = (DoubleBounds) dBounds.combine(old);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
613 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
614
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
615 setYBounds(index, dBounds);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
616 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
617
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
618
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
619 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
620 * If no data is visible, draw at least empty axis.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
621 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
622 private void recoverEmptyPlot(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
623 if (plot.getRangeAxis() == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
624 logger.debug("debug: No range axis");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
625 plot.setRangeAxis(createYAxis(0));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
626 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
627 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
628
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
629
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
630 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
631 * Expands X axes if only a point is shown.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
632 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
633 private void preparePointRanges(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
634 for (int i = 0, num = plot.getDomainAxisCount(); i < num; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
635
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
636 Integer key = Integer.valueOf(i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
637 Bounds b = getXBounds(key);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
638
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
639
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
640 if (b != null && b.getLower().equals(b.getUpper())) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
641 logger.debug("Check whether to expand a x axis.i ("+b.getLower() + "-" + b.getUpper()+")");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
642 setXBounds(key, ChartHelper.expandBounds(b, 5));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
643 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
644 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
645 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
646
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
647
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
648 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
649 * This method zooms the plot to the specified ranges in the attribute
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
650 * document or to the ranges specified by the min/max values in the
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
651 * datasets. <b>Note:</b> We determine the range manually if no zoom ranges
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
652 * are given, because JFreeCharts auto-zoom adds a margin to the left and
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
653 * right of the data area.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
654 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
655 * @param plot The XYPlot.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
656 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
657 protected void autoZoom(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
658 logger.debug("Zoom to specified ranges.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
659
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
660 Range xrange = getDomainAxisRange();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
661 Range yrange = getValueAxisRange();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
662
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
663 ValueAxis xAxis = plot.getDomainAxis();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
664
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
665 Range fixedXRange = getRangeForAxisFromSettings("X");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
666 if (fixedXRange != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
667 xAxis.setRange(fixedXRange);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
668 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
669 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
670 zoomX(plot, xAxis, getXBounds(0), xrange);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
671 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
672
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
673 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
674 ValueAxis yaxis = plot.getRangeAxis(i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
675
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
676 if (yaxis instanceof IdentifiableNumberAxis) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
677 IdentifiableNumberAxis idAxis = (IdentifiableNumberAxis) yaxis;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
678
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
679 Range fixedRange = getRangeForAxisFromSettings(idAxis.getId());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
680 if (fixedRange != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
681 yaxis.setRange(fixedRange);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
682 continue;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
683 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
684 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
685
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
686 if (yaxis == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
687 logger.debug("Zoom problem: no Y Axis for index: " + i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
688 continue;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
689 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
690
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
691 logger.debug("Prepare zoom settings for y axis at index: " + i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
692 zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
693 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
694 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
695
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
696
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
697 protected Range getDomainAxisRange() {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
698 String[] ranges = getDomainAxisRangeFromRequest();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
699
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
700 if (ranges == null || ranges.length < 2) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
701 logger.debug("No zoom range for domain axis specified.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
702 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
703 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
704
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
705 if (ranges[0].length() > 0 && ranges[1].length() > 0) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
706 try {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
707 double from = Double.parseDouble(ranges[0]);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
708 double to = Double.parseDouble(ranges[1]);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
709
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
710 if (from == 0 && to == 0) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
711 logger.debug("No range specified. Lower and upper X == 0");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
712 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
713 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
714
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
715 if (from > to) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
716 double tmp = to;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
717 to = from;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
718 from = tmp;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
719 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
720
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
721 return new Range(from, to);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
722 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
723 catch (NumberFormatException nfe) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
724 logger.warn("Wrong values for domain axis range.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
725 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
726 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
727
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
728 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
729 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
730
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
731
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
732 protected Range getValueAxisRange() {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
733 String[] ranges = getValueAxisRangeFromRequest();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
734
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
735 if (ranges == null || ranges.length < 2) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
736 logger.debug("No range specified. Lower and upper Y == 0");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
737 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
738 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
739
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
740 if (ranges[0].length() > 0 && ranges[1].length() > 0) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
741 try {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
742 double from = Double.parseDouble(ranges[0]);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
743 double to = Double.parseDouble(ranges[1]);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
744
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
745 if (from == 0 && to == 0) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
746 logger.debug("No range specified. Lower and upper Y == 0");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
747 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
748 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
749
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
750 return from > to
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
751 ? new Range(to, from)
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
752 : new Range(from, to);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
753 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
754 catch (NumberFormatException nfe) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
755 logger.warn("Wrong values for value axis range.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
756 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
757 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
758
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
759 return null;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
760 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
761
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
762
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
763 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
764 return zoom(plot, axis, bounds, x);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
765 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
766
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
767
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
768 protected boolean zoomY(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
769 return zoom(plot, axis, bounds, x);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
770 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
771
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
772
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
773 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
774 * Zooms the x axis to the range specified in the attribute document.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
775 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
776 * @param plot The XYPlot.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
777 * @param axis The axis the shoud be modified.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
778 * @param bounds The whole range specified by a dataset.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
779 * @param x A user defined range (null permitted).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
780 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
781 * @return true, if a zoom range was specified, otherwise false.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
782 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
783 protected boolean zoom(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
784
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
785 if (bounds == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
786 return false;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
787 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
788
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
789 if (x != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
790 Bounds computed = calculateZoom(bounds, x);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
791 computed.applyBounds(axis, AXIS_SPACE);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
792
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
793 logger.debug("Zoom axis to: " + computed);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
794
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
795 return true;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
796 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
797
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
798 bounds.applyBounds(axis, AXIS_SPACE);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
799 return false;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
800 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
801
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
802 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
803 * Calculates the start and end km for zoomed charts.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
804 * @param bounds The given total bounds (unzoomed).
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
805 * @param range The range specifying the zoom.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
806 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
807 * @return The start and end km for the zoomed chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
808 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
809 protected Bounds calculateZoom(Bounds bounds, Range range) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
810 double min = bounds.getLower().doubleValue();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
811 double max = bounds.getUpper().doubleValue();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
812
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
813 if (logger.isDebugEnabled()) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
814 logger.debug("Minimum is: " + min);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
815 logger.debug("Maximum is: " + max);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
816 logger.debug("Lower zoom is: " + range.getLowerBound());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
817 logger.debug("Upper zoom is: " + range.getUpperBound());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
818 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
819
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
820 double diff = max > min ? max - min : min - max;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
821
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
822 DoubleBounds computed = new DoubleBounds(
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
823 min + range.getLowerBound() * diff,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
824 min + range.getUpperBound() * diff);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
825 return computed;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
826 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
827
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
828 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
829 * Extract the minimum and maximum values for x and y axes
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
830 * which are stored in <i>xRanges</i> and <i>yRanges</i>.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
831 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
832 * @param index The index of the y-Axis.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
833 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
834 * @return a Range[] as follows: [x-Range, y-Range].
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
835 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
836 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
837 public Range[] getRangesForAxis(int index) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
838 logger.debug("getRangesForAxis " + index);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
839
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
840 Bounds rx = getXBounds(Integer.valueOf(0));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
841 Bounds ry = getYBounds(Integer.valueOf(index));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
842
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
843 if (rx == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
844 logger.warn("Range for x axis not set." +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
845 " Using default values: 0 - 1.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
846 rx = new DoubleBounds(0, 1);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
847 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
848 if (ry == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
849 logger.warn("Range for y" + index +
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
850 " axis not set. Using default values: 0 - 1.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
851 ry = new DoubleBounds(0, 1);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
852 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
853
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
854 return new Range[] {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
855 new Range(rx.getLower().doubleValue(), rx.getUpper().doubleValue()),
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
856 new Range(ry.getLower().doubleValue(), ry.getUpper().doubleValue())
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
857 };
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
858 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
859
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
860
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
861 /** Get X (usually horizontal) extent for given axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
862 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
863 public Bounds getXBounds(int axis) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
864 return xBounds.get(axis);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
865 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
866
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
867
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
868 /** Set X (usually horizontal) extent for given axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
869 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
870 protected void setXBounds(int axis, Bounds bounds) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
871 if (bounds.getLower() == bounds.getUpper()) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
872 xBounds.put(axis, ChartHelper.expandBounds(bounds, 5d));
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
873 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
874 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
875 xBounds.put(axis, bounds);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
876 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
877 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
878
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
879
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
880 /** Get Y (usually vertical) extent for given axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
881 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
882 public Bounds getYBounds(int axis) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
883 return yBounds.get(axis);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
884 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
885
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
886
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
887 /** Set Y (usually vertical) extent for given axis. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
888 @Override
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
889 protected void setYBounds(int axis, Bounds bounds) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
890 yBounds.put(axis, bounds);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
891 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
892
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
893
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
894 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
895 * Adjusts the axes of a plot. This method sets the <i>labelFont</i> of the
7106
ed8623b989f3 Minor cleanup / doc
Andre Heinecke <aheinecke@intevation.de>
parents: 7104
diff changeset
896 * X axis and applies the inversion if inverted is true.
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
897 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
898 * (Duplicate in TimeseriesChartGenerator)
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
899 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
900 * @param plot The XYPlot of the chart.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
901 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
902 protected void adjustAxes(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
903 ValueAxis xaxis = plot.getDomainAxis();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
904
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
905 ChartSettings chartSettings = getChartSettings();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
906 if (chartSettings == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
907 return;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
908 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
909
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
910 Font labelFont = new Font(
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
911 DEFAULT_FONT_NAME,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
912 Font.BOLD,
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
913 getXAxisLabelFontSize());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
914
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
915 xaxis.setLabelFont(labelFont);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
916 xaxis.setTickLabelFont(labelFont);
7104
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
917
7112
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
918 logger.debug("Adjusting xAxis. Inverted?: " + inverted);
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
919 if (inverted) {
7104
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
920 xaxis.setInverted(true);
eb3a2bc5d591 Add more Inversion logic to the DiagramGenerator
Andre Heinecke <aheinecke@intevation.de>
parents: 7099
diff changeset
921 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
922 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
923
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
924
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
925 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
926 * This method walks over all axes (domain and range) of <i>plot</i> and
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
927 * calls localizeDomainAxis() for domain axes or localizeRangeAxis() for
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
928 * range axes.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
929 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
930 * @param plot The XYPlot.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
931 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
932 private void localizeAxes(XYPlot plot) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
933 for (int i = 0, num = plot.getDomainAxisCount(); i < num; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
934 ValueAxis axis = plot.getDomainAxis(i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
935
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
936 if (axis != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
937 localizeDomainAxis(axis);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
938 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
939 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
940 logger.warn("Domain axis at " + i + " is null.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
941 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
942 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
943
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
944 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
945 ValueAxis axis = plot.getRangeAxis(i);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
946
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
947 if (axis != null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
948 localizeRangeAxis(axis);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
949 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
950 else {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
951 logger.warn("Range axis at " + i + " is null.");
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
952 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
953 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
954 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
955
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
956
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
957 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
958 * Overrides the NumberFormat with the NumberFormat for the current locale
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
959 * that is provided by getLocale().
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
960 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
961 * @param domainAxis The domain axis that needs localization.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
962 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
963 protected void localizeDomainAxis(ValueAxis domainAxis) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
964 NumberFormat nf = NumberFormat.getInstance(getLocale());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
965 ((NumberAxis) domainAxis).setNumberFormatOverride(nf);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
966 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
967
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
968
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
969 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
970 * Overrides the NumberFormat with the NumberFormat for the current locale
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
971 * that is provided by getLocale().
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
972 *
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
973 * @param rangeAxis The domain axis that needs localization.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
974 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
975 protected void localizeRangeAxis(ValueAxis rangeAxis) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
976 NumberFormat nf = NumberFormat.getInstance(getLocale());
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
977 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
978 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
979
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
980
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
981 /**
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
982 * Create a hash from a legenditem.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
983 * This hash can then be used to merge legend items labels.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
984 * @return hash for given legenditem to identify mergeables.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
985 */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
986 public static String legendItemHash(LegendItem li) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
987 // TODO Do proper implementation. Ensure that only mergable sets are created.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
988 // getFillPaint()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
989 // getFillPaintTransformer()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
990 // getLabel()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
991 // getLine()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
992 // getLinePaint()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
993 // getLineStroke()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
994 // getOutlinePaint()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
995 // getOutlineStroke()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
996 // Shape getShape()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
997 // String getToolTipText()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
998 // String getURLText()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
999 // boolean isLineVisible()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1000 // boolean isShapeFilled()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1001 // boolean isShapeOutlineVisible()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1002 // boolean isShapeVisible()
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1003 String hash = li.getLinePaint().toString();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1004 String label = li.getLabel();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1005 if (label.startsWith("W (") || label.startsWith("W(")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1006 hash += "-W-";
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1007 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1008 else if (label.startsWith("Q(") || label.startsWith("Q (")) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1009 hash += "-Q-";
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1010 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1011
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1012 // WQ.java holds example of using regex Matcher/Pattern.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1013
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1014 return hash;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1015 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1016
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1017 /** True if x axis has been inverted. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1018 public boolean isInverted() {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1019 return inverted;
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1020 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1021
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1022
7106
ed8623b989f3 Minor cleanup / doc
Andre Heinecke <aheinecke@intevation.de>
parents: 7104
diff changeset
1023 /** Set to true if x axis should be inverted.
ed8623b989f3 Minor cleanup / doc
Andre Heinecke <aheinecke@intevation.de>
parents: 7104
diff changeset
1024 * This can not be set to false afterwards. */
7112
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
1025 public void setInverted(boolean value) {
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
1026 /* One request to invert dominates. */
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
1027 if (!inverted) {
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
1028 inverted = value;
7b88b87958ac Fix applying the inversion of diagrams.
Andre Heinecke <aheinecke@intevation.de>
parents: 7107
diff changeset
1029 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1030 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1031
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1032 @Override
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1033 public String getDefaultChartTitle() {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1034 DiagramAttributes.Title dTitle = diagramAttributes.getTitle();
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1035 if (dTitle == null) {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1036 return "Title not configured in conf.xml";
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1037 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1038
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1039 return dTitle.evaluate((D4EArtifact)getMaster(), context);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1040 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1041
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1042 @Override
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1043 public String getDefaultChartSubtitle() {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1044 DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle();
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1045 if (dTitle == null) {
7122
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1046 /* Subtitle is optional */
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1047 return null;
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1048 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1049
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1050 return dTitle.evaluate((D4EArtifact)getMaster(), context);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1051 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1052
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1053 /**
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1054 * Get internationalized label for the x axis.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1055 */
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1056 @Override
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1057 protected String getDefaultXAxisLabel() {
7143
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1058 DiagramAttributes.DomainAxisAttributes dx =
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1059 diagramAttributes.getDomainAxis();
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1060
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1061 if (dx != null) {
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1062 DiagramAttributes.Title t = dx.getTitle();
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1063 if (t != null) {
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1064 return t.evaluate((D4EArtifact)getMaster(), context);
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1065 }
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1066 }
7143
053e39436ba3 Diagrams: Determine if axis should be inverted dynamically.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7124
diff changeset
1067 return "Domain Axis Title not configured in conf.xml";
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1068 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1069
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1070 @Override
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1071 protected String getDefaultYAxisLabel(String axisName) {
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1072 Set labelSet = axesLabels.get(diagramAttributes.getAxisIndex(axisName));
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1073 logger.debug("Labels for axis: " + labelSet);
7603
25bce6e8beea (issue1225) Use label code also when only one item is present
Andre Heinecke <aheinecke@intevation.de>
parents: 7597
diff changeset
1074 if (labelSet != null && !labelSet.isEmpty()) {
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1075 String label = StringUtils.join(labelSet, ", ");
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1076 Matcher units = UNIT_PATTERN.matcher(label);
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1077 if (units.find()) {
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1078 String firstUnit = units.group();
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1079 label = units.replaceAll("");
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1080 label += firstUnit;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1081 }
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1082 return label;
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1083 }
7122
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1084 for (Processor pr: diagramAttributes.getProcessorsForAxisName(axisName)) {
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1085 String label = pr.getAxisLabel(this);
7122
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1086 if (label != null) {
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1087 return label;
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1088 }
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1089 }
038a04e001d7 Handle multiple processors for axis labeling.
Andre Heinecke <aheinecke@intevation.de>
parents: 7112
diff changeset
1090 return "No configured axis label";
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1091 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1092
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1093
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1094 /**
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1095 * Creates a list of Section for the chart's Y axes.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1096 *
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1097 * @return a list of Y axis sections.
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1098 */
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1099 protected List<AxisSection> buildYAxisSections() {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1100 List<AxisSection> axisSections = new ArrayList<AxisSection>();
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1101
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1102 List<DiagramAttributes.AxisAttributes> axesAttrs = diagramAttributes.getAxesAttributes();
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1103
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1104 for (int i = 0, n = axesAttrs.size(); i < n; i++) {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1105 AxisSection ySection = new AxisSection();
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1106 String axisName = diagramAttributes.getAxisName(i);
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1107 ySection.setIdentifier(axisName);
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1108 ySection.setLabel(getYAxisLabel(axisName));
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1109 ySection.setSuggestedLabel(getDefaultYAxisLabel(axisName));
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1110 ySection.setFontSize(14);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1111 ySection.setFixed(false);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1112
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1113 // XXX We are able to find better default ranges that [0,0], the
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1114 // only problem is, that we do NOT have a better range than [0,0]
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1115 // for each axis, because the initial chart will not have a dataset
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1116 // for each axis set!
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1117 ySection.setUpperRange(0d);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1118 ySection.setLowerRange(0d);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1119
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1120 axisSections.add(ySection);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1121 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1122
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1123 return axisSections;
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1124 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1125
7241
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1126 protected String getYAxisLabel(int index) {
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1127 return getYAxisLabel(diagramAttributes.getAxisName(index));
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1128 }
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1129
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1130 /**
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1131 * Returns the Y-Axis label of a chart at position <i>pos</i>.
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1132 *
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1133 * @return the Y-Axis label of a chart at position <i>0</i>.
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1134 */
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1135 protected String getYAxisLabel(String axisName) {
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1136 ChartSettings chartSettings = getChartSettings();
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1137 if (chartSettings == null) {
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1138 return getDefaultYAxisLabel(axisName);
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1139 }
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1140 AxisSection as = chartSettings.getAxisSection(axisName);
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1141 if (as != null) {
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1142 String label = as.getLabel();
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1143 if (label != null && !label.equals(as.getSuggestedLabel())) {
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1144 // Only if the suggested label is not the current label
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1145 // the user has modified the label. Otherwise lets
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1146 // recalculate the label
7084
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1147 return label;
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1148 }
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1149 }
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1150
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1151 return getDefaultYAxisLabel(axisName);
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1152 }
f0731aa7b735 Implement Label handling
Andre Heinecke <aheinecke@intevation.de>
parents: 7081
diff changeset
1153
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1154 protected String axisIndexToName(int index) {
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1155 return diagramAttributes.getAxisName(index);
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1156 }
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1157
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1158 /** Add the acutal data to the diagram according to the processors.
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1159 * For every outable facets, this function is
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1160 * called and handles the data accordingly. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1161 @Override
7052
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1162 public void doOut(
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1163 ArtifactAndFacet bundle,
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1164 ThemeDocument theme,
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1165 boolean visible
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1166 ) {
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1167 String facetName = bundle.getFacetName();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1168 Facet facet = bundle.getFacet();
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1169
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1170 /* A conservative security check */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1171 if (facetName == null || facet == null) {
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1172 /* Can't happen,.. */
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1173 logger.error("doOut called with null facet.");
7052
7056fa3b1f75 Call processors from configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7051
diff changeset
1174 return;
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1175 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1176
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1177 logger.debug("DoOut for facet: " + facetName);
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1178
7096
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1179 boolean found = false;
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1180 List<Processor> prL = diagramAttributes.getProcessors();
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1181 for (Processor pr: prL) {
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1182 if (pr.canHandle(facetName)) {
7096
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1183 found = true;
7068
726d998dce29 Remove Axis Walker, unabstract Diagram generator
Andre Heinecke <aheinecke@intevation.de>
parents: 7059
diff changeset
1184 pr.doOut(this, bundle, theme, visible);
7597
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1185
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1186 if (visible) {
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1187 // Save the label that should be added for this processor
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1188 int axisIdx = diagramAttributes.getAxisIndex(pr.getAxisName());
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1189 LinkedHashSet<String> curLabels = axesLabels.get(axisIdx);
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1190 if (curLabels == null) {
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1191 curLabels = new LinkedHashSet<String>(5);
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1192 }
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1193 curLabels.add(pr.getAxisLabel(this));
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1194 axesLabels.put(axisIdx, curLabels);
fca46ce8e4f5 (issue1225) Implement Magic labels.
Andre Heinecke <aheinecke@intevation.de>
parents: 7248
diff changeset
1195 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1196 }
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1197 }
7096
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1198 if (!found) {
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1199 logger.warn("No processor found for: " + facetName);
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1200 if (logger.isDebugEnabled()) {
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1201 logger.debug("Configured processors for this diagram are:");
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1202 for (Processor pr: prL) {
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1203 logger.debug(pr.getClass().getName());
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1204 }
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1205 }
5c059c05b100 Add useful debug output for diagram generator debugging
Andre Heinecke <aheinecke@intevation.de>
parents: 7088
diff changeset
1206 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1207 }
7107
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1208
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1209 @Override
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1210 protected NumberAxis createYAxis(int index) {
7241
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1211 NumberAxis axis;
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1212 boolean logarithmic = (Boolean)diagramAttributes.getAxesAttributes().
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1213 get(index).isLog().evaluate((D4EArtifact)getMaster(), context);
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1214
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1215 if (logarithmic) {
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1216 axis = new LogarithmicAxis(getYAxisLabel(index));
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1217 } else {
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1218 axis = super.createYAxis(index);
32db4f89b65f Add new option to diagram axes "logarithmic" that can be set to an evaluator
Andre Heinecke <aheinecke@intevation.de>
parents: 7167
diff changeset
1219 }
7107
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1220
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1221 if (diagramAttributes.getAxesAttributes().get(index).includeZero()) {
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1222 axis.setAutoRangeIncludesZero(true);
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1223 }
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1224 return axis;
564033adf9c6 Handle axis include zero setting for the new processing architecture
Andre Heinecke <aheinecke@intevation.de>
parents: 7106
diff changeset
1225 }
7044
6ab1464021ae Add DiagramGenerator which should mainly replace xygenerator
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1226 }

http://dive4elements.wald.intevation.org