Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java @ 2056:76eeb3b4358e
Added an ExportSection to ChartSettings which provides attributes for chart 'width' and 'height'.
flys-artifacts/trunk@3547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 27 Dec 2011 10:12:14 +0000 |
parents | c4e0e433f825 |
children | 46b9391b122a |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Tue Dec 27 09:09:42 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Tue Dec 27 10:12:14 2011 +0000 @@ -23,6 +23,7 @@ protected ChartSection chartSection; protected LegendSection legendSection; + protected ExportSection exportSection; protected Section axesSection; @@ -90,6 +91,34 @@ /** + * Sets the export section. Old export sections are removed. + * + * @param exportSection A new Section that stores export specific + * attributes. + */ + public void setExportSection(ExportSection exportSection) { + ExportSection oldExportSection = getExportSection(); + + if (oldExportSection != null) { + removeSection(oldExportSection); + } + + this.exportSection = exportSection; + addSection(exportSection); + } + + + /** + * Returns the Section that stores export specific attributes. + * + * @return the Section that stores export specific attributes. + */ + public ExportSection getExportSection() { + return exportSection; + } + + + /** * Adds a Section for a new axis of the chart. * * @param axisSection The Section specific for a chart axis. @@ -142,6 +171,7 @@ parseAxes(chartSettings, settings); parseChart(chartSettings, settings); parseLegend(chartSettings, settings); + parseExport(chartSettings, settings); return chartSettings; } @@ -231,5 +261,23 @@ target.setLegendSection(section); } + + + protected static void parseExport(ChartSettings target, Node export) { + ExportSection section = new ExportSection(); + + String width = XMLUtils.xpathString(export, "export/width", null); + String height = XMLUtils.xpathString(export, "export/height", null); + + if (logger.isDebugEnabled()) { + logger.debug("Found export width : '" + width + "'"); + logger.debug("Found export height: '" + height + "'"); + } + + section.setWidth(Integer.valueOf(width.length() > 0 ? width : "-1")); + section.setHeight(Integer.valueOf(height.length() > 0 ? height : "-1")); + + target.setExportSection(section); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :