Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/InfoGeneratorHelper.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 | 3dc740c51f9b |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
41 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 41 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
42 */ | 42 */ |
43 public class InfoGeneratorHelper { | 43 public class InfoGeneratorHelper { |
44 | 44 |
45 /** Private logging instance. */ | 45 /** Private logging instance. */ |
46 private static final Logger logger = | 46 private static final Logger log = |
47 Logger.getLogger(InfoGeneratorHelper.class); | 47 Logger.getLogger(InfoGeneratorHelper.class); |
48 | 48 |
49 protected ChartGenerator generator; | 49 protected ChartGenerator generator; |
50 | 50 |
51 public InfoGeneratorHelper(ChartGenerator generator) { | 51 public InfoGeneratorHelper(ChartGenerator generator) { |
62 */ | 62 */ |
63 public Document createInfoDocument( | 63 public Document createInfoDocument( |
64 JFreeChart chart, | 64 JFreeChart chart, |
65 ChartRenderingInfo info) | 65 ChartRenderingInfo info) |
66 { | 66 { |
67 logger.debug("InfoGeneratorHelper.createInfoDocument"); | 67 log.debug("InfoGeneratorHelper.createInfoDocument"); |
68 | 68 |
69 Document doc = XMLUtils.newDocument(); | 69 Document doc = XMLUtils.newDocument(); |
70 | 70 |
71 ElementCreator cr = new ElementCreator( | 71 ElementCreator cr = new ElementCreator( |
72 doc, | 72 doc, |
95 */ | 95 */ |
96 protected Element createAxesElements( | 96 protected Element createAxesElements( |
97 ElementCreator cr, | 97 ElementCreator cr, |
98 JFreeChart chart) | 98 JFreeChart chart) |
99 { | 99 { |
100 logger.debug("InfoGeneratorHelper.createRangeElements"); | 100 log.debug("InfoGeneratorHelper.createRangeElements"); |
101 | 101 |
102 Element axes = cr.create("axes"); | 102 Element axes = cr.create("axes"); |
103 | 103 |
104 XYPlot plot = (XYPlot) chart.getPlot(); | 104 XYPlot plot = (XYPlot) chart.getPlot(); |
105 | 105 |
118 for (int i = 0; i < rAxisCount; i++) { | 118 for (int i = 0; i < rAxisCount; i++) { |
119 ValueAxis axis = plot.getRangeAxis(i); | 119 ValueAxis axis = plot.getRangeAxis(i); |
120 XYDataset data = plot.getDataset(i); | 120 XYDataset data = plot.getDataset(i); |
121 | 121 |
122 if (axis == null || data == null) { | 122 if (axis == null || data == null) { |
123 logger.warn("Axis or dataset is empty at pos: " + i); | 123 log.warn("Axis or dataset is empty at pos: " + i); |
124 continue; | 124 continue; |
125 } | 125 } |
126 | 126 |
127 Element e = createAxisElement(cr, axis, data, "range", i); | 127 Element e = createAxisElement(cr, axis, data, "range", i); |
128 axes.appendChild(e); | 128 axes.appendChild(e); |
149 ValueAxis axis, | 149 ValueAxis axis, |
150 XYDataset dataset, | 150 XYDataset dataset, |
151 String type, | 151 String type, |
152 int pos) | 152 int pos) |
153 { | 153 { |
154 logger.debug("createAxisElement " + pos); | 154 log.debug("createAxisElement " + pos); |
155 logger.debug("Axis is from type: " + axis.getClass()); | 155 log.debug("Axis is from type: " + axis.getClass()); |
156 | 156 |
157 Element e = cr.create(type); | 157 Element e = cr.create(type); |
158 cr.addAttr(e, "pos", String.valueOf(pos), true); | 158 cr.addAttr(e, "pos", String.valueOf(pos), true); |
159 | 159 |
160 if (axis instanceof DateAxis) { | 160 if (axis instanceof DateAxis) { |
244 protected Element createTransformationElements( | 244 protected Element createTransformationElements( |
245 ElementCreator cr, | 245 ElementCreator cr, |
246 JFreeChart chart, | 246 JFreeChart chart, |
247 ChartRenderingInfo info) | 247 ChartRenderingInfo info) |
248 { | 248 { |
249 logger.debug("InfoGeneratorHelper.createTransformationElements"); | 249 log.debug("InfoGeneratorHelper.createTransformationElements"); |
250 | 250 |
251 Element tf = cr.create("transformation-matrix"); | 251 Element tf = cr.create("transformation-matrix"); |
252 | 252 |
253 Rectangle2D dataArea = info.getPlotInfo().getDataArea(); | 253 Rectangle2D dataArea = info.getPlotInfo().getDataArea(); |
254 | 254 |
255 XYPlot plot = (XYPlot) chart.getPlot(); | 255 XYPlot plot = (XYPlot) chart.getPlot(); |
256 ValueAxis xAxis = plot.getDomainAxis(); | 256 ValueAxis xAxis = plot.getDomainAxis(); |
257 | 257 |
258 if (xAxis == null) { | 258 if (xAxis == null) { |
259 logger.error("There is no x axis in the chart!"); | 259 log.error("There is no x axis in the chart!"); |
260 return null; | 260 return null; |
261 } | 261 } |
262 | 262 |
263 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { | 263 for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { |
264 ValueAxis yAxis = plot.getRangeAxis(i); | 264 ValueAxis yAxis = plot.getRangeAxis(i); |
265 | 265 |
266 if (yAxis == null) { | 266 if (yAxis == null) { |
267 logger.warn("No y axis at pos " + i + " existing."); | 267 log.warn("No y axis at pos " + i + " existing."); |
268 continue; | 268 continue; |
269 } | 269 } |
270 | 270 |
271 Element matrix = createTransformationElement( | 271 Element matrix = createTransformationElement( |
272 cr, xAxis, yAxis, dataArea, i); | 272 cr, xAxis, yAxis, dataArea, i); |
338 protected static double[] createTransformationMatrix( | 338 protected static double[] createTransformationMatrix( |
339 Rectangle2D dataArea, | 339 Rectangle2D dataArea, |
340 ValueAxis xAxis, | 340 ValueAxis xAxis, |
341 ValueAxis yAxis) | 341 ValueAxis yAxis) |
342 { | 342 { |
343 logger.debug("InfoGeneratorHelper.createTransformationMatrix"); | 343 log.debug("InfoGeneratorHelper.createTransformationMatrix"); |
344 | 344 |
345 double offsetX = dataArea.getX(); | 345 double offsetX = dataArea.getX(); |
346 double width = dataArea.getWidth(); | 346 double width = dataArea.getWidth(); |
347 double offsetY = dataArea.getY(); | 347 double offsetY = dataArea.getY(); |
348 double height = dataArea.getHeight(); | 348 double height = dataArea.getHeight(); |
354 double upperX = xRange.getUpperBound(); | 354 double upperX = xRange.getUpperBound(); |
355 double lowerY = yRange.getLowerBound(); | 355 double lowerY = yRange.getLowerBound(); |
356 double upperY = yRange.getUpperBound(); | 356 double upperY = yRange.getUpperBound(); |
357 | 357 |
358 if (xAxis.isInverted()) { | 358 if (xAxis.isInverted()) { |
359 logger.info("X-Axis is inverted!"); | 359 log.info("X-Axis is inverted!"); |
360 | 360 |
361 double tmp = upperX; | 361 double tmp = upperX; |
362 upperX = lowerX; | 362 upperX = lowerX; |
363 lowerX = tmp; | 363 lowerX = tmp; |
364 } | 364 } |
386 | 386 |
387 return new double[] { c[0], c[3], c[4], c[5] }; | 387 return new double[] { c[0], c[3], c[4], c[5] }; |
388 } | 388 } |
389 catch (NoninvertibleTransformException e) { | 389 catch (NoninvertibleTransformException e) { |
390 // do nothing | 390 // do nothing |
391 logger.warn("Matrix is not invertible."); | 391 log.warn("Matrix is not invertible."); |
392 } | 392 } |
393 | 393 |
394 return new double[] { 1d, 1d, 0d, 0d }; | 394 return new double[] { 1d, 1d, 0d, 0d }; |
395 } | 395 } |
396 | 396 |