Bug 12289 fixed: sub_ticks property was ignored 93/10993/3
Calixte DENIZET [Mon, 25 Mar 2013 14:41:42 +0000 (15:41 +0100)]
Change-Id: I45bbe945ba9ff9ccd2d35e834a4694b1fa8af955

scilab/CHANGES_5.4.X
scilab/modules/graphics/src/c/getHandleProperty/set_sub_tics_property.c
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.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/UserDefineGraduation.java

index 633edc5..b88e23e 100644 (file)
@@ -534,6 +534,10 @@ Bug fixes
 
 * Bug #12285 fixed - export_to_hdf5 function did not manage any matrix in append mode.
 
+* Bug #12289 fixed - sub_ticks property was ignored.
+
+* Bug #12291 fixed - Unable to display a list of handle as an handle userData.
+
 * Bug #12291 fixed - A list of handles could not be displayed as a handle userdata.
 
 * Bug #12296 fixed - Calling getenv with a big environment variable
index feed13a..6ed84e0 100644 (file)
@@ -88,7 +88,8 @@ int set_sub_tics_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int
          * The AUTO_SUBTICKS property is shared by the 3 axes for now.
          * To be modified.
          */
-        autoSubticks = 0;
+        int nbTicks = (int) values[0];
+        autoSubticks = nbTicks < 0 ? 1 : 0;
         status = setGraphicObjectProperty(pobjUID, __GO_AUTO_SUBTICKS__, &autoSubticks, jni_bool, 1);
 
         if (status == FALSE)
@@ -99,8 +100,6 @@ int set_sub_tics_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int
 
         for ( i = 0; i < nbCol ; i++ )
         {
-            int nbTicks;
-
             nbTicks = (int) values[i];
 
             if ( nbTicks < 0 )
index f8e1bdb..91ccd0b 100644 (file)
@@ -86,22 +86,19 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     /** Set of properties changed during a draw if auto-ticks is on for X axis. */
     private static final Set<Integer> X_AXIS_TICKS_PROPERTIES = new HashSet<Integer>(Arrays.asList(
                 GraphicObjectProperties.__GO_X_AXIS_TICKS_LOCATIONS__,
-                GraphicObjectProperties.__GO_X_AXIS_TICKS_LABELS__,
-                GraphicObjectProperties.__GO_X_AXIS_SUBTICKS__
+                GraphicObjectProperties.__GO_X_AXIS_TICKS_LABELS__
             ));
 
     /** Set of properties changed during a draw if auto-ticks is on for Y axis. */
     private static final Set<Integer> Y_AXIS_TICKS_PROPERTIES = new HashSet<Integer>(Arrays.asList(
                 GraphicObjectProperties.__GO_Y_AXIS_TICKS_LOCATIONS__,
-                GraphicObjectProperties.__GO_Y_AXIS_TICKS_LABELS__,
-                GraphicObjectProperties.__GO_Y_AXIS_SUBTICKS__
+                GraphicObjectProperties.__GO_Y_AXIS_TICKS_LABELS__
             ));
 
     /** Set of properties changed during a draw if auto-ticks is on for Z axis. */
     private static final Set<Integer> Z_AXIS_TICKS_PROPERTIES = new HashSet<Integer>(Arrays.asList(
                 GraphicObjectProperties.__GO_Z_AXIS_TICKS_LOCATIONS__,
-                GraphicObjectProperties.__GO_Z_AXIS_TICKS_LABELS__,
-                GraphicObjectProperties.__GO_Z_AXIS_SUBTICKS__
+                GraphicObjectProperties.__GO_Z_AXIS_TICKS_LABELS__
             ));
 
     /** Set of figure properties for witch a change doesn't lead to a redraw */
@@ -397,12 +394,16 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                 triangles.setFaceCullingMode(Geometry.FaceCullingMode.BOTH);
                 Appearance trianglesAppearance = new Appearance();
                 drawingTools.draw(triangles, trianglesAppearance);
-            } catch (ObjectRemovedException e) {
-                invalidate(grayplot, e);
-            } catch (SciRendererException e) {
-                invalidate(grayplot, e);
-            } catch (OutOfMemoryException e) {
-                invalidate(grayplot, e);
+                /*} catch (ObjectRemovedException e) {
+                        invalidate(grayplot, e);
+                    } catch (SciRendererException e) {
+                        invalidate(grayplot, e);
+                    } catch (OutOfMemoryException e) {
+                        invalidate(grayplot, e);
+                }*/
+            } catch (Exception e) {
+                System.err.println(e);
+                e.printStackTrace();
             }
             axesDrawer.disableClipping(grayplot.getClipProperty());
         }
index 0b5653a..147277c 100644 (file)
@@ -134,6 +134,9 @@ public class AxesRulerDrawer {
         rulerModel.setTicksDirection(xTicksDirection);
         rulerModel.setFirstPoint(xAxisPosition.setX(-1));
         rulerModel.setSecondPoint(xAxisPosition.setX(1));
+        if (!axes.getAutoSubticks()) {
+            rulerModel.setSubticksNumber(axes.getXAxisSubticks());
+        }
 
         setRulerBounds(axes.getXAxis(), rulerModel, bounds[0], bounds[1]);
 
@@ -159,7 +162,9 @@ public class AxesRulerDrawer {
                 Arrays.sort(values);
                 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_X_AXIS_TICKS_LOCATIONS__, toDoubleArray(values));
                 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_X_AXIS_TICKS_LABELS__, toStringArray(values, rulerDrawingResult.getFormat()));
-                GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_X_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                if (axes.getAutoSubticks()) {
+                    GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_X_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                }
             }
 
             distanceRatio = rulerDrawingResult.getMaxDistToTicksDirNorm();
@@ -179,6 +184,9 @@ public class AxesRulerDrawer {
         rulerModel.setTicksDirection(yTicksDirection);
         rulerModel.setFirstPoint(yAxisPosition.setY(-1));
         rulerModel.setSecondPoint(yAxisPosition.setY(1));
+        if (!axes.getAutoSubticks()) {
+            rulerModel.setSubticksNumber(axes.getYAxisSubticks());
+        }
 
         setRulerBounds(axes.getYAxis(), rulerModel, bounds[2], bounds[3]);
         rulerModel.setLogarithmic(axes.getYAxis().getLogFlag());
@@ -201,7 +209,9 @@ public class AxesRulerDrawer {
                 Arrays.sort(values);
                 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Y_AXIS_TICKS_LOCATIONS__, toDoubleArray(values));
                 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Y_AXIS_TICKS_LABELS__, toStringArray(values, rulerDrawingResult.getFormat()));
-                GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Y_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                if (axes.getAutoSubticks()) {
+                    GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Y_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                }
             }
 
             distanceRatio = rulerDrawingResult.getMaxDistToTicksDirNorm();
@@ -238,6 +248,9 @@ public class AxesRulerDrawer {
             rulerModel.setFirstPoint(new Vector3d(xs, ys, -1));
             rulerModel.setSecondPoint(new Vector3d(xs, ys, 1));
             rulerModel.setTicksDirection(new Vector3d(txs, tys, 0));
+            if (!axes.getAutoSubticks()) {
+                rulerModel.setSubticksNumber(axes.getZAxisSubticks());
+            }
 
             setRulerBounds(axes.getZAxis(), rulerModel, bounds[4], bounds[5]);
             rulerModel.setLogarithmic(axes.getZAxis().getLogFlag());
@@ -260,7 +273,9 @@ public class AxesRulerDrawer {
                     Arrays.sort(values);
                     GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Z_AXIS_TICKS_LOCATIONS__, toDoubleArray(values));
                     GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Z_AXIS_TICKS_LABELS__, toStringArray(values, rulerDrawingResult.getFormat()));
-                    GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Z_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                    if (axes.getAutoSubticks()) {
+                        GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_Z_AXIS_SUBTICKS__, rulerDrawingResult.getSubTicksDensity() - 1);
+                    }
                 }
 
                 distanceRatio = rulerDrawingResult.getMaxDistToTicksDirNorm();
index a24501a..d8e9dde 100644 (file)
@@ -16,6 +16,7 @@ import org.scilab.modules.graphic_objects.axes.AxisProperty;
 
 import java.text.DecimalFormat;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -28,6 +29,7 @@ class UserDefineGraduation implements Graduations {
     private final double upperBound;
 
     private List<Double> allValues;
+    private List<Double> subValues;
 
     public UserDefineGraduation(AxisProperty axisProperty, double lowerBound, double upperBound) {
         this.axisProperty = axisProperty;
@@ -103,8 +105,33 @@ class UserDefineGraduation implements Graduations {
     }
 
     @Override
+    public List<Double> getSubGraduations(final int N) {
+        if (subValues == null) {
+            if (N == 0) {
+                subValues = new LinkedList<Double>();
+            } else {
+                List<Double> ticksValue = getAllValues();
+                Collections.sort(ticksValue);
+                subValues = new LinkedList<Double>();
+
+                for (int i = 0; i < ticksValue.size() - 1; i++) {
+                    final double first = ticksValue.get(i);
+                    final double second = ticksValue.get(i + 1);
+                    final double step = (second - first) / (N + 1);
+                    double v = first + step;
+                    for (int j = 0; j < N; j++) {
+                        subValues.add(v);
+                        v += step;
+                    }
+                }
+            }
+        }
+
+        return subValues;
+    }
+
+    @Override
     public int getSubDensity() {
         return axisProperty.getSubticks() + 1;
     }
-
 }