Graphics: xstringl returned bad values between drawlater/drawnow
[scilab.git] / scilab / modules / renderer / src / java / org / scilab / modules / renderer / JoGLView / axes / AxesDrawer.java
index bb02744..7a39aff 100644 (file)
@@ -124,6 +124,19 @@ public class AxesDrawer {
         reversedBoundsIntervals = new double[3];
     }
 
+    public Transformation getCurrentProjection(Axes axes) throws DegenerateMatrixException {
+        DrawingTools drawingTools = visitor.getDrawingTools();
+        Canvas canvas = visitor.getCanvas();
+        Transformation zoneProjection = computeZoneProjection(axes);
+        Transformation transformation = computeBoxTransformation(axes, canvas, false);
+        Transformation dataTransformation = computeDataTransformation(axes);
+        Transformation windowTrans = drawingTools.getTransformationManager().getWindowTransformation().getInverseTransformation();
+        Transformation current = zoneProjection.rightTimes(transformation);
+        current = current.rightTimes(dataTransformation);
+
+        return windowTrans.rightTimes(current);
+    }
+
     /**
      * Draw the given {@see Axes}.
      * @param axes {@see Axes} to draw.
@@ -277,10 +290,10 @@ public class AxesDrawer {
         double[] matrix = transformation.getMatrix();
         try {
             return TransformationFactory.getScaleTransformation(
-                matrix[2] < 0 ? 1 : -1,
-                matrix[6] < 0 ? 1 : -1,
-                matrix[10] < 0 ? 1 : -1
-                );
+                       matrix[2] < 0 ? 1 : -1,
+                       matrix[6] < 0 ? 1 : -1,
+                       matrix[10] < 0 ? 1 : -1
+                   );
         } catch (DegenerateMatrixException e) {
             // Should never happen.
             return TransformationFactory.getIdentity();
@@ -347,26 +360,26 @@ public class AxesDrawer {
 
         // Reverse data if needed.
         Transformation transformation = TransformationFactory.getScaleTransformation(
-            axes.getAxes()[0].getReverse() ? 1 : -1,
-            axes.getAxes()[1].getReverse() ? 1 : -1,
-            axes.getAxes()[2].getReverse() ? 1 : -1
-            );
+                                            axes.getAxes()[0].getReverse() ? 1 : -1,
+                                            axes.getAxes()[1].getReverse() ? 1 : -1,
+                                            axes.getAxes()[2].getReverse() ? 1 : -1
+                                        );
 
         // Scale data.
         Transformation scaleTransformation = TransformationFactory.getScaleTransformation(
-            2.0 / (bounds[1] - bounds[0]),
-            2.0 / (bounds[3] - bounds[2]),
-            2.0 / (bounds[5] - bounds[4])
-            );
+                2.0 / (bounds[1] - bounds[0]),
+                2.0 / (bounds[3] - bounds[2]),
+                2.0 / (bounds[5] - bounds[4])
+                                             );
         transformation = transformation.rightTimes(scaleTransformation);
 
 
         // Translate data.
         Transformation translateTransformation = TransformationFactory.getTranslateTransformation(
-            -(bounds[0] + bounds[1]) / 2.0,
-            -(bounds[2] + bounds[3]) / 2.0,
-            -(bounds[4] + bounds[5]) / 2.0
-            );
+                    -(bounds[0] + bounds[1]) / 2.0,
+                    -(bounds[2] + bounds[3]) / 2.0,
+                    -(bounds[4] + bounds[5]) / 2.0
+                );
         transformation = transformation.rightTimes(translateTransformation);
         return transformation;
     }