comparison flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java @ 5673:e1ba8273df07

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
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Apr 2013 12:23:53 +0200
parents 2f6d4f92d628
children
comparison
equal deleted inserted replaced
5672:c2a590925ec3 5673:e1ba8273df07
1 package de.intevation.flys.jfree; 1 package de.intevation.flys.jfree;
2 2
3 3
4 import org.jfree.chart.axis.ValueAxis; 4 import org.jfree.chart.axis.ValueAxis;
5 import org.jfree.chart.axis.LogarithmicAxis;
5 import org.jfree.data.Range; 6 import org.jfree.data.Range;
6 7
7 8
8 /** 9 /**
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 10 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
48 * thus 10 percent on [0,100] -> [-10,110]. 49 * thus 10 percent on [0,100] -> [-10,110].
49 */ 50 */
50 @Override 51 @Override
51 public void applyBounds(ValueAxis axis, int percent) { 52 public void applyBounds(ValueAxis axis, int percent) {
52 double space = (upper - lower) / 100 * percent; 53 double space = (upper - lower) / 100 * percent;
53 axis.setRange(new Range(lower-space, upper+space)); 54 if (axis instanceof LogarithmicAxis) {
55 axis.setRange(new Range(Math.max(lower-space, 0.0001),
56 Math.max(upper+space, 0.0002)));
57 } else {
58 axis.setRange(new Range(lower-space, upper+space));
59 }
54 } 60 }
55 61
56 62
57 @Override 63 @Override
58 public Bounds combine(Bounds bounds) { 64 public Bounds combine(Bounds bounds) {

http://dive4elements.wald.intevation.org