[Dive4elements-commits] [PATCH 3 of 3] Add saveguard not to include 0 in a scale for logarithmic axes

Wald Commits scm-commit at wald.intevation.org
Fri Apr 12 12:25:11 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1365762233 -7200
# Node ID e1ba8273df07273d08cd13a39efa14556feef267
# Parent  c2a590925ec307facb7df3424d135032348c22bc
Add saveguard not to include 0 in a scale for logarithmic axes

    Including 0 or allowing negative values triggers a bug in the
    jfreechart logarithmic axis code that causes values < 1 to be
    drawn in carthesic coordinates.

    Fixes:
    flys/issue12345

diff -r c2a590925ec3 -r e1ba8273df07 flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Apr 12 12:22:01 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java	Fri Apr 12 12:23:53 2013 +0200
@@ -2,6 +2,7 @@
 
 
 import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.axis.LogarithmicAxis;
 import org.jfree.data.Range;
 
 
@@ -50,7 +51,12 @@
     @Override
     public void applyBounds(ValueAxis axis, int percent) {
         double space = (upper - lower) / 100 * percent;
-        axis.setRange(new Range(lower-space, upper+space));
+        if (axis instanceof LogarithmicAxis) {
+            axis.setRange(new Range(Math.max(lower-space, 0.0001),
+                        Math.max(upper+space, 0.0002)));
+        } else {
+            axis.setRange(new Range(lower-space, upper+space));
+        }
     }
 
 


More information about the Dive4elements-commits mailing list