changeset 3621:6772e9f9b65f

Deal with inverted axes in longitudinal charts and logos. flys-artifacts/trunk@5297 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 29 Aug 2012 14:43:26 +0000
parents 1cd6114603d9
children 5e505060a9bf
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 3 files changed, 56 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Aug 29 14:33:48 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 29 14:43:26 2012 +0000
@@ -1,3 +1,10 @@
+2012-08-29	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
+	  src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  (getLeftX, getRightX): New and overridden to deal with inverted axis
+	  for logo placement in longitudinalsection charts.
+
 2012-08-29	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Aug 29 14:33:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Wed Aug 29 14:43:26 2012 +0000
@@ -116,15 +116,42 @@
     }
 
 
+    /** True if x axis has been inverted. */
     public boolean isInverted() {
         return inverted;
     }
 
 
+    /** Set to true if x axis has been inverted. */
     public void setInverted(boolean inverted) {
         this.inverted = inverted;
     }
 
+    /**
+     * Return left most data points x value (on first axis).
+     * Overridden because axis could be inverted.
+     */
+    @Override
+    protected double getLeftX() {
+        if (isInverted()) {
+            return (Double)getXBounds(0).getUpper();
+        }
+        return (Double)getXBounds(0).getLower();
+    }
+
+
+    /**
+     * Return right most data points x value (on first axis).
+     * Overridden because axis could be inverted.
+     */
+    @Override
+    protected double getRightX() {
+        if (isInverted()) {
+            return (Double)getXBounds(0).getLower();
+        }
+        return (Double)getXBounds(0).getUpper();
+    }
+
 
     /**
      * Returns the default title for this chart.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Wed Aug 29 14:33:48 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Wed Aug 29 14:43:26 2012 +0000
@@ -252,6 +252,26 @@
     }
 
 
+    /**
+     * Return left most data points x value (on first axis).
+     * Shortcut, especially to be overridden in (LS) charts where
+     * axis could be inverted.
+     */
+    protected double getLeftX() {
+        return (Double)getXBounds(0).getLower();
+    }
+
+
+    /**
+     * Return right most data points x value (on first axis).
+     * Shortcut, especially to be overridden in (LS) charts where
+     * axis could be inverted.
+     */
+    protected double getRightX() {
+        return (Double)getXBounds(0).getUpper();
+    }
+
+
     /** Add a logo as background annotation to plot. */
     protected void addLogo(XYPlot plot) {
         String logo = showLogo();
@@ -296,10 +316,10 @@
             placeh = "center";
         }
         if (placeh.equals("left")) {
-            xPos = (Double)getXBounds(0).getLower();
+            xPos = getLeftX();
         }
         else if (placeh.equals("right")) {
-            xPos = (Double)getXBounds(0).getUpper();
+            xPos = getRightX();
         }
         else if (placeh.equals("center")) {
             xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d;

http://dive4elements.wald.intevation.org