Graphics: fix custom Formatter after JDK8 upgrade 58/18958/2
Clément DAVID [Wed, 25 Jan 2017 16:21:44 +0000 (17:21 +0100)]
Change-Id: I4edd236b4c4fd7650593389563d096a1585363fc

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/datatip/Datatip.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/AxesRulerDrawer.java

index c3ab68b..7b30c75 100755 (executable)
@@ -30,6 +30,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
+import java.util.Locale;
 
 import org.scilab.forge.scirenderer.ruler.graduations.UserDefinedFormat;
 
@@ -76,48 +77,42 @@ public class Datatip extends Text {
     public static TipOrientation intToEnum(Integer i) {
         switch (i) {
             case 0:
-                return TipOrientation.TOP_LEFT;
-            case 1:
-                return TipOrientation.TOP_RIGHT;
-            case 2:
-                return TipOrientation.BOTTOM_LEFT;
-            case 3:
-                return TipOrientation.BOTTOM_RIGHT;
-            case 4:
-                return TipOrientation.LEFT;
-            case 5:
-                return TipOrientation.RIGHT;
-            case 6:
-                return TipOrientation.TOP;
-            case 7:
-                return TipOrientation.BOTTOM;
-            default:
-                return TipOrientation.TOP_RIGHT;
+                        return TipOrientation.TOP_LEFT;
+                case 1:
+                    return TipOrientation.TOP_RIGHT;
+                case 2:
+                    return TipOrientation.BOTTOM_LEFT;
+                case 3:
+                    return TipOrientation.BOTTOM_RIGHT;
+                case 4:
+                    return TipOrientation.LEFT;
+                case 5:
+                    return TipOrientation.RIGHT;
+                case 6:
+                    return TipOrientation.TOP;
+                case 7:
+                    return TipOrientation.BOTTOM;
+                default:
+                    return TipOrientation.TOP_RIGHT;
+            }
         }
-    }
 
-                        };
+                            };
 
-    TipOrientation currentOrientation;
+        TipOrientation currentOrientation;
 
-    Boolean detachedMode;
-    Double[] detachedPosition;
+        Boolean detachedMode;
+        Double[] detachedPosition;
 
-    /**
-     * Initializes the datatip, setup format, orientation and mark.
-     */
-    public Datatip() {
+        /**
+         * Initializes the datatip, setup format, orientation and mark.
+         */
+        public Datatip() {
         super();
         displayComponents = "xy";
         autoOrientation = true;
         setOrientationAsEnum(TipOrientation.TOP_RIGHT);
-        DecimalFormat fb = new DecimalFormat("#.####E00");
-        DecimalFormatSymbols decimalFormatSymbols = fb.getDecimalFormatSymbols();
-        decimalFormatSymbols.setDecimalSeparator('.');
-        decimalFormatSymbols.setExponentSeparator("e");
-        decimalFormatSymbols.setGroupingSeparator('\u00A0');
-        fb.setDecimalFormatSymbols(decimalFormatSymbols);
-        tipTextFormat = new UserDefinedFormat(fb, "%g", 1, 0);
+        tipTextFormat = new DecimalFormat("%g", DecimalFormatSymbols.getInstance(Locale.US));
 
         detachedMode = false;
         detachedPosition = new Double[] {0.0, 0.0, 0.0};
index a484288..f18f64c 100644 (file)
@@ -46,6 +46,7 @@ import org.scilab.modules.renderer.JoGLView.util.ColorFactory;
 import java.awt.Dimension;
 import java.nio.FloatBuffer;
 import java.text.DecimalFormat;
+import java.text.FieldPosition;
 import java.util.Arrays;
 import java.util.List;
 
@@ -577,7 +578,7 @@ public class AxesRulerDrawer {
         AxesRulerSpriteFactory.setScilabStyle(format);
         String[] r = new String[values.length];
         for (int i = 0; i < values.length; i++) {
-            r[i] = format.format(values[i]);
+            r[i] = format.format(values[i], new StringBuffer(), new FieldPosition(0)).toString();
         }
         return r;
     }