# HG changeset patch # User Ingo Weinzierl # Date 1324630288 0 # Node ID 2ae0627f956eae4673c703c1e3334b23c399ec55 # Parent d13be39cfd1dceb74ae3dc95b92218f6b6a9ae3c Improved ChartSettings and depending classes to avoid a lot of casting. flys-artifacts/trunk@3534 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d13be39cfd1d -r 2ae0627f956e flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Dec 22 13:22:55 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Dec 23 08:51:28 2011 +0000 @@ -1,3 +1,11 @@ +2011-12-23 Ingo Weinzierl + + * src/main/java/de/intevation/flys/exports/ChartSettings.java, + src/main/java/de/intevation/flys/exports/LegendSection.java, + src/main/java/de/intevation/flys/exports/ChartSection.java: Use more + concrete classes than Settings and Section in these classes to avoid a lot + of castings. + 2011-12-22 Ingo Weinzierl flys/issue242 (W-INFO: Fehlende Header in Datenexporten) diff -r d13be39cfd1d -r 2ae0627f956e flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Thu Dec 22 13:22:55 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Fri Dec 23 08:51:28 2011 +0000 @@ -35,6 +35,12 @@ } + public String getTitle() { + StringAttribute attr = (StringAttribute) getAttribute(TITLE_ATTR); + return attr != null ? (String) attr.getValue() : null; + } + + public void setSubtitle(String subtitle) { if (subtitle == null || subtitle.length() == 0) { return; @@ -51,6 +57,12 @@ } + public String getSubtitle() { + StringAttribute attr = (StringAttribute) getAttribute(SUBTITLE_ATTR); + return attr != null ? (String) attr.getValue() : null; + } + + public void setDisplayGird(boolean displayGrid) { Attribute attr = getAttribute(DISPLAYGRID_ATTR); if (attr == null) { @@ -61,5 +73,11 @@ attr.setValue(displayGrid); } } + + + public Boolean getDisplayGrid() { + BooleanAttribute ba = (BooleanAttribute) getAttribute(DISPLAYGRID_ATTR); + return ba != null ? (Boolean) ba.getValue() : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r d13be39cfd1d -r 2ae0627f956e flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Thu Dec 22 13:22:55 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Fri Dec 23 08:51:28 2011 +0000 @@ -21,9 +21,9 @@ private static final Logger logger = Logger.getLogger(ChartSettings.class); - protected Section chartSection; - protected Section legendSection; - protected Section axesSection; + protected ChartSection chartSection; + protected LegendSection legendSection; + protected Section axesSection; public ChartSettings() { @@ -39,8 +39,8 @@ * * @param chartSection A new Section that stores chart specific attributes. */ - public void setChartSection(Section chartSection) { - Section oldChartSection = getChartSection(); + public void setChartSection(ChartSection chartSection) { + ChartSection oldChartSection = getChartSection(); if (oldChartSection != null) { removeSection(oldChartSection); @@ -56,7 +56,7 @@ * * @return the Section that stores chart specific attributes. */ - public Section getChartSection() { + public ChartSection getChartSection() { return chartSection; } @@ -67,8 +67,8 @@ * @param legendSection A new Section that stores legend specific * attributes. */ - public void setLegendSection(Section legendSection) { - Section oldLegendSection = getLegendSection(); + public void setLegendSection(LegendSection legendSection) { + LegendSection oldLegendSection = getLegendSection(); if (oldLegendSection != null) { removeSection(oldLegendSection); @@ -84,7 +84,7 @@ * * @return the Section that stores legend specific attributes. */ - public Section getLegendSection() { + public LegendSection getLegendSection() { return legendSection; } diff -r d13be39cfd1d -r 2ae0627f956e flys-artifacts/src/main/java/de/intevation/flys/exports/LegendSection.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LegendSection.java Thu Dec 22 13:22:55 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LegendSection.java Fri Dec 23 08:51:28 2011 +0000 @@ -34,6 +34,12 @@ } + public Integer getFontSize() { + IntegerAttribute ia = (IntegerAttribute) getAttribute(FONTSIZE_ATTR); + return ia != null ? (Integer) ia.getValue() : null; + } + + public void setVisibility(boolean visibility) { Attribute attr = getAttribute(VISIBILITY_ATTR); if (attr == null) { @@ -44,5 +50,11 @@ attr.setValue(visibility); } } + + + public Boolean getVisibility() { + BooleanAttribute ba = (BooleanAttribute) getAttribute(VISIBILITY_ATTR); + return ba != null ? (Boolean ) ba.getValue() : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :