Use real link figure_size <-> axes_size 58/12958/2
Bruno JOFRET [Fri, 18 Oct 2013 13:40:45 +0000 (15:40 +0200)]
Change-Id: Ib37af2ca79abf800240b4dc757aea18b9ba8b8a1

scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/window/SwingScilabWindow.java

index 51463e4..2244bf8 100644 (file)
@@ -121,23 +121,6 @@ import org.scilab.modules.gui.utils.ScilabSwingUtilities;
 import org.scilab.modules.gui.utils.Size;
 import org.scilab.modules.gui.utils.ToolBarBuilder;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SIZE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AUTORESIZE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES_SIZE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_ENABLE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ID__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_EVENTHANDLER_NAME__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFO_MESSAGE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_NAME__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICHECKEDMENU__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICHILDMENU__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIPARENTMENU__;
-
 import org.scilab.modules.gui.editor.EditorEventListener;
 
 /**
@@ -1472,7 +1455,19 @@ public class SwingScilabTab extends View implements SwingViewObject, SimpleTab,
             break;
         case __GO_SIZE__ :
             Integer[] size = (Integer[]) value;
-            SwingScilabWindow.allScilabWindows.get(parentWindowId).setDims(new Size(size[0], size[1]));
+            SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(parentWindowId);
+            Size oldFigureSize = figure.getDims();
+            figure.setDims(new Size(size[0], size[1]));
+            int deltaFigureX = size[0] - (int) oldFigureSize.getWidth();
+            int deltaFigureY = size[1] - (int) oldFigureSize.getHeight();
+            if ( oldFigureSize.getWidth() != 0 && oldFigureSize.getHeight() != 0
+                    && ((oldFigureSize.getWidth() != size[0]) || (oldFigureSize.getHeight() != size[1]))
+                    && ((Boolean) GraphicController.getController().getProperty(getId(), __GO_AUTORESIZE__))
+                    ) {
+                Integer[] axesSize = (Integer[]) GraphicController.getController().getProperty(getId(), __GO_AXES_SIZE__);
+                Integer[] newAxesSize = {axesSize[0] + deltaFigureX, axesSize[1] + deltaFigureY};
+                GraphicController.getController().setProperty(getId(), __GO_AXES_SIZE__, newAxesSize);  
+            }
             break;
         case __GO_POSITION__ :
             Integer[] position = (Integer[]) value;
@@ -1491,6 +1486,8 @@ public class SwingScilabTab extends View implements SwingViewObject, SimpleTab,
                 Size parentWindowSize = SwingScilabWindow.allScilabWindows.get(parentWindowId).getDims();
                 SwingScilabWindow.allScilabWindows.get(parentWindowId).setDims(
                         new Size(parentWindowSize.getWidth() + deltaX, parentWindowSize.getHeight() + deltaY));
+                Integer figureSize[] = {parentWindowSize.getWidth() + deltaX, parentWindowSize.getHeight() + deltaY};
+                GraphicController.getController().setProperty(getId(), __GO_SIZE__, figureSize);
             }
             break;
         case __GO_INFO_MESSAGE__ :
index 4546ca5..71cc9da 100644 (file)
@@ -354,8 +354,6 @@ public class SwingScilabWindow extends JFrame implements SimpleWindow {
      */
     @Override
     public void setDims(Size newWindowSize) {
-        //System.out.println("{SwingScilabWindow.setDims} "+newWindowSize.getWidth()+"x"+newWindowSize.getHeight());
-        //System.out.println("{called by} "+Thread.currentThread().getStackTrace()[2]);
         //if (!SwingUtilities.isEventDispatchThread()) {
         if (getDims().getWidth() != newWindowSize.getWidth() || getDims().getHeight() != newWindowSize.getHeight()) {
             Dimension finalDim = new Dimension(newWindowSize.getWidth(), newWindowSize.getHeight());