changeset 3618:b7867c03760a

Split logo placement property in two (vertical/horizontal). flys-artifacts/trunk@5286 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 29 Aug 2012 07:58:08 +0000
parents 05deafdcbf39
children 1548935582bc
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java 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/XYChartGenerator.java
diffstat 5 files changed, 85 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Aug 28 15:53:05 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 29 07:58:08 2012 +0000
@@ -1,3 +1,19 @@
+2012-08-29	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Split logo-placement property in two, one for horizontal, one for
+	vertical placement.
+
+	* src/main/java/de/intevation/flys/exports/ChartSettings.java,
+	  src/main/java/de/intevation/flys/exports/ChartSection.java:
+	  Accessors for split property.
+        
+	* src/main/java/de/intevation/flys/exports/ChartGenerator.java
+	  (logoHPlace,logoVPlace,logoPlace): Use split properties for vertical
+	                                     and horizontal placement of logo.
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  Use split properties, respect in placement.
+
 2012-08-28	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Sloppy logo placement property implementation.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Tue Aug 28 15:53:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java	Wed Aug 29 07:58:08 2012 +0000
@@ -753,7 +753,8 @@
         chartSection.setSubtitle(getChartSubtitle());
         chartSection.setDisplayGrid(isGridVisible());
         chartSection.setDisplayLogo(showLogo());
-        chartSection.setLogoPlacement(logoPlace());
+        chartSection.setLogoVPlacement(logoVPlace());
+        chartSection.setLogoHPlacement(logoHPlace());
         return chartSection;
     }
 
@@ -1030,11 +1031,25 @@
     }
 
 
-    protected String logoPlace() {
+    /** Where to place the logo. */
+    protected String logoHPlace() {
         ChartSettings chartSettings = getChartSettings();
         if (chartSettings != null) {
             ChartSection cs    = chartSettings.getChartSection();
-            String       place = cs.getLogoPlacement();
+            String       place = cs.getLogoHPlacement();
+
+            return place;
+        }
+        return "none";
+    }
+
+
+    /** Where to place the logo. */
+    protected String logoVPlace() {
+        ChartSettings chartSettings = getChartSettings();
+        if (chartSettings != null) {
+            ChartSection cs    = chartSettings.getChartSection();
+            String       place = cs.getLogoVPlacement();
 
             return place;
         }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java	Tue Aug 28 15:53:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java	Wed Aug 29 07:58:08 2012 +0000
@@ -14,7 +14,8 @@
     public static final String SUBTITLE_ATTR      = "subtitle";
     public static final String DISPLAYGRID_ATTR   = "display-grid";
     public static final String DISPLAYLOGO_ATTR   = "display-logo";
-    public static final String LOGOPLACEMENT_ATTR = "logo-place";
+    public static final String LOGOPLACEMENTH_ATTR = "logo-placeh";
+    public static final String LOGOPLACEMENTV_ATTR = "logo-placev";
 
 
     public ChartSection() {
@@ -55,15 +56,27 @@
     }
 
 
-    /** Get Property-value for logo-placement property. */
-    public String getLogoPlacement() {
-        return getStringValue(LOGOPLACEMENT_ATTR);
+    /** Get Property-value for horizontal logo-placement property. */
+    public String getLogoHPlacement() {
+        return getStringValue(LOGOPLACEMENTH_ATTR);
     }
 
 
-    /** Set Property-value for logo-placement property. */
-    public void setLogoPlacement(String place) {
-        setChoiceStringValue(LOGOPLACEMENT_ATTR, place, "place");
+    /** Set Property-value for horizontal logo-placement property. */
+    public void setLogoHPlacement(String place) {
+        setChoiceStringValue(LOGOPLACEMENTH_ATTR, place, "placeh");
+    }
+
+
+    /** Get Property-value for vertical logo-placement property. */
+    public String getLogoVPlacement() {
+        return getStringValue(LOGOPLACEMENTV_ATTR);
+    }
+
+
+    /** Set Property-value for vertical logo-placement property. */
+    public void setLogoVPlacement(String place) {
+        setChoiceStringValue(LOGOPLACEMENTV_ATTR, place, "placev");
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java	Tue Aug 28 15:53:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java	Wed Aug 29 07:58:08 2012 +0000
@@ -235,22 +235,24 @@
         String sub   = XMLUtils.xpathString(chart, "chart/subtitle", null);
         String grid  = XMLUtils.xpathString(chart, "chart/display-grid", null);
         String logo  = XMLUtils.xpathString(chart, "chart/display-logo", null);
-        String place = XMLUtils.xpathString(chart, "chart/logo-place", null);
+        String placeh = XMLUtils.xpathString(chart, "chart/logo-placeh", null);
+        String placev = XMLUtils.xpathString(chart, "chart/logo-placev", null);
 
         if (logger.isDebugEnabled()) {
             logger.debug("Found chart title:    '" + title + "'");
             logger.debug("Found chart subtitle: '" + sub + "'");
             logger.debug("Found chart grid:     '" + grid + "'");
             logger.debug("Found chart logo:     '" + logo + "'");
-            logger.debug("Found chart logo place: '" + place + "'");
+            logger.debug("Found chart logo placeh: '" + placeh + "'");
+            logger.debug("Found chart logo placev: '" + placev + "'");
         }
 
         chartSection.setTitle(title);
         chartSection.setSubtitle(sub);
         chartSection.setDisplayGrid(Boolean.valueOf(grid));
         chartSection.setDisplayLogo(logo);
-        chartSection.setLogoPlacement(place);
-
+        chartSection.setLogoHPlacement(placeh);
+        chartSection.setLogoVPlacement(placev);
 
         target.setChartSection(chartSection);
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue Aug 28 15:53:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Wed Aug 29 07:58:08 2012 +0000
@@ -261,37 +261,48 @@
         }
 
         ImageIcon imageIcon = null; 
-        // TODO: Which logo?
+        if (logo.equals("none")) {
+            return;
+        }
         if (logo.equals("Intevation")) {
             imageIcon = new ImageIcon("/home/felix/Downloads/intevation_logo_120.png");
         }
-        else {
+        else { // TODO else if ...
             imageIcon = new ImageIcon("/home/felix/Downloads/bfg_logo.gif");
         }
 
         double xPos = 0d, yPos = 0d;
 
         // TODO placement should be decided by from other properties.
-        String place = logoPlace();
-        if (place == null || place.equals("none")) {
-            place = "top";
+        String placeh = logoHPlace();
+        String placev = logoVPlace();
+        if (placev == null || placev.equals("none")) {
+            placev = "top";
         }
-        if (place.equals("top")) {
-            xPos = ((Double)getXBounds(0).getUpper() - (Double)getXBounds(0).getLower())/2d;
+        if (placev.equals("top")) {
             yPos = (Double)getYBounds(0).getUpper();
         }
-        else if (place.equals("bottom")) {
-            xPos = ((Double)getXBounds(0).getUpper() - (Double)getXBounds(0).getLower())/2d;
+        else if (placev.equals("bottom")) {
             yPos = (Double)getYBounds(0).getLower();
         }
-        else if (place.equals("left")) {
-            xPos = (Double)getXBounds(0).getLower();
-            yPos = ((Double)getYBounds(0).getLower() - (Double)getYBounds(0).getLower())/2d;
+        else if (placev.equals("center")) {
+            yPos = ((Double)getYBounds(0).getUpper() + (Double)getYBounds(0).getLower())/2d;
         }
-        else if (place.equals("right")) {
+        // TODO else
+
+        if (placeh == null || placeh.equals("none")) {
+            placeh = "center";
+        }
+        if (placeh.equals("left")) {
+            xPos = (Double)getXBounds(0).getLower();
+        }
+        else if (placeh.equals("right")) {
             xPos = (Double)getXBounds(0).getUpper();
-            yPos = ((Double)getYBounds(0).getLower() - (Double)getYBounds(0).getLower())/2d;
         }
+        else if (placeh.equals("center")) {
+            xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d;
+        }
+        // TODO else
         logger.debug("logo position: " + xPos + "/" + yPos);
 
         XYAnnotation xyannotation =

http://dive4elements.wald.intevation.org