# HG changeset patch # User Ingo Weinzierl # Date 1307452502 0 # Node ID ab43f36f4af64242ed87ee6d94ca7a3dd9ddf1e8 # Parent ed7c901ee712506b789eeef06d48609f5b1f4d85 The ChartInfoGenerator appends axes range information to the document now. flys-artifacts/trunk@2065 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ed7c901ee712 -r ab43f36f4af6 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Jun 07 11:43:30 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Jun 07 13:15:02 2011 +0000 @@ -1,3 +1,8 @@ +2011-06-07 Ingo Weinzierl + + * src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java: + Append axes range information to the info document. + 2011-06-08 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: diff -r ed7c901ee712 -r ab43f36f4af6 flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java Tue Jun 07 11:43:30 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/InfoGeneratorHelper.java Tue Jun 07 13:15:02 2011 +0000 @@ -58,6 +58,7 @@ Element chartinfo = cr.create("chartinfo"); + chartinfo.appendChild(createAxesElements(cr, chart)); chartinfo.appendChild(createTransformationElement(cr, chart, info)); doc.appendChild(chartinfo); @@ -67,6 +68,77 @@ /** + * This method create a axes element that contains all domain and range + * axes of the given chart. + * + * @param cr The ElementCreator. + * @param chart The chart that provides range information of its axes. + * + * @return an element with axes information. + */ + protected static Element createAxesElements( + ElementCreator cr, + JFreeChart chart) + { + logger.debug("InfoGeneratorHelper.createRangeElements"); + + Element axes = cr.create("axes"); + + XYPlot plot = (XYPlot) chart.getPlot(); + + int dAxisCount = plot.getDomainAxisCount(); + for (int i = 0; i < dAxisCount; i++) { + Element e = createAxisElement( + cr, plot.getDomainAxis(i), "domain", i); + + if (e != null) { + axes.appendChild(e); + } + } + + int rAxisCount = plot.getRangeAxisCount(); + for (int i = 0; i < rAxisCount; i++) { + Element e = createAxisElement( + cr, plot.getRangeAxis(i), "range", i); + + if (e != null) { + axes.appendChild(e); + } + } + + return axes; + } + + + /** + * This method create a axis element for a given axis and + * type. Type can be one of 'domain' or 'range'. + * + * @param cr The ElementCreator + * @param axis The axis that provides range information. + * @param type The axis type ('domain' or 'range'). + * @param pos The position in the chart. + * + * @return An element that contains range information of a given axis. + */ + protected static Element createAxisElement( + ElementCreator cr, + ValueAxis axis, + String type, + int pos) + { + Range range = axis.getRange(); + + Element e = cr.create(type); + cr.addAttr(e, "pos", String.valueOf(pos), true); + cr.addAttr(e, "from", String.valueOf(range.getLowerBound()), true); + cr.addAttr(e, "to", String.valueOf(range.getUpperBound()), true); + + return e; + } + + + /** * This method appends the values of a transformation matrix to transform * image pixel coordinates into chart coordinates. *