Bug 7790 fixed: Line thickness was taken into account when drawing marks 65/11065/2
Calixte DENIZET [Wed, 27 Mar 2013 16:59:04 +0000 (17:59 +0100)]
Change-Id: I7fc2417bb7ef6691fba2e82069c9926ab4734485

scilab/CHANGES_5.4.X
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/contouredObject/ContouredObjectDrawer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/legend/LegendDrawer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/mark/MarkSpriteFactory.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/mark/MarkSpriteManager.java

index c5898ac..7086930 100644 (file)
@@ -254,6 +254,8 @@ Bug fixes
 
 * Bug #7769 fixed - get_function_path did not have a unit test.
 
+* Bug #7790 fixed - Line thickness was taken into account when drawing marks.
+
 * Bug #8213 fixed - geom3d help page had no examples.
 
 * Bug #8395 fixed - dft has been deprecated to fft.
index 91ccd0b..4ad1c6d 100644 (file)
@@ -530,7 +530,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     }
 
                     if (polyline.getMarkMode()) {
-                        Texture sprite = markManager.getMarkSprite(polyline, colorMap);
+                        Texture sprite = markManager.getMarkSprite(polyline, colorMap, appearance);
                         ElementsBuffer positions = dataManager.getVertexBuffer(polyline.getIdentifier());
                         drawingTools.draw(sprite, AnchorPosition.CENTER, positions);
                     }
@@ -622,7 +622,13 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                 }
 
                 if (fac3d.getMarkMode()) {
-                    Texture texture = markManager.getMarkSprite(fac3d, colorMap);
+                    Appearance appearance = null;
+                    if (fac3d.getLineThickness() > 0.0) {
+                        appearance = new Appearance();
+                        appearance.setLineWidth(fac3d.getLineThickness().floatValue());
+                    }
+
+                    Texture texture = markManager.getMarkSprite(fac3d, colorMap, appearance);
                     ElementsBuffer positions = dataManager.getVertexBuffer(fac3d.getIdentifier());
                     drawingTools.draw(texture, AnchorPosition.CENTER, positions);
                 }
@@ -635,7 +641,6 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
             }
             axesDrawer.disableClipping(fac3d.getClipProperty());
         }
-
     }
 
     @Override
@@ -666,7 +671,6 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     /* Front-facing triangles */
                     Appearance appearance = new Appearance();
 
-
                     if (plot3d.getColorFlag() == 1) {
                         geometry.setColors(dataManager.getColorBuffer(plot3d.getIdentifier()));
                     } else {
@@ -696,7 +700,13 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                 }
 
                 if (plot3d.getMarkMode()) {
-                    Texture texture = markManager.getMarkSprite(plot3d, colorMap);
+                    Appearance appearance = null;
+                    if (plot3d.getLineThickness() > 0.0) {
+                        appearance = new Appearance();
+                        appearance.setLineWidth(plot3d.getLineThickness().floatValue());
+                    }
+
+                    Texture texture = markManager.getMarkSprite(plot3d, colorMap, appearance);
                     ElementsBuffer positions = dataManager.getVertexBuffer(plot3d.getIdentifier());
                     drawingTools.draw(texture, AnchorPosition.CENTER, positions);
                 }
@@ -805,7 +815,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                  * in order to obtain the latter's Mark (all arrows are supposed to have the same contour properties for now).
                  */
                 if (segs.getMarkMode()) {
-                    Texture texture = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), colorMap);
+                    Texture texture = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), colorMap, null);
                     ElementsBuffer positions = dataManager.getVertexBuffer(segs.getIdentifier());
                     // Take only into account start-end of segs and not the arrow head.
                     positions.getData().limit(segs.getNumberArrows() * 2 * 4);
index 1e10038..010c7a8 100644 (file)
@@ -61,7 +61,7 @@ public class ContouredObjectDrawer {
      * @param contouredObject the ContouredObject to draw.
      * @param use2dView a boolean specifying whether the 2D view mode is used or not.
      * @throws org.scilab.forge.scirenderer.SciRendererException if the draw fail.
-     * @throws ObjectRemovedException 
+     * @throws ObjectRemovedException
      */
     public void draw(ContouredObject contouredObject, boolean use2dView) throws SciRendererException, ObjectRemovedException, OutOfMemoryException {
         DrawingTools drawingTools = visitor.getDrawingTools();
@@ -101,9 +101,9 @@ public class ContouredObjectDrawer {
         drawingTools.draw(geometry, appearance);
 
         if (contouredObject.getMarkMode()) {
-                Texture texture = markManager.getMarkSprite(contouredObject, colorMap);
-                ElementsBuffer positions = dataManager.getVertexBuffer(contouredObject.getIdentifier());
-                drawingTools.draw(texture, AnchorPosition.CENTER, positions);
+            Texture texture = markManager.getMarkSprite(contouredObject, colorMap, appearance);
+            ElementsBuffer positions = dataManager.getVertexBuffer(contouredObject.getIdentifier());
+            drawingTools.draw(texture, AnchorPosition.CENTER, positions);
         }
     }
 }
index 888cc0a..3e7acbc 100644 (file)
@@ -67,13 +67,13 @@ public class LegendDrawer {
      * Set of properties that affect the legend sprite
      */
     private static final Set<Integer> SPRITE_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-                                                                                 GraphicObjectProperties.__GO_FONT_SIZE__,
-                                                                                 GraphicObjectProperties.__GO_FONT_COLOR__,
-                                                                                 GraphicObjectProperties.__GO_FONT_STYLE__,
-                                                                                 GraphicObjectProperties.__GO_FONT_FRACTIONAL__,
-                                                                                 GraphicObjectProperties.__GO_TEXT_ARRAY_DIMENSIONS__,
-                                                                                 GraphicObjectProperties.__GO_TEXT_STRINGS__
-                                                                                 ));
+                GraphicObjectProperties.__GO_FONT_SIZE__,
+                GraphicObjectProperties.__GO_FONT_COLOR__,
+                GraphicObjectProperties.__GO_FONT_STYLE__,
+                GraphicObjectProperties.__GO_FONT_FRACTIONAL__,
+                GraphicObjectProperties.__GO_TEXT_ARRAY_DIMENSIONS__,
+                GraphicObjectProperties.__GO_TEXT_STRINGS__
+            ));
 
     /** The height of a bar relative to the height difference between two lines */
     private static final float BAR_HEIGHT = 0.5f;
@@ -371,7 +371,7 @@ public class LegendDrawer {
         float [] lineVertexData = new float[] {0.25f, 0.75f, Z_FRONT, 1.0f,
                                                0.5f, 0.75f, Z_FRONT, 1.0f,
                                                0.75f, 0.75f, Z_FRONT, 1.0f
-        };
+                                              };
 
         double normSpriteMargin = 0.0;
 
@@ -403,7 +403,7 @@ public class LegendDrawer {
                                               0.75f, 0.75f, Z_FRONT, 1.0f,
                                               0.25f, 1.00f, Z_FRONT, 1.0f,
                                               0.75f, 1.00f, Z_FRONT, 1.0f
-        };
+                                             };
 
         float barHeight = BAR_HEIGHT * deltaHeight;
 
@@ -548,8 +548,9 @@ public class LegendDrawer {
         }
 
         if (polyline.getMarkMode()) {
-            Texture markTexture = markManager.getMarkSprite(polyline, colorMap);
-
+            Appearance lineAppearance = new Appearance();
+            lineAppearance.setLineWidth((float) lineThickness);
+            Texture markTexture = markManager.getMarkSprite(polyline, colorMap, lineAppearance);
             if (barDrawn) {
                 drawingTools.draw(markTexture, AnchorPosition.CENTER, barVertices);
             } else {
index 4070ada..3498209 100644 (file)
@@ -37,7 +37,7 @@ public class MarkSpriteFactory {
      * @param colorMap the scilab color map.
      * @return a mark sprite corresponding to the given scilab mark.
      */
-    public static Texture getMarkSprite(TextureManager spriteManager, Mark mark, ColorMap colorMap) {
+    public static Texture getMarkSprite(TextureManager spriteManager, Mark mark, ColorMap colorMap, Appearance appearance) {
         int finalSize;
 
         /**
@@ -57,7 +57,7 @@ public class MarkSpriteFactory {
         }
 
         Texture sprite = spriteManager.createTexture();
-        sprite.setDrawer(getSpriteDrawer(mark, finalSize, colorMap));
+        sprite.setDrawer(getSpriteDrawer(mark, finalSize, colorMap, appearance));
 
         return sprite;
     }
@@ -69,8 +69,7 @@ public class MarkSpriteFactory {
      * @param colorMap the scilab colormap to use.
      * @return the sprite drawer corresponding to the given mark.
      */
-    private static TextureDrawer getSpriteDrawer(Mark mark, int finalSize, ColorMap colorMap) {
-
+    private static TextureDrawer getSpriteDrawer(Mark mark, int finalSize, ColorMap colorMap, Appearance usedAppearance) {
         final Appearance appearance = new Appearance();
         Color backgroundColor = ColorFactory.createColor(colorMap, mark.getBackground());
         Color foregroundColor = ColorFactory.createColor(colorMap, mark.getForeground());
@@ -81,42 +80,45 @@ public class MarkSpriteFactory {
             appearance.setFillColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
         }
         appearance.setLineColor(foregroundColor);
+        if (usedAppearance != null) {
+            appearance.setLineWidth(usedAppearance.getLineWidth());
+        }
 
         if (finalSize != 1) {
             switch (mark.getStyle()) {
-            case  0:
-                return new DotSpriteDrawer(foregroundColor, finalSize);
-            case  1:
-                return new PlusSpriteDrawer(appearance, finalSize);
-            case  2:
-                return new CrossSpriteDrawer(appearance, finalSize);
-            case  3:
-                return new StarSpriteDrawer(appearance, finalSize);
-            case  4:
-                return new FilledDiamondSpriteDrawer(foregroundColor, finalSize);
-            case  5:
-                return new DiamondSpriteDrawer(appearance, finalSize);
-            case  6:
-                return new TriangleUpSpriteDrawer(appearance, finalSize);
-            case  7:
-                return new TriangleDownSpriteDrawer(appearance, finalSize);
-            case  8:
-                return new DiamondPlusSpriteDrawer(appearance, finalSize);
-            case  9:
-                return new CircleSpriteDrawer(appearance, finalSize);
-            case 10:
-                return new AsteriskSpriteDrawer(appearance, finalSize);
-            case 11:
-                return new SquareSpriteDrawer(appearance, finalSize);
-            case 12:
-                return new TriangleRightSpriteDrawer(appearance, finalSize);
-            case 13:
-                return new TriangleLeftSpriteDrawer(appearance, finalSize);
-            case 14:
-                return new PentagramSpriteDrawer(appearance, finalSize);
-
-            default:
-                return new PlusSpriteDrawer(appearance, finalSize);
+                case  0:
+                    return new DotSpriteDrawer(foregroundColor, finalSize);
+                case  1:
+                    return new PlusSpriteDrawer(appearance, finalSize);
+                case  2:
+                    return new CrossSpriteDrawer(appearance, finalSize);
+                case  3:
+                    return new StarSpriteDrawer(appearance, finalSize);
+                case  4:
+                    return new FilledDiamondSpriteDrawer(foregroundColor, finalSize);
+                case  5:
+                    return new DiamondSpriteDrawer(appearance, finalSize);
+                case  6:
+                    return new TriangleUpSpriteDrawer(appearance, finalSize);
+                case  7:
+                    return new TriangleDownSpriteDrawer(appearance, finalSize);
+                case  8:
+                    return new DiamondPlusSpriteDrawer(appearance, finalSize);
+                case  9:
+                    return new CircleSpriteDrawer(appearance, finalSize);
+                case 10:
+                    return new AsteriskSpriteDrawer(appearance, finalSize);
+                case 11:
+                    return new SquareSpriteDrawer(appearance, finalSize);
+                case 12:
+                    return new TriangleRightSpriteDrawer(appearance, finalSize);
+                case 13:
+                    return new TriangleLeftSpriteDrawer(appearance, finalSize);
+                case 14:
+                    return new PentagramSpriteDrawer(appearance, finalSize);
+
+                default:
+                    return new PlusSpriteDrawer(appearance, finalSize);
             }
         } else {
             return new PlusSpriteDrawer(appearance, finalSize);
index 635cf1a..3e70e37 100644 (file)
@@ -10,6 +10,7 @@
  */
 package org.scilab.modules.renderer.JoGLView.mark;
 
+import org.scilab.forge.scirenderer.shapes.appearance.Appearance;
 import org.scilab.forge.scirenderer.texture.Texture;
 import org.scilab.forge.scirenderer.texture.TextureManager;
 import org.scilab.modules.graphic_objects.contouredObject.ContouredObject;
@@ -55,11 +56,11 @@ public class MarkSpriteManager {
      * @param colorMap the current color map.
      * @return the mark sprite for the given contoured object.
      */
-    public Texture getMarkSprite(ContouredObject contouredObject, ColorMap colorMap) {
+    public Texture getMarkSprite(ContouredObject contouredObject, ColorMap colorMap, Appearance appearance) {
         String id = contouredObject.getIdentifier();
         Texture sprite = spriteMap.get(id);
         if (sprite == null) {
-            sprite = MarkSpriteFactory.getMarkSprite(textureManager, contouredObject.getMark(), colorMap);
+            sprite = MarkSpriteFactory.getMarkSprite(textureManager, contouredObject.getMark(), colorMap, appearance);
             spriteMap.put(id, sprite);
         }
         return sprite;
@@ -72,10 +73,10 @@ public class MarkSpriteManager {
      * @param colorMap the current color map.
      * @return the mark sprite for the given contoured object.
      */
-    public Texture getMarkSprite(String id, Mark mark, ColorMap colorMap) {
+    public Texture getMarkSprite(String id, Mark mark, ColorMap colorMap, Appearance appearance) {
         Texture sprite = spriteMap.get(id);
         if (sprite == null) {
-            sprite = MarkSpriteFactory.getMarkSprite(textureManager, mark, colorMap);
+            sprite = MarkSpriteFactory.getMarkSprite(textureManager, mark, colorMap, appearance);
             spriteMap.put(id, sprite);
         }
         return sprite;
@@ -97,7 +98,8 @@ public class MarkSpriteManager {
                 || property == GraphicObjectProperties.__GO_MARK_SIZE_UNIT__
                 || property == GraphicObjectProperties.__GO_MARK_SIZE__
                 || property == GraphicObjectProperties.__GO_MARK_FOREGROUND__
-                || property == GraphicObjectProperties.__GO_MARK_BACKGROUND__) {
+                || property == GraphicObjectProperties.__GO_MARK_BACKGROUND__
+                || property == GraphicObjectProperties.__GO_LINE_THICKNESS__) {
             dispose(id);
         }
     }