annotate artifacts/src/main/java/org/dive4elements/river/exports/InfoGeneratorHelper.java @ 7069:9b52c501c57e generator-refactoring

Add InfoGenerator Hacks to be removed soon. Neccessary for testing but they will be removed again in one of the next commits
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 20 Sep 2013 14:56:46 +0200
parents af13ceeba52a
children 3dc740c51f9b
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5335
diff changeset
9 package org.dive4elements.river.exports;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import java.awt.geom.AffineTransform;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.awt.geom.NoninvertibleTransformException;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import java.awt.geom.Rectangle2D;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
15 import java.util.Date;
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
16
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import org.w3c.dom.Document;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.w3c.dom.Element;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.jfree.chart.ChartRenderingInfo;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.jfree.chart.JFreeChart;
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
24 import org.jfree.chart.axis.DateAxis;
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
25 import org.jfree.chart.axis.NumberAxis;
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
26 import org.jfree.chart.axis.ValueAxis;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import org.jfree.chart.plot.XYPlot;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import org.jfree.data.Range;
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
29 import org.jfree.data.xy.XYDataset;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5335
diff changeset
31 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5335
diff changeset
32 import org.dive4elements.artifacts.common.utils.XMLUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5335
diff changeset
33 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5335
diff changeset
35 import org.dive4elements.river.jfree.Bounds;
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
36
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 /**
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * This class helps generating chart info documents.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 */
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 public class InfoGeneratorHelper {
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
5335
05eeedc5b156 Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4433
diff changeset
45 /** Private logging instance. */
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 private static final Logger logger =
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 Logger.getLogger(InfoGeneratorHelper.class);
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
49 protected ChartGenerator generator;
7069
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
50 protected ChartGenerator2 generator2;
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
51
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
52
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
53 public InfoGeneratorHelper(ChartGenerator generator) {
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
54 this.generator = generator;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
7069
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
57 public InfoGeneratorHelper(ChartGenerator2 generator) {
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
58 this.generator2 = generator2;
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
59 }
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
60
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 /**
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 * Triggers the creation of the chart info document.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 * @param chart The JFreeChart chart.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 * @param info An info object that has been created while chart creation.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 * @return the info document.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
70 public Document createInfoDocument(
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 JFreeChart chart,
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 ChartRenderingInfo info)
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 {
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 logger.debug("InfoGeneratorHelper.createInfoDocument");
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 Document doc = XMLUtils.newDocument();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 ElementCreator cr = new ElementCreator(
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 doc,
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 ArtifactNamespaceContext.NAMESPACE_URI,
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 ArtifactNamespaceContext.NAMESPACE_PREFIX);
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 Element chartinfo = cr.create("chartinfo");
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
85 chartinfo.appendChild(createAxesElements(cr, chart));
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
86 chartinfo.appendChild(createTransformationElements(cr, chart, info));
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 doc.appendChild(chartinfo);
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 return doc;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 /**
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
95 * This method create a axes element that contains all domain and range
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
96 * axes of the given chart.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
97 *
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
98 * @param cr The ElementCreator.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
99 * @param chart The chart that provides range information of its axes.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
100 *
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
101 * @return an element with axes information.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
102 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
103 protected Element createAxesElements(
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
104 ElementCreator cr,
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
105 JFreeChart chart)
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
106 {
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
107 logger.debug("InfoGeneratorHelper.createRangeElements");
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
108
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
109 Element axes = cr.create("axes");
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
110
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
111 XYPlot plot = (XYPlot) chart.getPlot();
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
112
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
113 int dAxisCount = plot.getDomainAxisCount();
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
114 for (int i = 0; i < dAxisCount; i++) {
663
51172d56e8bc Only generate an axis element if a axis really exists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 659
diff changeset
115 ValueAxis axis = plot.getDomainAxis(i);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
116 XYDataset data = plot.getDataset(i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
117
663
51172d56e8bc Only generate an axis element if a axis really exists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 659
diff changeset
118 if (axis != null) {
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
119 Element e = createAxisElement(cr, axis, data, "domain", i);
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
120 axes.appendChild(e);
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
121 }
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
122 }
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
123
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
124 int rAxisCount = plot.getRangeAxisCount();
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
125 for (int i = 0; i < rAxisCount; i++) {
663
51172d56e8bc Only generate an axis element if a axis really exists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 659
diff changeset
126 ValueAxis axis = plot.getRangeAxis(i);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
127 XYDataset data = plot.getDataset(i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
128
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
129 if (axis == null || data == null) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
130 logger.warn("Axis or dataset is empty at pos: " + i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
131 continue;
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
132 }
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
133
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
134 Element e = createAxisElement(cr, axis, data, "range", i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
135 axes.appendChild(e);
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
136 }
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
137
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
138 return axes;
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
139 }
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
140
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
141
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
142 /**
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
143 * This method create a axis element for a given <i>axis</i> and
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
144 * <i>type</i>. Type can be one of 'domain' or 'range'.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
145 *
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
146 * @param cr The ElementCreator
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
147 * @param axis The axis that provides range information.
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
148 * @param dataset The dataset for min/max determination.
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
149 * @param type The axis type ('domain' or 'range').
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
150 * @param pos The position in the chart.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
151 *
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
152 * @return An element that contains range information of a given axis.
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
153 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
154 protected Element createAxisElement(
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
155 ElementCreator cr,
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
156 ValueAxis axis,
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
157 XYDataset dataset,
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
158 String type,
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
159 int pos)
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
160 {
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
161 logger.debug("createAxisElement " + pos);
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
162 logger.debug("Axis is from type: " + axis.getClass());
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
163
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
164 Element e = cr.create(type);
1944
21a4d2c677a1 Changed doOut signature, side effect from blackboard feature (to come).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1684
diff changeset
165 cr.addAttr(e, "pos", String.valueOf(pos), true);
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
166
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
167 if (axis instanceof DateAxis) {
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
168 prepareDateAxisElement(
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
169 e, cr, (DateAxis) axis, dataset, type, pos);
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
170 }
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
171 else {
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
172 prepareNumberAxisElement(
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
173 e, cr, (NumberAxis) axis, dataset, type, pos);
2261
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
174 }
6aeb71517136 Registered an Info generator for historical discharge curves; made some adaptions in XYChartGenerator, ChartGenerator and TimeseriesChartGenerator.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1944
diff changeset
175
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
176 return e;
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
177 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
178
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
179
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
180 protected Element prepareNumberAxisElement(
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
181 Element e,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
182 ElementCreator cr,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
183 NumberAxis axis,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
184 XYDataset dataset,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
185 String type,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
186 int pos
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
187 ) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
188 Range range = axis.getRange();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
189
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
190 cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
191 cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
192 cr.addAttr(e, "axistype", "number", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
193
7069
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
194 Range[] rs = generator2 == null ? generator.getRangesForAxis(pos) : generator2.getRangesForAxis(pos);
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
195 Range r = null;
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
196
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
197 if (type.equals("range")) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
198 r = rs[1];
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
199 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
200 else {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
201 r = rs[0];
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
202 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
203
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
204 cr.addAttr(e, "min", String.valueOf(r.getLowerBound()), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
205 cr.addAttr(e, "max", String.valueOf(r.getUpperBound()), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
206
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
207 return e;
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
208 }
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
209
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
210
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
211 protected Element prepareDateAxisElement(
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
212 Element e,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
213 ElementCreator cr,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
214 DateAxis axis,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
215 XYDataset dataset,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
216 String type,
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
217 int pos
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
218 ) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
219 Date from = axis.getMinimumDate();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
220 Date to = axis.getMaximumDate();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
221
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
222 Bounds bounds = null;
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
223 if (type.equals("range")) {
7069
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
224 bounds = generator2 == null ? generator.getYBounds(pos) : generator2.getYBounds(pos);
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
225 }
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
226 else {
7069
9b52c501c57e Add InfoGenerator Hacks to be removed soon.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
227 bounds = generator2 == null ? generator.getXBounds(pos) : generator2.getXBounds(pos);
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
228 }
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
229
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
230 cr.addAttr(e, "axistype", "date", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
231 cr.addAttr(e, "from", String.valueOf(from.getTime()), true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
232 cr.addAttr(e, "to", String.valueOf(to.getTime()), true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
233
2330
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
234 cr.addAttr(e, "min", bounds.getLower().toString(), true);
594885703687 Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2273
diff changeset
235 cr.addAttr(e, "max", bounds.getUpper().toString(), true);
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
236
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
237 return e;
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
238 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
239
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
240
659
ab43f36f4af6 The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 657
diff changeset
241 /**
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 * This method appends the values of a transformation matrix to transform
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 * image pixel coordinates into chart coordinates.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 * @param cr The ElementCreator.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 * @param chart The chart object.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 * @param info The ChartRenderingInfo that is filled while chart creation.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 * @return an element that contains one or more transformation matrix.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 */
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
251 protected Element createTransformationElements(
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 ElementCreator cr,
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 JFreeChart chart,
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 ChartRenderingInfo info)
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 {
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
256 logger.debug("InfoGeneratorHelper.createTransformationElements");
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 Element tf = cr.create("transformation-matrix");
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 Rectangle2D dataArea = info.getPlotInfo().getDataArea();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
262 XYPlot plot = (XYPlot) chart.getPlot();
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
263 ValueAxis xAxis = plot.getDomainAxis();
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
265 if (xAxis == null) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
266 logger.error("There is no x axis in the chart!");
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
267 return null;
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
268 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
269
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
270 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
271 ValueAxis yAxis = plot.getRangeAxis(i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
272
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
273 if (yAxis == null) {
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
274 logger.warn("No y axis at pos " + i + " existing.");
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
275 continue;
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
276 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
277
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
278 Element matrix = createTransformationElement(
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
279 cr, xAxis, yAxis, dataArea, i);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
280
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
281 tf.appendChild(matrix);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
282 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
283
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
284 return tf;
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
285 }
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
286
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
287
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
288 /**
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
289 * Creates an element that contains values used to transform coordinates
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
290 * of a coordinate system A into a coordinate system B.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
291 *
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
292 * @param cr The ElementCreator.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
293 * @param xAxis The x axis of the target coordinate system.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
294 * @param yAxis The y axis of the target coordinate system.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
295 * @param dataArea The pixel coordinates of the chart image.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
296 * @param pos The dataset position.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
297 *
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
298 * @return an element that contains transformation matrix values.
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
299 */
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
300 protected Element createTransformationElement(
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
301 ElementCreator cr,
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
302 ValueAxis xAxis,
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
303 ValueAxis yAxis,
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
304 Rectangle2D dataArea,
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
305 int pos)
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
306 {
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
307 double[] tm = createTransformationMatrix(dataArea, xAxis, yAxis);
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
309 Element matrix = cr.create("matrix");
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
311 cr.addAttr(matrix, "pos", String.valueOf(pos), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
312 cr.addAttr(matrix, "sx", String.valueOf(tm[0]), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
313 cr.addAttr(matrix, "sy", String.valueOf(tm[1]), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
314 cr.addAttr(matrix, "tx", String.valueOf(tm[2]), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
315 cr.addAttr(matrix, "ty", String.valueOf(tm[3]), true);
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
316
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
317 if (xAxis instanceof DateAxis) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
318 cr.addAttr(matrix, "xtype", "date", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
319 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
320 else {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
321 cr.addAttr(matrix, "xtype", "number", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
322 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
323
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
324 if (yAxis instanceof DateAxis) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
325 cr.addAttr(matrix, "ytype", "date", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
326 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
327 else {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
328 cr.addAttr(matrix, "ytype", "number", true);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
329 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
330
673
b22f21b173a7 Changed the zoom process - the values in the chart request document are percentual values that apply to every axis.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 663
diff changeset
331 return matrix;
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
332 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
333
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
334
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
335 /**
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
336 * This method determines a transformation matrix to transform pixel
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
337 * coordinates of the chart image into chart coordinates.
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
338 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
339 * @param dataArea The rectangle that contains the data points of the chart.
3270
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2330
diff changeset
340 * @param xAxis The x axis.
4ac581062c40 Fix various documentation issues.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2330
diff changeset
341 * @param yAxis The y axis.
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
342 *
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
343 * @return a double array as follows: [sx, sy, tx, ty].
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
344 */
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
345 protected static double[] createTransformationMatrix(
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
346 Rectangle2D dataArea,
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
347 ValueAxis xAxis,
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
348 ValueAxis yAxis)
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
349 {
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
350 logger.debug("InfoGeneratorHelper.createTransformationMatrix");
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
351
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
352 double offsetX = dataArea.getX();
657
ac1399d325e9 Removed asymmetrical "- 1" from width calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 648
diff changeset
353 double width = dataArea.getWidth();
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
354 double offsetY = dataArea.getY();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
355 double height = dataArea.getHeight();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
356
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
357 Range xRange = getRangeFromAxis(xAxis);
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
358 Range yRange = getRangeFromAxis(yAxis);
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
359
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
360 double lowerX = xRange.getLowerBound();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
361 double upperX = xRange.getUpperBound();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
362 double lowerY = yRange.getLowerBound();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
363 double upperY = yRange.getUpperBound();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
364
648
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
365 if (xAxis.isInverted()) {
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
366 logger.info("X-Axis is inverted!");
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
367
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
368 double tmp = upperX;
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
369 upperX = lowerX;
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
370 lowerX = tmp;
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
371 }
d4c4fefb095b The matrix that is used to transform chart image coordinates into chart coordinates supports inverted x-axis now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 647
diff changeset
372
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
373 double dMoveX = upperX - lowerX;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
374 double fMoveX = width * lowerX;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
375 double dMoveY = lowerY - upperY;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
376 double fMoveY = height * upperY;
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
377
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
378 AffineTransform t1 = AffineTransform.getTranslateInstance(
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
379 offsetX - ( fMoveX / dMoveX ),
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
380 offsetY - ( fMoveY / dMoveY ) );
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
381
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
382 AffineTransform t2 = AffineTransform.getScaleInstance(
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
383 width / (upperX - lowerX),
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
384 height / (lowerY - upperY));
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
385
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
386 t1.concatenate(t2);
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
387
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
388 try {
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
389 t1.invert();
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
390
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
391 double[] c = new double[6];
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
392 t1.getMatrix(c);
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
393
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
394 return new double[] { c[0], c[3], c[4], c[5] };
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
395 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
396 catch (NoninvertibleTransformException e) {
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
397 // do nothing
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
398 logger.warn("Matrix is not invertible.");
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
399 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
400
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
401 return new double[] { 1d, 1d, 0d, 0d };
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
402 }
2273
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
403
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
404
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
405 protected static Range getRangeFromAxis(ValueAxis axis) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
406 if (axis instanceof DateAxis) {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
407 DateAxis dAxis = (DateAxis) axis;
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
408 Date min = dAxis.getMinimumDate();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
409 Date max = dAxis.getMaximumDate();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
410
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
411 return new Range(min.getTime(), max.getTime());
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
412 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
413 else {
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
414 return axis.getRange();
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
415 }
7b8d59436be3 Set proper bounds for date axes in the chart info document; tell the transformation matrix which type it is (date/number).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2261
diff changeset
416 }
647
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
417 }
bb484489d3df Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
418 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org