changeset 3247:638b1da85450

New ChartHelper method to expand bounds added. flys-artifacts/trunk@4880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 06 Jul 2012 09:36:03 +0000
parents 229e9b27ce15
children 4eb91fb1e73e
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jul 06 09:34:51 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jul 06 09:36:03 2012 +0000
@@ -1,3 +1,8 @@
+2012-07-07	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/ChartHelper.java
+	  (expandBounds): New, expand bounds by given percentage.
+
 2012-07-07	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/math/Distance.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java	Fri Jul 06 09:34:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java	Fri Jul 06 09:36:03 2012 +0000
@@ -155,12 +155,34 @@
 
 
     /**
+     * Expand bounds by percent.
+     *
+     * @param bounds The bounds to expand.
+     * @param percent The percentage to expand.
+     *
+     * @param a new, expanded bounds.
+     */
+    public static Bounds expandBounds(Bounds bounds, double percent) {
+        if (bounds == null) {
+            return null;
+        }
+
+        double value  = (Double) bounds.getLower();
+        double expand = Math.abs(value / 100 * percent);
+
+        return expand != 0
+            ? new DoubleBounds(value-expand, value+expand)
+            : new DoubleBounds(-0.01 * percent, 0.01 * percent);
+    }
+
+
+    /**
      * Expand range by percent.
      *
      * @param range The range to expand.
      * @param percent The percentage to expand.
      *
-     * @param an expanded range.
+     * @param a new, expanded range.
      */
     public static Range expandRange(Range range, double percent) {
         if (range == null) {

http://dive4elements.wald.intevation.org