Bug 4946 fixed: Bad rendering of big rotated label 02/10702/2
Calixte DENIZET [Tue, 5 Mar 2013 17:31:17 +0000 (18:31 +0100)]
Change-Id: I2bfff213ece12d3ab5030ce37aae0c5c1761e483

scilab/CHANGES_5.4.X
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/AxisDrawer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/AxesRulerSpriteFactory.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/label/LabelManager.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/text/TextManager.java

index 880a701..de14ad9 100644 (file)
@@ -201,6 +201,8 @@ Bug fixes
 * Bug #3313 fixed - In the documentation, the title of a link was using the
                     id instead of the title of the page.
 
+* Bug #4946 fixed - Bad rendering of a big rotated label.
+
 * Bug #5291 fixed - strtod returned 0 when no real number was detected.
 
 * Bug #6583 fixed - jmat() was poorly documented.
index 066d10e..57d25f3 100644 (file)
@@ -161,14 +161,14 @@ public class AxisDrawer {
      */
     private Vector3d computeTicksDirection(Axis.TicksDirection direction) {
         switch (direction) {
-        case TOP:
-            return new Vector3d(0, +1, 0);
-        case BOTTOM:
-            return new Vector3d(0, -1, 0);
-        case LEFT:
-            return new Vector3d(-1, 0, 0);
-        default:
-            return new Vector3d(+1, 0, 0);
+            case TOP:
+                return new Vector3d(0, +1, 0);
+            case BOTTOM:
+                return new Vector3d(0, -1, 0);
+            case LEFT:
+                return new Vector3d(-1, 0, 0);
+            default:
+                return new Vector3d(+1, 0, 0);
         }
     }
 
@@ -330,6 +330,8 @@ public class AxisDrawer {
 
                 FormattedTextSpriteDrawer textureDrawer = new FormattedTextSpriteDrawer(drawerVisitor.getColorMap(), formattedText);
                 Texture texture = spriteManager.createTexture();
+                texture.setMagnificationFilter(Texture.Filter.LINEAR);
+                texture.setMinifyingFilter(Texture.Filter.LINEAR);
                 texture.setDrawer(textureDrawer);
 
                 return texture;
index 2d9b932..ffc2600 100644 (file)
@@ -94,7 +94,10 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
             FormattedText formattedText = getTextAtValue(value);
             FormattedTextSpriteDrawer textObjectSpriteDrawer = new FormattedTextSpriteDrawer(colorMap, formattedText);
             Texture texture = textureManager.createTexture();
+            texture.setMagnificationFilter(Texture.Filter.LINEAR);
+            texture.setMinifyingFilter(Texture.Filter.LINEAR);
             texture.setDrawer(textObjectSpriteDrawer);
+
             return texture;
         }
     }
@@ -154,25 +157,25 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
 
         texture.setDrawer(new TextureDrawer() {
 
-                @Override
-                public void draw(TextureDrawingTools drawingTools) {
-                    drawingTools.draw(mantissaTextEntity, 0, exponentSize.height);
-                    drawingTools.draw(exponentTextEntity, mantissaSize.width, 0);
-                }
-
-                @Override
-                public Dimension getTextureSize() {
-                    return new Dimension(
-                        exponentSize.width + mantissaSize.width,
-                        exponentSize.height + mantissaSize.height
-                        );
-                }
-
-                @Override
-                public TextureDrawer.OriginPosition getOriginPosition() {
-                    return TextureDrawer.OriginPosition.UPPER_LEFT;
-                }
-            });
+            @Override
+            public void draw(TextureDrawingTools drawingTools) {
+                drawingTools.draw(mantissaTextEntity, 0, exponentSize.height);
+                drawingTools.draw(exponentTextEntity, mantissaSize.width, 0);
+            }
+
+            @Override
+            public Dimension getTextureSize() {
+                return new Dimension(
+                           exponentSize.width + mantissaSize.width,
+                           exponentSize.height + mantissaSize.height
+                       );
+            }
+
+            @Override
+            public TextureDrawer.OriginPosition getOriginPosition() {
+                return TextureDrawer.OriginPosition.UPPER_LEFT;
+            }
+        });
 
         return texture;
     }
@@ -194,21 +197,21 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
         Texture texture = textureManager.createTexture();
         texture.setDrawer(new TextureDrawer() {
 
-                @Override
-                public void draw(TextureDrawingTools drawingTools) {
-                    drawingTools.draw(textEntity, 0, 0);
-                }
-
-                @Override
-                public Dimension getTextureSize() {
-                    return textEntity.getSize();
-                }
-
-                @Override
-                public TextureDrawer.OriginPosition getOriginPosition() {
-                    return TextureDrawer.OriginPosition.UPPER_LEFT;
-                }
-            });
+            @Override
+            public void draw(TextureDrawingTools drawingTools) {
+                drawingTools.draw(textEntity, 0, 0);
+            }
+
+            @Override
+            public Dimension getTextureSize() {
+                return textEntity.getSize();
+            }
+
+            @Override
+            public TextureDrawer.OriginPosition getOriginPosition() {
+                return TextureDrawer.OriginPosition.UPPER_LEFT;
+            }
+        });
 
         return texture;
     }
index a91df5e..1a0ea17 100644 (file)
@@ -128,7 +128,7 @@ public class LabelManager {
      * @throws SciRendererException if the label is not drawable.
      */
     public final void positionAndDraw(final DrawingTools drawingTools, final ColorMap colorMap, final Label label, LabelPositioner labelPositioner, Axes parentAxes, AxesDrawer axesDrawer, boolean drawnFlag) throws SciRendererException {
-        boolean[] logFlags = new boolean[]{parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
+        boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
         Texture labelSprite = getTexture(colorMap, label);
 
         labelPositioner.setLabelTexture(labelSprite);
@@ -136,7 +136,7 @@ public class LabelManager {
         labelPositioner.setParentAxes(parentAxes);
         labelPositioner.setAutoPosition(label.getAutoPosition());
         labelPositioner.setAutoRotation(label.getAutoRotation());
-        labelPositioner.setUserRotationAngle(180.0*label.getFontAngle()/Math.PI);
+        labelPositioner.setUserRotationAngle(180.0 * label.getFontAngle() / Math.PI);
 
         Vector3d labelUserPosition = new Vector3d(label.getPosition());
 
@@ -160,7 +160,7 @@ public class LabelManager {
             /* Apply inverse scaling to obtain user coordinates */
             objectCornerPos = ScaleUtils.applyInverseLogScale(objectCornerPos, logFlags);
 
-            label.setPosition(new Double[]{objectCornerPos.getX(), objectCornerPos.getY(), objectCornerPos.getZ()});
+            label.setPosition(new Double[] {objectCornerPos.getX(), objectCornerPos.getY(), objectCornerPos.getZ()});
 
             /*
              * Must be reset to true as setPosition modifies the label's auto position field.
@@ -186,7 +186,7 @@ public class LabelManager {
         if (label.getAutoRotation()) {
             rotationAngle = labelPositioner.getRotationAngle();
 
-            label.setFontAngle(Math.PI*rotationAngle/180.0);
+            label.setFontAngle(Math.PI * rotationAngle / 180.0);
 
             /*
              * Must be reset to true as setFontAngle modifies the label's auto rotation field.
@@ -228,7 +228,7 @@ public class LabelManager {
      */
     private Vector3d[] computeCorners(Transformation projection, Vector3d[] projCorners, Axes parentAxes) {
         Vector3d[] corners = new Vector3d[4];
-        boolean[] logFlags = new boolean[]{parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
+        boolean[] logFlags = new boolean[] {parentAxes.getXAxisLogFlag(), parentAxes.getYAxisLogFlag(), parentAxes.getZAxisLogFlag()};
 
         corners[0] = projection.unproject(projCorners[0]);
         corners[1] = projection.unproject(projCorners[1]);
@@ -280,7 +280,7 @@ public class LabelManager {
      */
     public void update(String id, int property) {
         if (!(__GO_POSITION__ == property) && !(__GO_AUTO_POSITION__ == property)
-         && !(__GO_FONT_ANGLE__ == property) && !(__GO_AUTO_ROTATION__ == property)) {
+                && !(__GO_FONT_ANGLE__ == property) && !(__GO_AUTO_ROTATION__ == property)) {
             dispose(id);
         }
     }
@@ -309,6 +309,8 @@ public class LabelManager {
     private Texture createSprite(final ColorMap colorMap, final Label label) {
         LabelSpriteDrawer spriteDrawer = new LabelSpriteDrawer(colorMap, label);
         Texture sprite = textureManager.createTexture();
+        sprite.setMagnificationFilter(Texture.Filter.LINEAR);
+        sprite.setMinifyingFilter(Texture.Filter.LINEAR);
         sprite.setDrawer(spriteDrawer);
         return sprite;
     }
index e859041..612bb46 100644 (file)
@@ -550,6 +550,8 @@ public class TextManager {
     private Texture createSprite(final ColorMap colorMap, final Text textObject) {
         TextSpriteDrawer spriteDrawer = new TextSpriteDrawer(colorMap, textObject);
         Texture texture = textureManager.createTexture();
+        texture.setMagnificationFilter(Texture.Filter.LINEAR);
+        texture.setMinifyingFilter(Texture.Filter.LINEAR);
         texture.setDrawer(spriteDrawer);
         return texture;
     }
@@ -564,6 +566,8 @@ public class TextManager {
     private Texture createSprite(final ColorMap colorMap, final Text textObject, double scaleFactor) {
         TextSpriteDrawer spriteDrawer = new TextSpriteDrawer(colorMap, textObject, scaleFactor);
         Texture texture = textureManager.createTexture();
+        texture.setMagnificationFilter(Texture.Filter.LINEAR);
+        texture.setMinifyingFilter(Texture.Filter.LINEAR);
         texture.setDrawer(spriteDrawer);
         return texture;
     }