Enable user ticks. 96/6196/6
Pierre LANDO [Thu, 9 Feb 2012 15:40:31 +0000 (16:40 +0100)]
Change-Id: I27179a355f0284a0f4ffc4f31ec2ed708e454b4d

scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/AxesDrawer.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/AxesRulerDrawer.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/axes/ruler/RulerDrawerManager.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/UserDefineGraduation.java [new file with mode: 0644]

index 2ae5a28..9887092 100644 (file)
@@ -874,7 +874,7 @@ public class AxesDrawer {
      * Returns the x-axis label positioner.
      * @return the x-axis label positioner.
      */
-    public LabelPositioner getXAxisLabelPositioner() {
+    public AxisLabelPositioner getXAxisLabelPositioner() {
         return this.xAxisLabelPositioner;
     }
 
@@ -882,7 +882,7 @@ public class AxesDrawer {
      * Returns the y-axis label positioner.
      * @return the y-axis label positioner.
      */
-    public LabelPositioner getYAxisLabelPositioner() {
+    public AxisLabelPositioner getYAxisLabelPositioner() {
         return this.yAxisLabelPositioner;
     }
 
@@ -890,7 +890,7 @@ public class AxesDrawer {
      * Returns the z-axis label positioner.
      * @return the z-axis label positioner.
      */
-    public LabelPositioner getZAxisLabelPositioner() {
+    public AxisLabelPositioner getZAxisLabelPositioner() {
         return this.zAxisLabelPositioner;
     }
 
index 0b0b78a..d2b0d07 100644 (file)
@@ -50,7 +50,7 @@ public class AxesRulerDrawer {
     }
 
     /**
-     * Draw the rulers and sets the axis label positioners' relevant values.
+     * Draw the ruler.
      * @param axes the current {@see Axes}
      * @param axesDrawer the drawer used to draw the current {@see Axes}
      * @param colorMap current {@see ColorMap}
@@ -63,17 +63,31 @@ public class AxesRulerDrawer {
         RulerDrawingResult rulerDrawingResult;
         double[] values;
 
-        RulerDrawer rulerDrawer = rulerDrawerManager.get(axes);
+        RulerDrawer[] rulerDrawers = rulerDrawerManager.get(axes);
         RulerModel rulerModel = new RulerModel();
 
         Transformation canvasProjection = drawingTools.getTransformationManager().getCanvasProjection();
+
+        Vector3d xAxisPosition = computeXAxisPosition(matrix, axes.getAxes()[0].getAxisLocation());
+        Vector3d yAxisPosition = computeYAxisPosition(matrix, axes.getAxes()[1].getAxisLocation());
+
         Vector3d px = canvasProjection.projectDirection(new Vector3d(1, 0, 0)).setZ(0);
         Vector3d py = canvasProjection.projectDirection(new Vector3d(0, 1, 0)).setZ(0);
         Vector3d pz = canvasProjection.projectDirection(new Vector3d(0, 0, 1)).setZ(0);
 
-        // Draw X ruler
+        Vector3d xTicksDirection, yTicksDirection;
+        if (py.getNorm2() > pz.getNorm2()) {
+            xTicksDirection = new Vector3d(0, TICKS_SIZE * xAxisPosition.getY(), 0);
+        } else {
+            xTicksDirection = new Vector3d(0, 0, TICKS_SIZE * xAxisPosition.getZ());
+        }
+
+        if (px.getNorm2() > pz.getNorm2()) {
+            yTicksDirection = new Vector3d(TICKS_SIZE * yAxisPosition.getX(), 0, 0);
+        } else {
+            yTicksDirection = new Vector3d(0, 0, TICKS_SIZE * yAxisPosition.getZ());
+        }
 
-        ElementsBuffer vertexBuffer = drawingTools.getCanvas().getBuffersManager().createElementsBuffer();
         int gridPosition;
         if (axes.getGridPositionAsEnum().equals(Axes.GridPosition.FOREGROUND)) {
             gridPosition = 1;
@@ -81,84 +95,47 @@ public class AxesRulerDrawer {
             gridPosition = -1;
         }
 
-        Appearance gridAppearance = new Appearance();
-        gridAppearance.setLinePattern(GRID_LINE_PATTERN);
-
-
-        double zs;
-        double ys;
-        double xs;
+        // Draw X ruler
 
-        if (axes.getAxes()[0].getAxisLocation().equals(AxisProperty.AxisLocation.BOTTOM)) {
-            zs = -Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
-            ys = -Math.signum(matrix[6]) * zs * Math.signum(matrix[10]);
-            if (ys == 0) {
-                ys = +1;
-            }
-        } else {
-            zs = Math.signum(matrix[9]);  // First : switch Z such that Y was maximal.
-            ys = -Math.signum(matrix[6]) * zs * Math.signum(matrix[10]);
-            if (ys == 0) {
-                ys = -1;
-            }
-        }
+        ElementsBuffer vertexBuffer = drawingTools.getCanvas().getBuffersManager().createElementsBuffer();
 
+        Appearance gridAppearance = new Appearance();
+        gridAppearance.setLinePattern(GRID_LINE_PATTERN);
 
-        Vector3d xTicksDirection;
-        if (py.getNorm2() > pz.getNorm2()) {
-            xTicksDirection = new Vector3d(0, TICKS_SIZE * ys, 0);
-        } else {
-            xTicksDirection = new Vector3d(0, 0, TICKS_SIZE * zs);
-        }
         rulerModel.setTicksDirection(xTicksDirection);
+        rulerModel.setFirstPoint(xAxisPosition.setX(1));
+        rulerModel.setSecondPoint(xAxisPosition.setX(-1));
 
-        rulerModel.setFirstPoint(new Vector3d(1, ys, zs));
-        rulerModel.setSecondPoint(new Vector3d(-1, ys, zs));
+        setRulerBounds(axes.getXAxis(), rulerModel, bounds[0], bounds[1]);
+        rulerModel.setLogarithmic(axes.getXAxis().getLogFlag());
 
-        double min, max;
-        if (axes.getAxes()[0].getReverse()) {
-            min = bounds[0];
-            max = bounds[1];
+        if (!axes.getAxes()[0].getAutoTicks()) {
+            rulerModel.setUserGraduation(new UserDefineGraduation(axes.getXAxis(), bounds[0], bounds[1]));
+            rulerModel.setAutoTicks(false);
         } else {
-            min = bounds[1];
-            max = bounds[0];
+            rulerModel.setAutoTicks(true);
         }
 
-        if (axes.getAxes()[0].getLogFlag()) {
-            rulerModel.setLogarithmic(true);
-            min = Math.pow(10, min);
-            max = Math.pow(10, max);
-        } else {
-            rulerModel.setLogarithmic(false);
-        }
-
-        rulerModel.setValues(min, max);
-
-        double [] midpoints = new double[]{0.0, 0.0, 0.0};
-        double [] otherbounds = new double[2];
-
-        otherbounds[0] = (ys > 0) ? +1 : -1;
-        otherbounds[1] = (zs > 0) ? +1 : -1;
-
-        Vector3d labelPosition = new Vector3d(midpoints[0], otherbounds[0], otherbounds[1]);
         double distanceRatio;
-
-        AxisLabelPositioner xAxisLabelPositioner = (AxisLabelPositioner) axesDrawer.getXAxisLabelPositioner();
-        xAxisLabelPositioner.setLabelPosition(labelPosition);
+        AxisLabelPositioner xAxisLabelPositioner = axesDrawer.getXAxisLabelPositioner();
+        xAxisLabelPositioner.setLabelPosition(xAxisPosition);
 
         if (axes.getXAxisVisible()) {
-            rulerDrawingResult = rulerDrawer.draw(drawingTools, rulerModel);
+            rulerDrawingResult = rulerDrawers[0].draw(drawingTools, rulerModel);
             values = rulerDrawingResult.getTicksValues();
-            axes.setXAxisTicksLocations(toDoubleArray(values));
-            axes.setXAxisTicksLabels(toStringArray(values));
-            axes.setXAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
+            if (axes.getXAxisAutoTicks()) {
+                // TODO
+                axes.setXAxisTicksLocations(toDoubleArray(values));
+                axes.setXAxisTicksLabels(toStringArray(values));
+                axes.setXAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
+            }
 
             distanceRatio  = rulerDrawingResult.getMaxDistToTicksDirNorm();
-            double [] xticksdir = rulerDrawingResult.getNormalizedTicksDirection();
+            double [] xTicksDir = rulerDrawingResult.getNormalizedTicksDirection();
 
             xAxisLabelPositioner.setTicksDirection(xTicksDirection);
             xAxisLabelPositioner.setDistanceRatio(distanceRatio);
-            xAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(xticksdir[0], xticksdir[1], 0.0));
+            xAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(xTicksDir[0], xTicksDir[1], 0.0));
 
             if (axes.getXAxisGridColor() != -1) {
                 FloatBuffer vertexData = getXGridData(values, rulerModel);
@@ -184,74 +161,40 @@ public class AxesRulerDrawer {
 
         }
 
-
         // Draw Y ruler
-        if (axes.getAxes()[1].getAxisLocation().equals(AxisProperty.AxisLocation.LEFT)) {
-            zs = -Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
-            xs = -Math.signum(matrix[2]) * zs * Math.signum(matrix[10]);
-            if (xs == 0) {
-                xs = +1;
-            }
-        } else {
-            zs = Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
-            xs = -Math.signum(matrix[2]) * zs * Math.signum(matrix[10]); // Then switch X such that Z max but not in the middle.
-            if (xs == 0) {
-                xs = -1;
-            }
-        }
-
-        rulerModel.setFirstPoint(new Vector3d(xs, 1, zs));
-        rulerModel.setSecondPoint(new Vector3d(xs, -1, zs));
+        rulerModel.setTicksDirection(yTicksDirection);
+        rulerModel.setFirstPoint(yAxisPosition.setY(1));
+        rulerModel.setSecondPoint(yAxisPosition.setY(-1));
 
+        setRulerBounds(axes.getYAxis(), rulerModel, bounds[2], bounds[3]);
+        rulerModel.setLogarithmic(axes.getYAxis().getLogFlag());
 
-        if (px.getNorm2() > pz.getNorm2()) {
-            rulerModel.setTicksDirection(new Vector3d(TICKS_SIZE * xs, 0, 0));
-        } else {
-            rulerModel.setTicksDirection(new Vector3d(0, 0, TICKS_SIZE * zs));
-        }
-
-
-        if (axes.getAxes()[1].getReverse()) {
-            min = bounds[2];
-            max = bounds[3];
+        if (!axes.getAxes()[1].getAutoTicks()) {
+            rulerModel.setUserGraduation(new UserDefineGraduation(axes.getXAxis(), bounds[2], bounds[3]));
+            rulerModel.setAutoTicks(false);
         } else {
-            min = bounds[3];
-            max = bounds[2];
+            rulerModel.setAutoTicks(true);
         }
 
-        if (axes.getAxes()[1].getLogFlag()) {
-            rulerModel.setLogarithmic(true);
-            min = Math.pow(10, min);
-            max = Math.pow(10, max);
-        } else {
-            rulerModel.setLogarithmic(false);
-        }
-
-        rulerModel.setValues(min, max);
-
-        otherbounds[0] = (xs > 0) ? +1 : -1;
-        otherbounds[1] = (zs > 0) ? +1 : -1;
-
-        labelPosition = new Vector3d(otherbounds[0], midpoints[1], otherbounds[1]);
-
-        AxisLabelPositioner yAxisLabelPositioner = (AxisLabelPositioner) axesDrawer.getYAxisLabelPositioner();
-        yAxisLabelPositioner.setLabelPosition(labelPosition);
+        AxisLabelPositioner yAxisLabelPositioner = axesDrawer.getYAxisLabelPositioner();
+        yAxisLabelPositioner.setLabelPosition(yAxisPosition);
 
         if (axes.getYAxisVisible()) {
-            rulerDrawingResult = rulerDrawer.draw(drawingTools, rulerModel);
+            rulerDrawingResult = rulerDrawers[1].draw(drawingTools, rulerModel);
             values = rulerDrawingResult.getTicksValues();
-            axes.setYAxisTicksLocations(toDoubleArray(values));
-            axes.setYAxisTicksLabels(toStringArray(values));
-            axes.setYAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
-
-            Vector3d yTicksDirection = rulerModel.getTicksDirection();
+            if (axes.getYAxisAutoTicks()) {
+                // TODO
+                axes.setYAxisTicksLocations(toDoubleArray(values));
+                axes.setYAxisTicksLabels(toStringArray(values));
+                axes.setYAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
+            }
 
             distanceRatio = rulerDrawingResult.getMaxDistToTicksDirNorm();
-            double [] yticksdir = rulerDrawingResult.getNormalizedTicksDirection();
+            double [] yTicksDir = rulerDrawingResult.getNormalizedTicksDirection();
 
             yAxisLabelPositioner.setTicksDirection(yTicksDirection);
             yAxisLabelPositioner.setDistanceRatio(distanceRatio);
-            yAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(yticksdir[0], yticksdir[1], 0.0));
+            yAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(yTicksDir[0], yTicksDir[1], 0.0));
 
             if (axes.getYAxisGridColor() != -1) {
                 FloatBuffer vertexData = getYGridData(values, rulerModel);
@@ -278,8 +221,8 @@ public class AxesRulerDrawer {
 
         // Draw Z ruler
         if (axes.getViewAsEnum() == Camera.ViewType.VIEW_3D && axes.getRotationAngles()[1] != 90.0) {
-            double txs;
-            double tys;
+            double txs, tys, xs, ys;
+
             if (Math.abs(matrix[2]) < Math.abs(matrix[6])) {
                 xs = Math.signum(matrix[2]);
                 ys = -Math.signum(matrix[6]);
@@ -297,45 +240,35 @@ public class AxesRulerDrawer {
             rulerModel.setTicksDirection(new Vector3d(TICKS_SIZE * txs, TICKS_SIZE * tys, 0));
 
 
-            if (axes.getAxes()[2].getReverse()) {
-                min = bounds[4];
-                max = bounds[5];
-            } else {
-                min = bounds[5];
-                max = bounds[4];
-            }
+            setRulerBounds(axes.getZAxis(), rulerModel, bounds[4], bounds[5]);
+            rulerModel.setLogarithmic(axes.getZAxis().getLogFlag());
 
-            if (axes.getAxes()[2].getLogFlag()) {
-                rulerModel.setLogarithmic(true);
-                min = Math.pow(10, min);
-                max = Math.pow(10, max);
+            if (!axes.getAxes()[2].getAutoTicks()) {
+                rulerModel.setUserGraduation(new UserDefineGraduation(axes.getXAxis(), bounds[4], bounds[5]));
+                rulerModel.setAutoTicks(false);
             } else {
-                rulerModel.setLogarithmic(false);
+                rulerModel.setAutoTicks(true);
             }
 
-            rulerModel.setValues(min, max);
-
-            otherbounds[0] = (xs > 0) ? +1 : -1;
-            otherbounds[1] = (ys > 0) ? +1 : -1;
-
-            labelPosition = new Vector3d(otherbounds[0], otherbounds[1], midpoints[2]);
-
-            AxisLabelPositioner zAxisLabelPositioner = (AxisLabelPositioner) axesDrawer.getZAxisLabelPositioner();
-            zAxisLabelPositioner.setLabelPosition(labelPosition);
+            AxisLabelPositioner zAxisLabelPositioner = axesDrawer.getZAxisLabelPositioner();
+            zAxisLabelPositioner.setLabelPosition(new Vector3d(xs, ys, 0));
 
             if (axes.getZAxisVisible()) {
-                rulerDrawingResult = rulerDrawer.draw(drawingTools, rulerModel);
+                rulerDrawingResult = rulerDrawers[2].draw(drawingTools, rulerModel);
                 values = rulerDrawingResult.getTicksValues();
-                axes.setZAxisTicksLocations(toDoubleArray(values));
-                axes.setZAxisTicksLabels(toStringArray(values));
-                axes.setZAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
+                if (axes.getZAxisAutoTicks()) {
+                    // TODO
+                    axes.setZAxisTicksLocations(toDoubleArray(values));
+                    axes.setZAxisTicksLabels(toStringArray(values));
+                    axes.setZAxisSubticks(rulerDrawingResult.getSubTicksDensity() - 1);
+                }
 
                 distanceRatio = rulerDrawingResult.getMaxDistToTicksDirNorm();
-                double [] zticksdir = rulerDrawingResult.getNormalizedTicksDirection();
+                double [] zTicksDir = rulerDrawingResult.getNormalizedTicksDirection();
 
                 zAxisLabelPositioner.setTicksDirection(new Vector3d(TICKS_SIZE * txs, TICKS_SIZE * tys, 0.0));
                 zAxisLabelPositioner.setDistanceRatio(distanceRatio);
-                zAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(zticksdir[0], zticksdir[1], 0.0));
+                zAxisLabelPositioner.setProjectedTicksDirection(new Vector3d(zTicksDir[0], zTicksDir[1], 0.0));
 
                 if (axes.getZAxisGridColor() != -1 || !axes.getZAxisVisible()) {
                     FloatBuffer vertexData = getZGridData(values, rulerModel);
@@ -364,6 +297,59 @@ public class AxesRulerDrawer {
         drawingTools.getCanvas().getBuffersManager().dispose(vertexBuffer);
     }
 
+    private void setRulerBounds(AxisProperty axis, RulerModel rulerModel, double axisMin, double axisMax) {
+        double min, max;
+        if (axis.getReverse()) {
+            min = axisMin;
+            max = axisMax;
+        } else {
+            min = axisMax;
+            max = axisMin;
+        }
+
+        if (axis.getLogFlag()) {
+            min = Math.pow(10, min);
+            max = Math.pow(10, max);
+        }
+        rulerModel.setValues(min, max);
+    }
+
+    private Vector3d computeXAxisPosition(double[] matrix, AxisProperty.AxisLocation axisLocation) {
+        double y, z;
+        if (axisLocation.equals(AxisProperty.AxisLocation.BOTTOM)) {
+            z = -Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
+            y = -Math.signum(matrix[6]) * z * Math.signum(matrix[10]);
+            if (y == 0) {
+                y = +1;
+            }
+        } else {
+            z = Math.signum(matrix[9]);  // First : switch Z such that Y was maximal.
+            y = -Math.signum(matrix[6]) * z * Math.signum(matrix[10]);
+            if (y == 0) {
+                y = -1;
+            }
+        } // TODO : center, origin case ?!
+        return new Vector3d(0, y, z);
+    }
+
+    private Vector3d computeYAxisPosition(double[] matrix, AxisProperty.AxisLocation axisLocation) {
+        double x, z;
+        if (axisLocation.equals(AxisProperty.AxisLocation.LEFT)) {
+            z = -Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
+            x = -Math.signum(matrix[2]) * z * Math.signum(matrix[10]);
+            if (x == 0) {
+                x = +1;
+            }
+        } else {
+            z = Math.signum(matrix[9]);  // First : switch Z such that Y was minimal.
+            x = -Math.signum(matrix[2]) * z * Math.signum(matrix[10]); // Then switch X such that Z max but not in the middle.
+            if (x == 0) {
+                x = -1;
+            }
+        } // TODO : center, origin case ?!
+        return new Vector3d(x, 0, z);
+    }
+
     private String[] toStringArray(double[] values) {
         String[] r = new String[values.length];
         for (int i = 0; i < values.length; i++) {
@@ -460,4 +446,4 @@ public class AxesRulerDrawer {
     public void dispose(String id) {
         this.rulerDrawerManager.dispose(id);
     }
-}
+}
\ No newline at end of file
index 8826524..e6c17b9 100644 (file)
@@ -18,6 +18,7 @@ import org.scilab.forge.scirenderer.sprite.SpriteDrawingTools;
 import org.scilab.forge.scirenderer.sprite.SpriteManager;
 import org.scilab.forge.scirenderer.sprite.TextEntity;
 import org.scilab.modules.graphic_objects.axes.Axes;
+import org.scilab.modules.graphic_objects.axes.AxisProperty;
 import org.scilab.modules.graphic_objects.figure.ColorMap;
 import org.scilab.modules.graphic_objects.figure.Figure;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
@@ -41,6 +42,8 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
      */
     private final Axes axes;
 
+    private final int axisId;
+
     /**
      * The current colormap.
      */
@@ -48,9 +51,11 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
 
     /**
      * Default constructor.
-     * @param axes This factory create ruler label for this given {@see Axes}.
+     * @param axes This factory create ruler label for one axis of this given {@see Axes}.
+     * @param axisId the id of the managed axis.
      */
-    public AxesRulerSpriteFactory(Axes axes) {
+    public AxesRulerSpriteFactory(Axes axes, int axisId) {
+        this.axisId = axisId;
         this.axes = axes;
         ColorMap figureColorMap;
         try {
@@ -65,14 +70,18 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
 
     @Override
     public Sprite create(double value, DecimalFormat adaptedFormat, SpriteManager spriteManager) {
-
-        DecimalFormatSymbols decimalFormatSymbols = adaptedFormat.getDecimalFormatSymbols();
-        decimalFormatSymbols.setDecimalSeparator('.');
-        decimalFormatSymbols.setExponentSeparator("e");
-        adaptedFormat.setDecimalFormatSymbols(decimalFormatSymbols);
-
-        String text = adaptedFormat.format(value).replaceAll("E", "e");
-        final TextEntity textEntity = new TextEntity(text);
+        final TextEntity textEntity;
+        if (axes.getAxes()[axisId].getAutoTicks()) {
+            DecimalFormatSymbols decimalFormatSymbols = adaptedFormat.getDecimalFormatSymbols();
+            decimalFormatSymbols.setDecimalSeparator('.');
+            decimalFormatSymbols.setExponentSeparator("e");
+            adaptedFormat.setDecimalFormatSymbols(decimalFormatSymbols);
+    
+            String text = adaptedFormat.format(value).replaceAll("E", "e");
+            textEntity = new TextEntity(text);
+        } else {            
+            textEntity = new TextEntity(getTextAtValue(axes.getAxes()[axisId], value));
+        }
 
         textEntity.setTextAntiAliased(false);
         textEntity.setTextUseFractionalMetrics(axes.getFontFractional());
@@ -98,4 +107,20 @@ class AxesRulerSpriteFactory implements RulerSpriteFactory {
 
         return sprite;
     }
+
+    private String getTextAtValue(AxisProperty axisProperty, double value) {
+        Double[] locations = axisProperty.getTicksLocations();
+        int index = -1;
+        for (int i = 0 ; i < locations.length ; i++) {
+            if (locations[i] == value) {
+                index = i;
+                break;
+            }
+        }
+        if (index == -1) {
+            return "";
+        } else {
+            return axisProperty.getTicksLabels().get(index).getText();
+        }        
+    }
 }
index f863650..5f68965 100644 (file)
@@ -28,7 +28,7 @@ import java.util.Set;
  *
  * @author Pierre Lando
  */
-public class RulerDrawerManager {
+class RulerDrawerManager {
 
     /**
      * Set of properties that affect ruler sprites.
@@ -37,14 +37,17 @@ public class RulerDrawerManager {
             GraphicObjectProperties.__GO_FONT_SIZE__,
             GraphicObjectProperties.__GO_FONT_COLOR__,
             GraphicObjectProperties.__GO_FONT_STYLE__,
-            GraphicObjectProperties.__GO_FONT_FRACTIONAL__
+            GraphicObjectProperties.__GO_FONT_FRACTIONAL__,
+            GraphicObjectProperties.__GO_X_AXIS_AUTO_TICKS__,
+            GraphicObjectProperties.__GO_Y_AXIS_AUTO_TICKS__,
+            GraphicObjectProperties.__GO_Z_AXIS_AUTO_TICKS__
     ));
 
     /**
      * Map of up to date {@see RulerSpriteManager}
      * The key are the {@see Axes} id.
      */
-    private final Map<String, RulerDrawer> rulerSpriteManagerMap = new HashMap<String, RulerDrawer>();
+    private final Map<String, RulerDrawer[]> rulerSpriteManagerMap = new HashMap<String, RulerDrawer[]>();
 
     /**
      * The {@see SpriteManager} of the current {@see Canvas}.
@@ -64,11 +67,13 @@ public class RulerDrawerManager {
      * @param axes the given {@see Axes}
      * @return the {@see RulerSpriteManager} for the rulers of the given {@see Axes}.
      */
-    public RulerDrawer get(Axes axes) {
-        RulerDrawer rulerSpriteManager = rulerSpriteManagerMap.get(axes.getIdentifier());
+    public RulerDrawer[] get(Axes axes) {
+        RulerDrawer[] rulerSpriteManager = rulerSpriteManagerMap.get(axes.getIdentifier());
         if (rulerSpriteManager == null) {
-            rulerSpriteManager = new RulerDrawer(spriteManager);
-            rulerSpriteManager.setSpriteFactory(new AxesRulerSpriteFactory(axes));
+            rulerSpriteManager = new RulerDrawer[]{new RulerDrawer(spriteManager), new RulerDrawer(spriteManager), new RulerDrawer(spriteManager)};
+            rulerSpriteManager[0].setSpriteFactory(new AxesRulerSpriteFactory(axes, 0));
+            rulerSpriteManager[1].setSpriteFactory(new AxesRulerSpriteFactory(axes, 1));
+            rulerSpriteManager[2].setSpriteFactory(new AxesRulerSpriteFactory(axes, 2));
             rulerSpriteManagerMap.put(axes.getIdentifier(), rulerSpriteManager);
         }
         return rulerSpriteManager;
@@ -84,6 +89,7 @@ public class RulerDrawerManager {
 
         /**
          * If update affect {@see Axes} ruler sprites, we clear the corresponding {@see RulerSpriteManager}.
+         * TODO : optimize by an X, Y, Z auto ticks differentiation.
          */
         if (SPRITE_PROPERTIES.contains(property)) {
             dispose(id);
@@ -95,9 +101,13 @@ public class RulerDrawerManager {
      * @param id the {@see Axes} id.
      */
     public void dispose(String id) {
-        RulerDrawer spriteManager = rulerSpriteManagerMap.get(id);
-        if (spriteManager != null) {
-            spriteManager.disposeResources();
+        RulerDrawer[] rulerDrawers = rulerSpriteManagerMap.get(id);
+        if (rulerDrawers != null) {
+            for (RulerDrawer rulerDrawer : rulerDrawers) {
+                if (rulerDrawer != null) {
+                    rulerDrawer.disposeResources();
+                }
+            }
         }
         rulerSpriteManagerMap.remove(id);
     }
@@ -106,8 +116,14 @@ public class RulerDrawerManager {
      * Dispose all the {@see RulerSpriteManager}.
      */
     public void disposeAll() {
-        for (RulerDrawer spriteManager : rulerSpriteManagerMap.values()) {
-            spriteManager.disposeResources();
+        for (RulerDrawer[] rulerDrawers : rulerSpriteManagerMap.values()) {
+            if (rulerDrawers != null) {
+                for (RulerDrawer rulerDrawer : rulerDrawers) {
+                    if (rulerDrawer != null) {
+                        rulerDrawer.disposeResources();
+                    }
+                }
+            }
         }
         rulerSpriteManagerMap.clear();
     }
diff --git a/scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/UserDefineGraduation.java b/scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/UserDefineGraduation.java
new file mode 100644 (file)
index 0000000..c301cfd
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2011 - DIGITEO - Pierre Lando
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ */
+
+package org.scilab.modules.renderer.JoGLView.axes.ruler;
+
+import org.scilab.forge.scirenderer.ruler.graduations.Graduations;
+import org.scilab.modules.graphic_objects.axes.AxisProperty;
+
+import java.text.DecimalFormat;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Pierre Lando
+ */
+class UserDefineGraduation implements Graduations {
+    private final AxisProperty axisProperty;
+    private final double lowerBound;
+    private final double upperBound;
+
+    private List<Double> allValues;
+
+    public UserDefineGraduation(AxisProperty axisProperty, double lowerBound, double upperBound) {
+        this.axisProperty = axisProperty;
+        this.lowerBound = lowerBound;
+        this.upperBound = upperBound;
+    }
+
+    @Override
+    public double getLowerBound() {
+        return lowerBound;
+    }
+
+    @Override
+    public boolean isLowerBoundIncluded() {
+        return true;
+    }
+
+    @Override
+    public double getUpperBound() {
+        return upperBound;
+    }
+
+    @Override
+    public boolean isUpperBoundIncluded() {
+        return true;
+    }
+
+    @Override
+    public boolean contain(double value) {
+        return (getLowerBound() <= value) && (value <= getUpperBound());
+    }
+
+    @Override
+    public DecimalFormat getFormat() {
+        /**
+         * Will never be used. The label was defined by the user too.
+         */
+        return new DecimalFormat();
+    }
+
+    @Override
+    public List<Double> getAllValues() {
+        if (allValues == null) {
+            allValues = Arrays.asList(axisProperty.getTicksLocations());
+        }
+        return allValues;
+    }
+
+    @Override
+    public List<Double> getNewValues() {
+        return getAllValues();
+    }
+
+    @Override
+    public Graduations getParentGraduations() {
+        return null;
+    }
+
+    @Override
+    public Graduations getMore() {
+        return null;
+    }
+
+    @Override
+    public Graduations getAlternative() {
+        return null;
+    }
+
+    @Override
+    public Graduations getSubGraduation() {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public int getSubDensity() {
+        return axisProperty.getSubticks() + 1;
+    }
+
+}