Add a way to precise mark border color for scatter plots 87/16387/1
Calixte DENIZET [Tue, 21 Apr 2015 12:08:55 +0000 (14:08 +0200)]
Change-Id: I36b96ddb34fc1d3794aa5b219955f2a50d9ad50f

scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/mark/MarkSpriteFactory.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/DrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/G2DDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/motor/Motor3D.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/motor/SpritedRectangle.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/g2d/texture/G2DTextureDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/JoGLDrawingTools.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/texture/JoGLTextureManager.java

index 5b703fe..7f68b53 100755 (executable)
@@ -31,6 +31,7 @@ import org.scilab.forge.scirenderer.DrawingTools;
 import org.scilab.forge.scirenderer.SciRendererException;
 import org.scilab.forge.scirenderer.buffers.ElementsBuffer;
 import org.scilab.forge.scirenderer.shapes.appearance.Appearance;
+import org.scilab.forge.scirenderer.shapes.appearance.Color;
 import org.scilab.forge.scirenderer.shapes.geometry.DefaultGeometry;
 import org.scilab.forge.scirenderer.shapes.geometry.Geometry;
 import org.scilab.forge.scirenderer.texture.AbstractTextureDataProvider;
@@ -159,7 +160,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     public static int[] getSize() {
         return new int[] {visitorMap.size(), openGLChildren.size()};
     }
-    
+
     public DrawerVisitor(Component component, Canvas canvas, AxesContainer figure) {
         GraphicController.getController().register(this);
 
@@ -599,13 +600,19 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                         ElementsBuffer positions = dataManager.getVertexBuffer(polyline.getIdentifier());
                         int offset = polyline.getMarkOffset();
                         int stride = polyline.getMarkStride();
-                        if (polyline.getColorSet() && polyline.getMark().getBackground() == -3) {
+                        if (polyline.getColorSet() && (polyline.getMark().getBackground() == -3 || polyline.getMark().getForeground() == -3)) {
                             Texture sprite = markManager.getMarkSprite(polyline, null, appearance);
                             ElementsBuffer colors = dataManager.getColorBuffer(polyline.getIdentifier());
-                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, colors);
+                            Color auxColor;
+                            if (polyline.getMark().getBackground() == -3) {
+                                auxColor = ColorFactory.createColor(colorMap, polyline.getMark().getForeground());
+                            } else {
+                                auxColor = ColorFactory.createColor(colorMap, polyline.getMark().getBackground());
+                            }
+                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, auxColor, colors);
                         } else {
                             Texture sprite = markManager.getMarkSprite(polyline, colorMap, appearance);
-                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, null);
+                            drawingTools.draw(sprite, AnchorPosition.CENTER, positions, offset, stride, 0, null, null);
                         }
                     }
                 } catch (ObjectRemovedException e) {
@@ -790,13 +797,19 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     }
 
                     ElementsBuffer positions = dataManager.getVertexBuffer(plot3d.getIdentifier());
-                    if (plot3d.getMark().getBackground() == -3 && plot3d.getColorFlag() == 1) {
+                    if ((plot3d.getMark().getBackground() == -3 || plot3d.getMark().getForeground() == -3) && plot3d.getColorFlag() == 1) {
                         Texture sprite = markManager.getMarkSprite(plot3d, null, appearance);
                         ElementsBuffer colors = dataManager.getColorBuffer(plot3d.getIdentifier());
-                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, colors);
+                        Color auxColor;
+                        if (plot3d.getMark().getBackground() == -3) {
+                            auxColor = ColorFactory.createColor(colorMap, plot3d.getMark().getForeground());
+                        } else {
+                            auxColor = ColorFactory.createColor(colorMap, plot3d.getMark().getBackground());
+                        }
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, auxColor, colors);
                     } else {
                         Texture sprite = markManager.getMarkSprite(plot3d, colorMap, appearance);
-                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null);
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null, null);
                     }
                 }
             } catch (ObjectRemovedException e) {
@@ -928,13 +941,19 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     // Take only into account start-end of segs and not the arrow head.
                     positions.getData().limit(segs.getNumberArrows() * 2 * 4);
 
-                    if (segs.getArrows().get(0).getMark().getBackground() == -3) {
+                    if (segs.getArrows().get(0).getMark().getBackground() == -3 || segs.getArrows().get(0).getMark().getForeground() == -3) {
                         Texture sprite = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), null, null);
                         ElementsBuffer colors = dataManager.getColorBuffer(segs.getIdentifier());
-                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, colors);
+                        Color auxColor;
+                        if (segs.getArrows().get(0).getMark().getBackground() == -3) {
+                            auxColor = ColorFactory.createColor(colorMap, segs.getArrows().get(0).getMark().getForeground());
+                        } else {
+                            auxColor = ColorFactory.createColor(colorMap, segs.getArrows().get(0).getMark().getBackground());
+                        }
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, auxColor, colors);
                     } else {
                         Texture sprite = markManager.getMarkSprite(segs.getIdentifier(), segs.getArrows().get(0).getMark(), colorMap, null);
-                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null);
+                        drawingTools.draw(sprite, AnchorPosition.CENTER, positions, null, null);
                     }
 
                     positions.getData().limit(positions.getData().capacity());
index 72ec98f..ad3c7b4 100644 (file)
@@ -78,6 +78,12 @@ public class MarkSpriteFactory {
         if (colorMap != null) {
             backgroundColor = ColorFactory.createColor(colorMap, mark.getBackground());
             foregroundColor = ColorFactory.createColor(colorMap, markColor);
+        } else if (mark.getBackground() == -3 && mark.getForeground() == -3) {
+            backgroundColor = new Color(0f, 0f, 0f, 1f);
+            foregroundColor = new Color(0f, 0f, 0f, 1f);
+        } else if (mark.getBackground() == -3) {
+            backgroundColor = new Color(0f, 0f, 0f, 1f);
+            foregroundColor = new Color(1f, 1f, 1f, 1f);
         } else {
             backgroundColor = new Color(1f, 1f, 1f, 1f);
             foregroundColor = new Color(0f, 0f, 0f, 1f);
index 4652efb..13bedda 100644 (file)
@@ -125,7 +125,7 @@ public interface DrawingTools {
      * @param colors the colors of the texture.
      * @throws SciRendererException if the texture is not drawable.
      */
-    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) throws SciRendererException;
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, Color auxColor, ElementsBuffer colors) throws SciRendererException;
 
     /**
      * Draw the given texture at all given position with the given rotation angle with selected colors.
@@ -136,7 +136,7 @@ public interface DrawingTools {
      * @param colors the colors of the texture.
      * @throws SciRendererException if the texture is not drawable.
      */
-    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) throws SciRendererException;
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, Color auxColor, ElementsBuffer colors) throws SciRendererException;
 
     /**
      * Draw the given texture at all given position with given offset and stride with the given rotation angle.
@@ -161,7 +161,7 @@ public interface DrawingTools {
      * @param colors the colors of the texture.
      * @throws SciRendererException if the texture is not drawable.
      */
-    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException;
+    void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, Color auxColor, ElementsBuffer colors) throws SciRendererException;
 
     /**
      * Draw the given texture at given position.
index 1cc0d14..3e1de38 100644 (file)
@@ -127,32 +127,32 @@ public class G2DDrawingTools implements DrawingTools {
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, null);
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, null, null);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null);
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null, null);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, Color auxColor, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, 0, auxColor, colors);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, Color auxColor, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, 0, 1, rotationAngle, auxColor, colors);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null);
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null, null);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) {
-        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, Color auxColor, ElementsBuffer colors) {
+        g2dCanvas.getMotor3D().draw(this, texture, anchor, positions, offset, stride, rotationAngle, auxColor, colors);
     }
 
     @Override
index 0a0686c..98f1490 100644 (file)
@@ -209,7 +209,7 @@ public class Motor3D {
         }
     }
 
-    public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) {
+    public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, org.scilab.forge.scirenderer.shapes.appearance.Color auxColor, ElementsBuffer colors) {
         FloatBuffer positionsBuffer = positions.getData();
         float[] buffer;
         offset = offset < 0 ? 0 : offset;
@@ -242,9 +242,9 @@ public class Motor3D {
                 Vector3d v = verticesArray[i];
                 SpritedRectangle o;
                 if (colorsArray == null) {
-                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, null);
+                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, null, null);
                 } else {
-                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, colorsArray[i]);
+                    o = new SpritedRectangle(v, texture, anchor, textureDrawingTools, rotationAngle, (Color) auxColor, colorsArray[i]);
                 }
                 add(o);
             } catch (InvalidPolygonException e) { }
@@ -253,7 +253,7 @@ public class Motor3D {
 
     public void draw(DrawingTools drawingTools, Texture texture, AnchorPosition anchor, Vector3d position, double rotationAngle) {
         try {
-            add(new SpritedRectangle(transf.project(position), texture, anchor, textureDrawingTools, rotationAngle, null));
+            add(new SpritedRectangle(transf.project(position), texture, anchor, textureDrawingTools, rotationAngle, null, null));
         } catch (InvalidPolygonException e) { }
     }
 
index a4371f8..7af8220 100644 (file)
@@ -43,14 +43,16 @@ public class SpritedRectangle extends ConvexObject {
     private Texture.Filter filter;
     private Vector3d position;
     private Color fillColor;
+    private Color borderColor;
 
-    public SpritedRectangle(Vector3d vertex, Texture sprite, AnchorPosition anchor, G2DTextureDrawingTools drawingTools, double rotationAngle, Color fillColor) throws InvalidPolygonException {
+    public SpritedRectangle(Vector3d vertex, Texture sprite, AnchorPosition anchor, G2DTextureDrawingTools drawingTools, double rotationAngle, Color borderColor, Color fillColor) throws InvalidPolygonException {
         super(getSpriteVertices(vertex, sprite, anchor, rotationAngle), null);
         this.sprite = sprite;
         this.drawingTools = drawingTools;
         this.rotationAngle = rotationAngle;
         this.position = vertex;
         this.fillColor = fillColor;
+        this.borderColor = borderColor;
     }
 
     public SpritedRectangle(Vector3d vertex, Transformation transf, BufferedImage image, Texture.Filter filter) throws InvalidPolygonException {
@@ -297,7 +299,7 @@ public class SpritedRectangle extends ConvexObject {
                 g2d.translate(vertices[0].getX(), vertices[0].getY());
             }
 
-            drawingTools.accept(sprite, fillColor);
+            drawingTools.accept(sprite, borderColor, fillColor);
             g2d.setTransform(oldTransf);
             g2d.setStroke(oldStroke);
         } else {
index 2c8480e..fae37a8 100644 (file)
@@ -42,6 +42,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     private int width;
     private int height;
     private java.awt.Color fillColor;
+    private java.awt.Color borderColor;
 
     /**
      * Default constructor.
@@ -58,16 +59,16 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     }
 
     public void accept(Texture texture) {
-        accept(texture, null);
+        accept(texture, null, null);
     }
 
-    public void accept(Texture texture, java.awt.Color fillColor) {
+    public void accept(Texture texture, java.awt.Color borderColor, java.awt.Color fillColor) {
         G2DTextureManager.G2DTexture t = (G2DTextureManager.G2DTexture) texture;
         TextureDrawer drawer = t.getDrawer();
         Dimension d = drawer.getTextureSize();
         this.width = (int) d.getWidth();
         this.height = (int) d.getHeight();
-        accept(drawer, this.width, this.height, fillColor);
+        accept(drawer, this.width, this.height, borderColor, fillColor);
     }
 
     /**
@@ -75,7 +76,7 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
      * This image will contain the drawing of the given drawer.
      * @param spriteDrawer the given sprite drawer.
      */
-    public void accept(TextureDrawer textureDrawer, int width, int height, java.awt.Color fillColor) {
+    public void accept(TextureDrawer textureDrawer, int width, int height, java.awt.Color borderColor, java.awt.Color fillColor) {
         // Change center coordinate to (0, 0).
         if (textureDrawer.getOriginPosition() == TextureDrawer.OriginPosition.CENTER) {
             g2d.translate(width / 2.0, height / 2.0);
@@ -86,7 +87,9 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
             g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         }
         this.fillColor = fillColor;
+        this.borderColor = borderColor;
         textureDrawer.draw(this);
+        this.borderColor = null;
         this.fillColor = null;
 
         if (!aa) {
@@ -213,14 +216,17 @@ public class G2DTextureDrawingTools implements TextureDrawingTools {
     }
 
     public java.awt.Color getColor(Color color) {
-        if (fillColor == null) {
-            return color;
-        } else {
-            if (color.equals(Color.WHITE)) {
-                return fillColor;
-            } else {
+        if (color.equals(Color.BLACK)) {
+            if (fillColor == null) {
+                return color;
+            }
+            return fillColor;
+        } else if (color.equals(Color.WHITE)) {
+            if (borderColor == null) {
                 return color;
             }
+            return borderColor;
         }
+        return color;
     }
 }
index 3a922ee..fa8efa3 100644 (file)
@@ -159,32 +159,32 @@ public class JoGLDrawingTools implements DrawingTools {
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, null);
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, null, null);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null);
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, null, null);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, ElementsBuffer colors) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, Color auxColor, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, 0, auxColor, colors);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, double rotationAngle, Color auxColor, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, 0, 1, rotationAngle, auxColor, colors);
     }
 
     @Override
     public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null);
+        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, null, null);
     }
 
     @Override
-    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
-        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, colors);
+    public void draw(Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, Color auxColor, ElementsBuffer colors) throws SciRendererException {
+        canvas.getTextureManager().draw(this, texture, anchor, positions, offset, stride, rotationAngle, auxColor, colors);
     }
 
     @Override
index 1470650..2ce86c3 100644 (file)
@@ -18,6 +18,7 @@ import org.scilab.forge.scirenderer.SciRendererException;
 import org.scilab.forge.scirenderer.buffers.ElementsBuffer;
 import org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvas;
 import org.scilab.forge.scirenderer.implementation.jogl.JoGLDrawingTools;
+import org.scilab.forge.scirenderer.shapes.appearance.Color;
 import org.scilab.forge.scirenderer.texture.AbstractTexture;
 import org.scilab.forge.scirenderer.texture.AnchorPosition;
 import org.scilab.forge.scirenderer.texture.Texture;
@@ -75,14 +76,14 @@ public class JoGLTextureManager implements TextureManager {
     public void draw(JoGLDrawingTools drawingTools, Texture texture) throws SciRendererException {
         if ((texture instanceof JoGLTexture) && (allTextures.contains((JoGLTexture) texture))) {
             final JoGLTexture jt = (JoGLTexture) texture;
-            if (jt.preDraw(drawingTools)) {
+            if (jt.preDraw(drawingTools, null)) {
                 jt.draw(drawingTools);
                 jt.postDraw(drawingTools);
             }
         }
     }
 
-    public void draw(JoGLDrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, ElementsBuffer colors) throws SciRendererException {
+    public void draw(JoGLDrawingTools drawingTools, Texture texture, AnchorPosition anchor, ElementsBuffer positions, int offset, int stride, double rotationAngle, Color auxColor, ElementsBuffer colors) throws SciRendererException {
         if ((texture instanceof JoGLTexture) && (allTextures.contains((JoGLTexture) texture))) {
             if (positions != null) {
                 FloatBuffer data = positions.getData();
@@ -93,7 +94,7 @@ public class JoGLTextureManager implements TextureManager {
                     // Initializing dataColors Buffer
                     if (colors != null) {
                         dataColors = colors.getData();
-                        if (dataColors != null){
+                        if (dataColors != null) {
                             dataColors.rewind();
                             // There should be as many colors as there are positions
                             if (dataColors.limit() != data.limit()) {
@@ -103,10 +104,16 @@ public class JoGLTextureManager implements TextureManager {
                     }
                     float[] position = {0, 0, 0, 1};
                     float[] color = {0, 0, 0, 0};
+                    float[] auxcolor = null;
+                    if (auxColor != null) {
+                        auxcolor = new float[4];
+                        auxColor.getComponents(auxcolor);
+                    }
+
                     int mark = 0;
 
                     final JoGLTexture jt = (JoGLTexture) texture;
-                    if (jt.preDraw(drawingTools)) {
+                    if (jt.preDraw(drawingTools, auxcolor)) {
                         stride = stride < 1 ? 1 : stride;
                         offset = offset < 0 ? 0 : offset;
                         if (stride == 1) {
@@ -119,10 +126,9 @@ public class JoGLTextureManager implements TextureManager {
                             }
                             while (data.remaining() >= 4) {
                                 data.get(position);
-                                if (dataColors == null){
+                                if (dataColors == null) {
                                     jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, null);
-                                }
-                                else {
+                                } else {
                                     dataColors.get(color);
                                     jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, color);
                                 }
@@ -133,10 +139,9 @@ public class JoGLTextureManager implements TextureManager {
                                 data.position(mark);
                                 while (data.remaining() >= 4) {
                                     data.get(position);
-                                    if (dataColors == null){
+                                    if (dataColors == null) {
                                         jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, null);
-                                    }
-                                    else {
+                                    } else {
                                         dataColors.position(mark);
                                         dataColors.get(color);
                                         jt.draw(drawingTools, anchor, new Vector3d(position), rotationAngle, color);
@@ -164,7 +169,7 @@ public class JoGLTextureManager implements TextureManager {
     public void draw(JoGLDrawingTools drawingTools, Texture texture, AnchorPosition anchor, Vector3d position, double rotationAngle) throws SciRendererException {
         if ((texture instanceof JoGLTexture) && (allTextures.contains((JoGLTexture) texture))) {
             final JoGLTexture jt = (JoGLTexture) texture;
-            jt.preDraw(drawingTools);
+            jt.preDraw(drawingTools, null);
             jt.draw(drawingTools, anchor, position, rotationAngle, null);
             jt.postDraw(drawingTools);
         }
@@ -373,7 +378,7 @@ public class JoGLTextureManager implements TextureManager {
             }
         }
 
-        public boolean preDraw(JoGLDrawingTools drawingTools) throws SciRendererException {
+        public boolean preDraw(JoGLDrawingTools drawingTools, float[] auxcolor) throws SciRendererException {
             checkData(drawingTools);
 
             if (textures == null) {
@@ -402,7 +407,12 @@ public class JoGLTextureManager implements TextureManager {
             gl.glPushAttrib(GL2.GL_ALL_ATTRIB_BITS);
 
             gl.glColor4f(1f, 1f, 1f, 1f);
-            gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
+            if (auxcolor != null) {
+                gl.glTexEnvfv(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_COLOR, auxcolor, 0);
+                gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_BLEND);
+            } else {
+                gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
+            }
 
             for (int k = 0; k < wCuts * hCuts; k++) {
                 textures[k].enable(gl);