Bug 12389 fixed: Axes sizes were not taken into account in offscreen export 29/10829/2
Calixte DENIZET [Thu, 14 Mar 2013 15:19:44 +0000 (16:19 +0100)]
Change-Id: Ibfff32b0fe0806360840d3a454bcbda950dff49d

scilab/CHANGES_5.4.X
scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/Export.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java

index 1f69bda..4c80fb5 100644 (file)
@@ -544,6 +544,8 @@ Bug fixes
 
 * Bug #12386 fixed - sgrid example improved in the list of graphics.
 
+* Bug #12389 fixed - Axes sizes were not taken into account in offscreen export.
+
 
                     Changes between version 5.3.3 and 5.4.0
                     =======================================
index cbb0ecb..928a18d 100644 (file)
@@ -48,6 +48,7 @@ import org.scilab.modules.commons.ScilabCommonsUtils;
 import org.scilab.modules.graphic_export.convertToPPM.PPMEncoder;
 import org.scilab.modules.graphic_objects.figure.Figure;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
 import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -336,8 +337,8 @@ public class Export {
      * @param file the file where to export
      * @param params the export paramaters
      */
-    public static void setVisitor(String uid, int type, ExportParams params) {
-        Exporter exporter = getExporter(types[type]);
+    public static void setVisitor(String uid, int type, final ExportParams params) {
+        final Exporter exporter = getExporter(types[type]);
         Figure figure = (Figure) GraphicController.getController().getObjectFromId(uid);
         Integer[] dims = figure.getAxesSize();
         int width = dims[0];
@@ -353,6 +354,22 @@ public class Export {
             public void deleteObject(String id) {
                 // Don't delete during the export
             }
+
+            @Override
+            public void updateObject(String id, int property) {
+                if (property == GraphicObjectProperties.__GO_AXES_SIZE__) {
+                    Integer[] size = getFigure().getAxesSize();
+                    Graphics2D g2d = exporter.getGraphics2D(size[0], size[1], null, params);
+                    params.setParamsOnGraphics(g2d);
+
+                    G2DCanvas canvas = G2DCanvasFactory.createCanvas(g2d, size[0], size[1]);
+                    canvas.disableDraw();
+                    setCanvas(canvas);
+
+                    setDrawingTools(canvas.getDrawingTools());
+                    canvas.setMainDrawer(this);
+                }
+            }
         };
         visitor.setDrawingTools(canvas.getDrawingTools());
         canvas.setMainDrawer(visitor);
index 004e892..8d4aebf 100644 (file)
@@ -118,7 +118,6 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     private static final boolean DEBUG_MODE = false;
 
     private final Component component;
-    private final Canvas canvas;
     private final Figure figure;
     private final InteractionManager interactionManager;
 
@@ -142,6 +141,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     private ColorMap colorMap;
 
     private Axes currentAxes;
+    private Canvas canvas;
 
     /**
      * The map between the existing Figures' identifiers and their corresponding Visitor.
@@ -202,6 +202,10 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         return canvas;
     }
 
+    public void setCanvas(Canvas canvas) {
+        this.canvas = canvas;
+    }
+
     /**
      * @return the DataManager
      */