Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java @ 728:56bcf56b1fe0
#157 Both types of discharge curves will now include the '0' value on the x-axis.
flys-artifacts/trunk@2218 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 23 Jun 2011 13:42:47 +0000 |
parents | b22f21b173a7 |
children | bdb05dc9b763 |
rev | line source |
---|---|
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.exports; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 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
|
4 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
|
5 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
|
6 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 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
|
8 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
|
9 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 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
|
11 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 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
|
13 import org.jfree.chart.JFreeChart; |
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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.common.utils.XMLUtils; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 /** |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * 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
|
26 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * @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
|
28 */ |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public class InfoGeneratorHelper { |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 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
|
32 Logger.getLogger(InfoGeneratorHelper.class); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
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
|
35 protected XYChartGenerator generator; |
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
|
36 |
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
|
37 |
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
|
38 public InfoGeneratorHelper(XYChartGenerator generator) { |
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
|
39 this.generator = generator; |
647
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 |
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 /** |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 * 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
|
45 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * @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
|
47 * @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
|
48 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 * @return the info document. |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 */ |
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 public Document createInfoDocument( |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 JFreeChart chart, |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 ChartRenderingInfo info) |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 { |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 logger.debug("InfoGeneratorHelper.createInfoDocument"); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 Document doc = XMLUtils.newDocument(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 ElementCreator cr = new ElementCreator( |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 doc, |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 ArtifactNamespaceContext.NAMESPACE_URI, |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 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
|
65 |
659
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
66 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
|
67 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
|
68 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 doc.appendChild(chartinfo); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 return doc; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
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 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 /** |
659
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
76 * 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
|
77 * 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
|
78 * |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
79 * @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
|
80 * @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
|
81 * |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
82 * @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
|
83 */ |
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
|
84 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
|
85 ElementCreator cr, |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
86 JFreeChart chart) |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
87 { |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
88 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
|
89 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
90 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
|
91 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
92 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
|
93 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 |
663
51172d56e8bc
Only generate an axis element if a axis really exists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
659
diff
changeset
|
99 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
|
100 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
|
101 axes.appendChild(e); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
102 } |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
103 } |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
104 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 |
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
|
110 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
|
111 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
|
112 continue; |
659
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
113 } |
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
|
114 |
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
|
115 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
|
116 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
|
117 } |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
118 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
119 return axes; |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
120 } |
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 * 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
|
125 * <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
|
126 * |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
127 * @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
|
128 * @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
|
129 * @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
|
130 * @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
|
131 * @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
|
132 * |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
133 * @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
|
134 */ |
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
|
135 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
|
136 ElementCreator cr, |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
137 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
|
138 XYDataset dataset, |
659
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
139 String type, |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
140 int pos) |
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 Range range = axis.getRange(); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
143 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
144 Element e = cr.create(type); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
145 cr.addAttr(e, "pos", String.valueOf(pos), true); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
146 cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
147 cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true); |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
148 |
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
|
149 Range[] rs = generator.getRangesForDataset(dataset); |
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
|
150 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
|
151 |
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
|
152 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
|
153 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
|
154 } |
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
|
155 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
|
156 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
|
157 } |
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
|
158 |
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
|
159 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
|
160 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
|
161 |
659
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
162 return e; |
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 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
165 |
ab43f36f4af6
The ChartInfoGenerator appends axes range information to the document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
657
diff
changeset
|
166 /** |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 * 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
|
168 * 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
|
169 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 * @param cr The ElementCreator. |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 * @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
|
172 * @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
|
173 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 * @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
|
175 */ |
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
|
176 protected Element createTransformationElements( |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 ElementCreator cr, |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 JFreeChart chart, |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 ChartRenderingInfo info) |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 { |
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
|
181 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
|
182 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 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
|
184 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 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
|
186 |
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
|
187 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
|
188 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
|
189 |
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
|
190 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
|
191 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
|
192 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
|
193 } |
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
|
194 |
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 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
|
196 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
|
197 |
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 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
|
199 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
|
200 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
|
201 } |
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 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
|
204 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
|
205 |
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 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
|
207 } |
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
|
208 |
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
|
209 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
|
210 } |
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
|
211 |
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
|
212 |
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
|
213 /** |
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
|
214 * 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
|
215 * 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
|
216 * |
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
|
217 * @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
|
218 * @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
|
219 * @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
|
220 * @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
|
221 * @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
|
222 * |
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
|
223 * @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
|
224 */ |
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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 { |
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
|
232 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
|
233 |
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
|
234 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
|
235 |
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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 |
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
|
242 return matrix; |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 } |
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 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 /** |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 * 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
|
248 * 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
|
249 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 * @param dataArea The rectangle that contains the data points of the chart. |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
251 * @param xRange The x axis range. |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
252 * @param yRange The y axis range. |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
253 * |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 * @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
|
255 */ |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
256 protected static double[] createTransformationMatrix( |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
257 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
|
258 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
|
259 ValueAxis yAxis) |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
260 { |
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
|
261 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
|
262 |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 double offsetX = dataArea.getX(); |
657
ac1399d325e9
Removed asymmetrical "- 1" from width calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
648
diff
changeset
|
264 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
|
265 double offsetY = dataArea.getY(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 double height = dataArea.getHeight(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 |
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
|
268 Range xRange = xAxis.getRange(); |
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
|
269 Range yRange = yAxis.getRange(); |
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
|
270 |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 double lowerX = xRange.getLowerBound(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
272 double upperX = xRange.getUpperBound(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
273 double lowerY = yRange.getLowerBound(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
274 double upperY = yRange.getUpperBound(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
275 |
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
|
276 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
|
277 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
|
278 |
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
|
279 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
|
280 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
|
281 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
|
282 } |
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
|
283 |
647
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
284 double dMoveX = upperX - lowerX; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
285 double fMoveX = width * lowerX; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
286 double dMoveY = lowerY - upperY; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
287 double fMoveY = height * upperY; |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
288 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
289 AffineTransform t1 = AffineTransform.getTranslateInstance( |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
290 offsetX - ( fMoveX / dMoveX ), |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
291 offsetY - ( fMoveY / dMoveY ) ); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
292 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
293 AffineTransform t2 = AffineTransform.getScaleInstance( |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
294 width / (upperX - lowerX), |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
295 height / (lowerY - upperY)); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
296 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
297 t1.concatenate(t2); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
298 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
299 try { |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
300 t1.invert(); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
301 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
302 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
|
303 t1.getMatrix(c); |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
304 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
305 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
|
306 } |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
307 catch (NoninvertibleTransformException e) { |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
308 // do nothing |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
309 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
|
310 } |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
311 |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
312 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
|
313 } |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
314 } |
bb484489d3df
Introduced a new output generators for creating chart info documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
315 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |