changeset 2046:2ae0627f956e

Improved ChartSettings and depending classes to avoid a lot of casting. flys-artifacts/trunk@3534 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 23 Dec 2011 08:51:28 +0000
parents d13be39cfd1d
children 0318fa6f0844
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java flys-artifacts/src/main/java/de/intevation/flys/exports/LegendSection.java
diffstat 4 files changed, 47 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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 <ingo@intevation.de>
+
+	* 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 <ingo@intevation.de>
 
 	flys/issue242 (W-INFO: Fehlende Header in Datenexporten)
--- 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 :
--- 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;
     }
 
--- 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 :

http://dive4elements.wald.intevation.org