Bug 12399 fixed: Bad data bounds computation with %inf and log scale
[scilab.git] / scilab / modules / graphic_objects / src / java / org / scilab / modules / graphic_objects / axes / Axes.java
index 4f1827e..63abc0d 100644 (file)
@@ -1910,20 +1910,16 @@ public class Axes extends GraphicObject {
     public Double[] getMaximalDisplayedBounds() {
         Double[] bounds = getDataBounds();
 
-        /**
-         * Remove 0 sized bounds
-         */
-        for (int i = 0 ; i < 6 ; i += 2) {
-            if (bounds[i].equals(bounds[i + 1])) {
-                bounds[i]--;
-                bounds[i + 1]++;
-            }
-        }
-
+        boolean eq = bounds[0].equals(bounds[1]);
         if (getXAxisLogFlag()) {
             bounds[0] = Math.log10(bounds[0]);
             bounds[1] = Math.log10(bounds[1]);
         }
+        if (eq) {
+            // Avoid to have same bounds.
+            bounds[0]--;
+            bounds[1]++;
+        }
 
         if (getXAxisLocationAsEnum() == AxisProperty.AxisLocation.ORIGIN) {
             if (0 < bounds[0]) {
@@ -1933,10 +1929,15 @@ public class Axes extends GraphicObject {
             }
         }
 
+        eq = bounds[2].equals(bounds[3]);
         if (getYAxisLogFlag()) {
             bounds[2] = Math.log10(bounds[2]);
             bounds[3] = Math.log10(bounds[3]);
         }
+        if (eq) {
+            bounds[2]--;
+            bounds[3]++;
+        }
 
         if (getYAxisLocationAsEnum() == AxisProperty.AxisLocation.ORIGIN) {
             if (0 < bounds[2]) {
@@ -1946,10 +1947,15 @@ public class Axes extends GraphicObject {
             }
         }
 
+        eq = bounds[4].equals(bounds[5]);
         if (getZAxisLogFlag()) {
             bounds[4] = Math.log10(bounds[4]);
             bounds[5] = Math.log10(bounds[5]);
         }
+        if (eq) {
+            bounds[4]--;
+            bounds[5]++;
+        }
 
         if (getZAxisLocationAsEnum() == AxisProperty.AxisLocation.ORIGIN) {
             if (0 < bounds[4]) {