call figure resize function with and without axes 23/14023/2
Antoine ELIAS [Fri, 14 Mar 2014 11:45:40 +0000 (12:45 +0100)]
Change-Id: I3d71347f8cb665d3a5a5e335bf70c23ee8881e59

scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabDockablePanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabStaticPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java

index 9f395e9..5fe6057 100644 (file)
@@ -61,6 +61,7 @@ import org.scilab.modules.commons.ScilabConstants;
 import org.scilab.modules.commons.gui.FindIconHelper;
 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.gui.SwingViewObject;
 import org.scilab.modules.gui.bridge.canvas.SwingScilabCanvas;
 import org.scilab.modules.gui.bridge.checkbox.SwingScilabCheckBox;
@@ -333,6 +334,16 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
                     Integer[] newAxesSize = new Integer[] {getContentPane().getWidth(), getContentPane().getHeight()};
                     GraphicController.getController().setProperty(id, __GO_AXES_SIZE__, newAxesSize);
                 }
+
+                String resizeFcn = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_RESIZEFCN__);
+                if (resizeFcn != null && !resizeFcn.equals("")) {
+                    String resizeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;"
+                                           + "gcbo = getcallbackobject(" + id + ");"
+                                           + resizeFcn
+                                           + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
+                    InterpreterManagement.requestScilabExec(resizeCommand);
+                }
+
             }
 
             public void componentMoved(ComponentEvent arg0) {
index 7445655..b54d86d 100644 (file)
@@ -23,8 +23,10 @@ import java.awt.event.ComponentListener;
 import javax.swing.JLayeredPane;
 import javax.swing.SwingUtilities;
 
+import org.scilab.modules.action_binding.InterpreterManagement;
 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.gui.SwingViewObject;
 import org.scilab.modules.gui.bridge.canvas.SwingScilabCanvas;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
@@ -47,7 +49,7 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
 
     private JLayeredPane uiContentPane;
     private JLayeredPane layerdPane;
-    
+
     private SwingScilabCanvas contentCanvas;
 
     public SwingScilabStaticPanel(String figureTitle, Integer figureId, Figure figure) {
@@ -87,6 +89,15 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
                     Integer[] newAxesSize = new Integer[] { getContentPane().getWidth(), getContentPane().getHeight() };
                     GraphicController.getController().setProperty(id, __GO_AXES_SIZE__, newAxesSize);
                 }
+
+                String resizeFcn = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_RESIZEFCN__);
+                if (resizeFcn != null && !resizeFcn.equals("")) {
+                    String resizeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;"
+                                           + "gcbo = getcallbackobject(" + id + ");"
+                                           + resizeFcn
+                                           + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
+                    InterpreterManagement.requestScilabExec(resizeCommand);
+                }
             }
 
             public void componentMoved(ComponentEvent arg0) {
index f2b7404..ffb6a71 100644 (file)
@@ -62,16 +62,6 @@ public class PanelLayout implements LayoutManager, Serializable {
                 parent.setComponentZOrder(child, parent.getComponentCount() - 1);
             }
 
-            Integer figureIdentifier = ((SwingScilabCanvas) parent).getFigure().getIdentifier();
-            String resizeFcn = (String) GraphicController.getController().getProperty(figureIdentifier, GraphicObjectProperties.__GO_RESIZEFCN__);
-            if (resizeFcn != null && !resizeFcn.equals("")) {
-                String resizeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;"
-                                       + "gcbo = getcallbackobject(" + figureIdentifier + ");"
-                                       + resizeFcn
-                                       + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
-                InterpreterManagement.requestScilabExec(resizeCommand);
-            }
-
             /* Here you can perform the layout of UI object. */
             if (child instanceof SwingViewObject) {
                 Integer id = ((SwingViewObject) child).getId();