Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/InfoGeneratorHelper2.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | 74ebe5e7fa69 |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
39 * This class helps generating chart info documents. | 39 * This class helps generating chart info documents. |
40 */ | 40 */ |
41 public class InfoGeneratorHelper2 { | 41 public class InfoGeneratorHelper2 { |
42 | 42 |
43 /** Private logging instance. */ | 43 /** Private logging instance. */ |
44 private static final Logger logger = | 44 private static final Logger log = |
45 Logger.getLogger(InfoGeneratorHelper2.class); | 45 Logger.getLogger(InfoGeneratorHelper2.class); |
46 | 46 |
47 protected ChartGenerator2 generator; | 47 protected ChartGenerator2 generator; |
48 | 48 |
49 public InfoGeneratorHelper2(ChartGenerator2 generator) { | 49 public InfoGeneratorHelper2(ChartGenerator2 generator) { |
60 */ | 60 */ |
61 public Document createInfoDocument( | 61 public Document createInfoDocument( |
62 JFreeChart chart, | 62 JFreeChart chart, |
63 ChartRenderingInfo info) | 63 ChartRenderingInfo info) |
64 { | 64 { |
65 logger.debug("InfoGeneratorHelper.createInfoDocument"); | 65 log.debug("InfoGeneratorHelper.createInfoDocument"); |
66 | 66 |
67 Document doc = XMLUtils.newDocument(); | 67 Document doc = XMLUtils.newDocument(); |
68 | 68 |
69 ElementCreator cr = new ElementCreator( | 69 ElementCreator cr = new ElementCreator( |
70 doc, | 70 doc, |
93 */ | 93 */ |
94 protected Element createAxesElements( | 94 protected Element createAxesElements( |
95 ElementCreator cr, | 95 ElementCreator cr, |
96 JFreeChart chart) | 96 JFreeChart chart) |
97 { | 97 { |
98 logger.debug("InfoGeneratorHelper.createRangeElements"); | 98 log.debug("InfoGeneratorHelper.createRangeElements"); |
99 | 99 |
100 Element axes = cr.create("axes"); | 100 Element axes = cr.create("axes"); |
101 | 101 |
102 XYPlot plot = (XYPlot) chart.getPlot(); | 102 XYPlot plot = (XYPlot) chart.getPlot(); |
103 | 103 |
116 for (int i = 0; i < rAxisCount; i++) { | 116 for (int i = 0; i < rAxisCount; i++) { |
117 ValueAxis axis = plot.getRangeAxis(i); | 117 ValueAxis axis = plot.getRangeAxis(i); |
118 XYDataset data = plot.getDataset(i); | 118 XYDataset data = plot.getDataset(i); |
119 | 119 |
120 if (axis == null || data == null) { | 120 if (axis == null || data == null) { |
121 logger.warn("Axis or dataset is empty at pos: " + i); | 121 log.warn("Axis or dataset is empty at pos: " + i); |
122 continue; | 122 continue; |
123 } | 123 } |
124 | 124 |
125 Element e = createAxisElement(cr, axis, data, "range", i); | 125 Element e = createAxisElement(cr, axis, data, "range", i); |
126 axes.appendChild(e); | 126 axes.appendChild(e); |
147 ValueAxis axis, | 147 ValueAxis axis, |
148 XYDataset dataset, | 148 XYDataset dataset, |
149 String type, | 149 String type, |
150 int pos) | 150 int pos) |
151 { | 151 { |
152 logger.debug("createAxisElement " + pos); | 152 log.debug("createAxisElement " + pos); |
153 logger.debug("Axis is from type: " + axis.getClass()); | 153 log.debug("Axis is from type: " + axis.getClass()); |
154 | 154 |
155 Element e = cr.create(type); | 155 Element e = cr.create(type); |
156 cr.addAttr(e, "pos", String.valueOf(pos), true); | 156 cr.addAttr(e, "pos", String.valueOf(pos), true); |
157 | 157 |
158 if (axis instanceof DateAxis) { | 158 if (axis instanceof DateAxis) { |
242 protected Element createTransformationElements( | 242 protected Element createTransformationElements( |
243 ElementCreator cr, | 243 ElementCreator cr, |
244 JFreeChart chart, | 244 JFreeChart chart, |
245 ChartRenderingInfo info) | 245 ChartRenderingInfo info) |
246 { | 246 { |
247 logger.debug("InfoGeneratorHelper.createTransformationElements"); | 247 log.debug("InfoGeneratorHelper.createTransformationElements"); |
248 | 248 |
249 Element tf = cr.create("transformation-matrix"); | 249 Element tf = cr.create("transformation-matrix"); |
250 | 250 |
251 Rectangle2D dataArea = info.getPlotInfo().getDataArea(); | 251 Rectangle2D dataArea = info.getPlotInfo().getDataArea(); |
252 | 252 |
253 XYPlot plot = (XYPlot) chart.getPlot(); | 253 XYPlot plot = (XYPlot) chart.getPlot(); |
254 ValueAxis xAxis = plot.getDomainAxis(); | 254 ValueAxis xAxis = plot.getDomainAxis(); |
255 | 255 |
256 if (xAxis == null) { | 256 if (xAxis == null) { |
257 logger.error("There is no x axis in the chart!"); | 257 log.error("There is no x axis in the chart!"); |
258 return null; | 258 return null; |
259 } | 259 } |
260 | 260 |
261 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { | 261 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { |
262 ValueAxis yAxis = plot.getRangeAxis(i); | 262 ValueAxis yAxis = plot.getRangeAxis(i); |
263 | 263 |
264 if (yAxis == null) { | 264 if (yAxis == null) { |
265 logger.warn("No y axis at pos " + i + " existing."); | 265 log.warn("No y axis at pos " + i + " existing."); |
266 continue; | 266 continue; |
267 } | 267 } |
268 | 268 |
269 Element matrix = createTransformationElement( | 269 Element matrix = createTransformationElement( |
270 cr, xAxis, yAxis, dataArea, i); | 270 cr, xAxis, yAxis, dataArea, i); |
336 protected static double[] createTransformationMatrix( | 336 protected static double[] createTransformationMatrix( |
337 Rectangle2D dataArea, | 337 Rectangle2D dataArea, |
338 ValueAxis xAxis, | 338 ValueAxis xAxis, |
339 ValueAxis yAxis) | 339 ValueAxis yAxis) |
340 { | 340 { |
341 logger.debug("InfoGeneratorHelper.createTransformationMatrix"); | 341 log.debug("InfoGeneratorHelper.createTransformationMatrix"); |
342 | 342 |
343 double offsetX = dataArea.getX(); | 343 double offsetX = dataArea.getX(); |
344 double width = dataArea.getWidth(); | 344 double width = dataArea.getWidth(); |
345 double offsetY = dataArea.getY(); | 345 double offsetY = dataArea.getY(); |
346 double height = dataArea.getHeight(); | 346 double height = dataArea.getHeight(); |
352 double upperX = xRange.getUpperBound(); | 352 double upperX = xRange.getUpperBound(); |
353 double lowerY = yRange.getLowerBound(); | 353 double lowerY = yRange.getLowerBound(); |
354 double upperY = yRange.getUpperBound(); | 354 double upperY = yRange.getUpperBound(); |
355 | 355 |
356 if (xAxis.isInverted()) { | 356 if (xAxis.isInverted()) { |
357 logger.info("X-Axis is inverted!"); | 357 log.info("X-Axis is inverted!"); |
358 | 358 |
359 double tmp = upperX; | 359 double tmp = upperX; |
360 upperX = lowerX; | 360 upperX = lowerX; |
361 lowerX = tmp; | 361 lowerX = tmp; |
362 } | 362 } |
384 | 384 |
385 return new double[] { c[0], c[3], c[4], c[5] }; | 385 return new double[] { c[0], c[3], c[4], c[5] }; |
386 } | 386 } |
387 catch (NoninvertibleTransformException e) { | 387 catch (NoninvertibleTransformException e) { |
388 // do nothing | 388 // do nothing |
389 logger.warn("Matrix is not invertible."); | 389 log.warn("Matrix is not invertible."); |
390 } | 390 } |
391 | 391 |
392 return new double[] { 1d, 1d, 0d, 0d }; | 392 return new double[] { 1d, 1d, 0d, 0d }; |
393 } | 393 } |
394 | 394 |