comparison flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java @ 659:ab43f36f4af6

The ChartInfoGenerator appends axes range information to the document now. flys-artifacts/trunk@2065 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 07 Jun 2011 13:15:02 +0000
parents ac1399d325e9
children 51172d56e8bc
comparison
equal deleted inserted replaced
658:ed7c901ee712 659:ab43f36f4af6
56 ArtifactNamespaceContext.NAMESPACE_URI, 56 ArtifactNamespaceContext.NAMESPACE_URI,
57 ArtifactNamespaceContext.NAMESPACE_PREFIX); 57 ArtifactNamespaceContext.NAMESPACE_PREFIX);
58 58
59 Element chartinfo = cr.create("chartinfo"); 59 Element chartinfo = cr.create("chartinfo");
60 60
61 chartinfo.appendChild(createAxesElements(cr, chart));
61 chartinfo.appendChild(createTransformationElement(cr, chart, info)); 62 chartinfo.appendChild(createTransformationElement(cr, chart, info));
62 63
63 doc.appendChild(chartinfo); 64 doc.appendChild(chartinfo);
64 65
65 return doc; 66 return doc;
67 }
68
69
70 /**
71 * This method create a axes element that contains all domain and range
72 * axes of the given chart.
73 *
74 * @param cr The ElementCreator.
75 * @param chart The chart that provides range information of its axes.
76 *
77 * @return an element with axes information.
78 */
79 protected static Element createAxesElements(
80 ElementCreator cr,
81 JFreeChart chart)
82 {
83 logger.debug("InfoGeneratorHelper.createRangeElements");
84
85 Element axes = cr.create("axes");
86
87 XYPlot plot = (XYPlot) chart.getPlot();
88
89 int dAxisCount = plot.getDomainAxisCount();
90 for (int i = 0; i < dAxisCount; i++) {
91 Element e = createAxisElement(
92 cr, plot.getDomainAxis(i), "domain", i);
93
94 if (e != null) {
95 axes.appendChild(e);
96 }
97 }
98
99 int rAxisCount = plot.getRangeAxisCount();
100 for (int i = 0; i < rAxisCount; i++) {
101 Element e = createAxisElement(
102 cr, plot.getRangeAxis(i), "range", i);
103
104 if (e != null) {
105 axes.appendChild(e);
106 }
107 }
108
109 return axes;
110 }
111
112
113 /**
114 * This method create a axis element for a given <i>axis</i> and
115 * <i>type</i>. Type can be one of 'domain' or 'range'.
116 *
117 * @param cr The ElementCreator
118 * @param axis The axis that provides range information.
119 * @param type The axis type ('domain' or 'range').
120 * @param pos The position in the chart.
121 *
122 * @return An element that contains range information of a given axis.
123 */
124 protected static Element createAxisElement(
125 ElementCreator cr,
126 ValueAxis axis,
127 String type,
128 int pos)
129 {
130 Range range = axis.getRange();
131
132 Element e = cr.create(type);
133 cr.addAttr(e, "pos", String.valueOf(pos), true);
134 cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true);
135 cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true);
136
137 return e;
66 } 138 }
67 139
68 140
69 /** 141 /**
70 * This method appends the values of a transformation matrix to transform 142 * This method appends the values of a transformation matrix to transform

http://dive4elements.wald.intevation.org