* Bug #11964 fixed - uicontrol coordinates system did not take figure resizing into... 79/14079/6
Antoine ELIAS [Wed, 19 Mar 2014 16:44:15 +0000 (17:44 +0100)]
+ Fix axes_size and figure_size bug, toggle infobar/toolbar/menubar_visible change figure_size

Change-Id: Id3beb0f8eb479a2559b5f0b134319495d38b9f3d

scilab/CHANGES_5.5.X
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/builder/Builder.java
scilab/modules/gui/sci_gateway/c/sci_figure.c
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingView.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabFrame.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabCommonPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabDockablePanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabStaticPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/window/SwingScilabWindow.java
scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java

index e3d5c29..a8351a3 100644 (file)
@@ -458,6 +458,8 @@ Scilab Bug Fixes
 
 * Bug #11953 fixed - Scilab crashed when global("") was typed.
 
+* Bug #11964 fixed - uicontrol coordinates system did not take figure resizing into account.
+
 * Bug #11996 fixed - eye extended to hypermatrix.
 
 * Bug #12037 fixed - Simplified Chinese version of SciNotes displayed warnings at startup.
index 39f7a99..8900d15 100644 (file)
@@ -359,8 +359,6 @@ public final class Builder {
         ScilabNativeView.ScilabNativeView__setCurrentFigure(newFigure);
 
         //Force axes size after window creation
-        Integer[] figureSize = (Integer[]) controller.getProperty(figModel, GraphicObjectProperties.__GO_SIZE__);
-        controller.setProperty(newFigure, GraphicObjectProperties.__GO_SIZE__, figureSize);
         Integer[] axesSize = (Integer[]) controller.getProperty(figModel, GraphicObjectProperties.__GO_AXES_SIZE__);
         controller.setProperty(newFigure, GraphicObjectProperties.__GO_AXES_SIZE__, axesSize);
 
index fb531e9..a2a7024 100644 (file)
@@ -439,6 +439,7 @@ int setDefaultProperties(int _iFig, BOOL _bDefaultAxes)
     int iColorIndex = 0;
     int iFilled = 0;
     int iAxesVisible = 0;
+    int* piAxesSize = NULL;
     double pdblNewColor[COLOR_COMPONENT] = {0.8, 0.8, 0.8};
 
     setGraphicObjectProperty(_iFig, __GO_IMMEDIATE_DRAWING__, &iDrawing, jni_bool, 1);
@@ -460,6 +461,11 @@ int setDefaultProperties(int _iFig, BOOL _bDefaultAxes)
         setGraphicObjectProperty(iAxes, __GO_Y_AXIS_VISIBLE__, &iAxesVisible, jni_bool, 1);
         setGraphicObjectProperty(iAxes, __GO_Z_AXIS_VISIBLE__, &iAxesVisible, jni_bool, 1);
     }
+
+    // axes_size
+    getGraphicObjectProperty(getFigureModel(), __GO_AXES_SIZE__, jni_int_vector, (void **)&piAxesSize);
+    setGraphicObjectProperty(_iFig, __GO_AXES_SIZE__, piAxesSize, jni_int_vector, 2);
+
     //f.immediate_drawing = "on"
     iDrawing = 1;
     setGraphicObjectProperty(_iFig, __GO_IMMEDIATE_DRAWING__, &iDrawing, jni_bool, 1);
index 8224e20..c116b97 100644 (file)
@@ -426,7 +426,6 @@ public final class SwingView implements GraphicView {
                     tab = new SwingScilabDockablePanel(figureTitle, figureId, figure);
                 } else {
                     tab = new SwingScilabStaticPanel(figureTitle, figureId, figure);
-                    window.addTab(tab);
                 }
                 tab.setId(id);
 
@@ -451,6 +450,8 @@ public final class SwingView implements GraphicView {
                 if (figure.getDockable()) {
                     DockingManager.dock((SwingScilabDockablePanel) tab, window.getDockingPort());
                     ActiveDockableTracker.requestDockableActivation((SwingScilabDockablePanel) tab);
+                } else {
+                    window.addTab(tab);
                 }
 
                 tab.setWindowIcon("graphic-window");
@@ -468,7 +469,6 @@ public final class SwingView implements GraphicView {
                 } else {
                     infoBar.setText(infoMessage);
                 }
-                tab.update(__GO_SIZE__, GraphicController.getController().getProperty(id, __GO_SIZE__));
                 tab.update(__GO_POSITION__, GraphicController.getController().getProperty(id, __GO_POSITION__));
 
                 String icon = (String)GraphicController.getController().getProperty(id, __GO_UI_ICON__);
index e525969..6474adf 100644 (file)
@@ -92,6 +92,7 @@ import org.scilab.modules.gui.utils.ScilabRelief;
 import org.scilab.modules.gui.utils.Size;
 import org.scilab.modules.gui.utils.UnitsConverter;
 import org.scilab.modules.gui.utils.UnitsConverter.UicontrolUnits;
+import org.scilab.modules.gui.widget.Widget;
 
 /**
  * Swing implementation for Scilab frames in GUI
@@ -104,7 +105,7 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
 
     private Integer uid = -1;
     int redraw = 0;
-
+    protected boolean hasLayout = false;
     private Border defaultBorder = null;
 
     /**
@@ -114,6 +115,7 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
         super();
         // the Default layout is null so we have to set a Position and a Size of every Dockable we add to it
         super.setLayout(null);
+        hasLayout = false;
         addComponentListener(new ComponentListener() {
             public void componentShown(ComponentEvent e) { }
 
@@ -140,6 +142,16 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
                         GraphicController.getController().setProperty(getId(), GraphicObjectProperties.__GO_POSITION__, positions);
                     }
                 }
+
+                if (hasLayout == false) {
+                    for (Component comp : getComponents()) {
+                        if (comp instanceof Widget) {
+                            Widget widget = (Widget) comp;
+                            SwingViewObject obj = (SwingViewObject) comp;
+                            SwingViewWidget.update(widget, __GO_POSITION__, GraphicController.getController().getProperty(obj.getId(), __GO_POSITION__));
+                        }
+                    }
+                }
             }
 
             public void componentMoved(ComponentEvent e) { }
@@ -208,6 +220,7 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
             AxesContainer frame = (AxesContainer) GraphicModel.getModel().getObjectFromId(getId());
             SwingScilabCanvas canvas = new SwingScilabCanvas(frame);
             setLayout(new BorderLayout());
+            hasLayout = true;
             add(canvas, BorderLayout.CENTER);
             return;
         }
@@ -856,15 +869,18 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
                 break;
             }
             case __GO_LAYOUT__: {
+                hasLayout = false;
                 LayoutType newLayout = LayoutType.intToEnum((Integer) value);
                 switch (newLayout) {
                     case BORDER: {
                         Integer[] padding = (Integer[]) controller.getProperty(getId(), __GO_BORDER_OPT_PADDING__);
                         setLayout(new BorderLayout(padding[0], padding[1]));
+                        hasLayout = true;
                         break;
                     }
                     case GRIDBAG:
                         setLayout(new GridBagLayout());
+                        hasLayout = true;
                         break;
                     case GRID: {
                         Integer[] padding = (Integer[]) controller.getProperty(getId(), __GO_GRID_OPT_PADDING__);
@@ -874,11 +890,13 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
                         }
 
                         setLayout(new GridLayout(grid[0], grid[1], padding[0], padding[1]));
+                        hasLayout = true;
                         break;
                     }
                     case NONE:
                     default: {
                         setLayout(null);
+                        hasLayout = false;
                         break;
                     }
                 }
index f3836e1..c38f364 100644 (file)
@@ -82,18 +82,19 @@ public class SwingScilabCommonPanel {
      * Update the tab after a modification of its properties
      * @param property the property name
      * @param value the property value
-     * @see org.scilab.modules.gui.SwingViewObject#update(java.lang.String, java.lang.Object)
+     * @see org.scilab.modules.gui.SwingViewObject#update(java.lang.String,
+     * java.lang.Object)
      */
     protected static void update(SwingScilabPanel component, int property, Object value) {
         String name;
         Integer figureId;
         switch (property) {
-            case  __GO_NAME__ :
+            case __GO_NAME__:
                 name = ((String) value);
                 figureId = (Integer) GraphicController.getController().getProperty(component.getId(), __GO_ID__);
                 updateTitle(component, name, figureId);
                 break;
-            case __GO_ID__ :
+            case __GO_ID__:
                 /* Update title */
                 figureId = ((Integer) value);
                 Figure localFigure = (Figure) GraphicController.getController().getObjectFromId(component.getId());
@@ -103,112 +104,126 @@ public class SwingScilabCommonPanel {
                 /** Update tool bar */
                 if (localFigure.getToolbarAsEnum() == BarType.FIGURE) {
                     SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+
+                    //keep current delta between figure size and axes size
+                    component.storeSizeDelta();
+
                     ToolBar toolbar = ToolBarBuilder.buildToolBar(GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
                     toolbar.setVisible(localFigure.getToolbarVisible());
                     component.setToolBar(toolbar);
                     parentWindow.addToolBar(toolbar);
+                    //force redraw to get good value on contentpane.getHeight
+                    parentWindow.validate();
+
+                    //apply stored delta to new axes size
+                    component.applyDeltaSize();
                 }
 
                 /* Update callback */
                 String closingCommand =
-                        "if (get_figure_handle(" + figureId + ") <> []) then"
-                                +      "  if (get(get_figure_handle(" + figureId + "), 'event_handler_enable') == 'on') then"
-                                +      "    execstr(get(get_figure_handle(" + figureId + "), 'event_handler')+'(" + figureId + ", -1, -1, -1000)', 'errcatch', 'm');"
-                                +      "  end;"
-                                +      "  delete(get_figure_handle(" + figureId + "));"
-                                +      "end;";
+                    "if (get_figure_handle(" + figureId + ") <> []) then"
+                    + "  if (get(get_figure_handle(" + figureId + "), 'event_handler_enable') == 'on') then"
+                    + "    execstr(get(get_figure_handle(" + figureId + "), 'event_handler')+'(" + figureId + ", -1, -1, -1000)', 'errcatch', 'm');"
+                    + "  end;"
+                    + "  delete(get_figure_handle(" + figureId + "));"
+                    + "end;";
                 component.setCallback(null);
                 component.setCallback(ScilabCloseCallBack.create(component.getId(), closingCommand));
                 /* Update menus callback */
                 Integer[] children = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_CHILDREN__);
                 updateChildrenCallbacks(children, figureId);
                 break;
-            case __GO_SIZE__ : {
+            case __GO_SIZE__: {
                 Integer[] size = (Integer[]) value;
                 SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
                 Size oldFigureSize = figure.getDims();
-                figure.setDims(new Size(size[0], size[1]));
-                int deltaFigureX = size[0] - oldFigureSize.getWidth();
-                int deltaFigureY = size[1] - oldFigureSize.getHeight();
-                if ( oldFigureSize.getWidth() != 0 && oldFigureSize.getHeight() != 0
-                        && ((oldFigureSize.getWidth() != size[0]) || (oldFigureSize.getHeight() != size[1]))
-                        && ((Boolean) GraphicController.getController().getProperty(component.getId(), __GO_AUTORESIZE__))
-                        ) {
-                    Integer[] axesSize = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_AXES_SIZE__);
-                    Integer[] newAxesSize = {axesSize[0] + deltaFigureX, axesSize[1] + deltaFigureY};
-                    GraphicController.getController().setProperty(component.getId(), __GO_AXES_SIZE__, newAxesSize);
+                if (oldFigureSize.getWidth() != 0 && oldFigureSize.getHeight() != 0 && ((oldFigureSize.getWidth() != size[0]) || (oldFigureSize.getHeight() != size[1]))
+                        && ((Boolean) GraphicController.getController().getProperty(component.getId(), __GO_AUTORESIZE__))) {
+                    figure.setDims(new Size(size[0], size[1]));
                 }
                 break;
             }
-            case __GO_POSITION__ :
+            case __GO_POSITION__:
                 Integer[] position = (Integer[]) value;
                 SwingScilabWindow.allScilabWindows.get(component.getParentWindowId()).setPosition(new Position(position[0], position[1]));
                 break;
-            case __GO_AXES_SIZE__ :
+            case __GO_AXES_SIZE__:
                 Integer[] axesSize = (Integer[]) value;
                 Dimension oldAxesSize = component.getContentPane().getSize();
-                if ( oldAxesSize.getWidth() != 0 && oldAxesSize.getHeight() != 0
-                        && ((oldAxesSize.getWidth() != axesSize[0]) || (oldAxesSize.getHeight() != axesSize[1]))
-                        && ((Boolean) GraphicController.getController().getProperty(component.getId(), __GO_AUTORESIZE__))
-                        ) {
+                if (oldAxesSize.getWidth() != 0 && oldAxesSize.getHeight() != 0 && ((oldAxesSize.getWidth() != axesSize[0]) || (oldAxesSize.getHeight() != axesSize[1]))
+                        && ((Boolean) GraphicController.getController().getProperty(component.getId(), __GO_AUTORESIZE__))) {
                     // TODO manage tabs when there are docked (do not change the window size if more than one tab docked)
                     int deltaX = axesSize[0] - (int) oldAxesSize.getWidth();
                     int deltaY = axesSize[1] - (int) oldAxesSize.getHeight();
                     Size parentWindowSize = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId()).getDims();
-                    SwingScilabWindow.allScilabWindows.get(component.getParentWindowId()).setDims(
-                            new Size(parentWindowSize.getWidth() + deltaX, parentWindowSize.getHeight() + deltaY));
-                    Integer figureSize[] = {parentWindowSize.getWidth() + deltaX, parentWindowSize.getHeight() + deltaY};
-                    GraphicController.getController().setProperty(component.getId(), __GO_SIZE__, figureSize);
+                    SwingScilabWindow.allScilabWindows.get(component.getParentWindowId()).setDims(new Size(parentWindowSize.getWidth() + deltaX, parentWindowSize.getHeight() + deltaY));
                 }
                 break;
-            case __GO_INFO_MESSAGE__ :
+            case __GO_INFO_MESSAGE__:
                 if (component.getInfoBar() != null) {
                     component.getInfoBar().setText((String) value);
                 }
                 break;
-            case __GO_EVENTHANDLER_ENABLE__ :
+            case __GO_EVENTHANDLER_ENABLE__:
                 Boolean enabled = (Boolean) GraphicController.getController().getProperty(component.getId(), __GO_EVENTHANDLER_ENABLE__);
-                component. setEventHandlerEnabled(enabled);
+                component.setEventHandlerEnabled(enabled);
                 break;
-            case __GO_EVENTHANDLER_NAME__ :
+            case __GO_EVENTHANDLER_NAME__:
                 String eventHandlerName = (String) GraphicController.getController().getProperty(component.getId(), __GO_EVENTHANDLER_NAME__);
                 component.setEventHandler(eventHandlerName);
                 break;
-            case __GO_VISIBLE__ :
+            case __GO_VISIBLE__:
                 component.getContentPane().setVisible((Boolean) value);
                 if (component.getParentWindow().getNbDockedObjects() == 1) {
                     component.getParentWindow().setVisible((Boolean) value);
                 }
                 break;
-            case __GO_INFOBAR_VISIBLE__ :
+            case __GO_INFOBAR_VISIBLE__: {
+                Integer[] oldSize = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_AXES_SIZE__);
                 component.getInfoBar().setVisible((Boolean) value);
+                SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+                parentWindow.validate();
+                GraphicController.getController().setProperty(component.getId(), __GO_AXES_SIZE__, oldSize);
                 break;
-            case __GO_TOOLBAR_VISIBLE__ :
+            }
+            case __GO_TOOLBAR_VISIBLE__: {
+                Integer[] oldSize = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_AXES_SIZE__);
                 component.getToolBar().setVisible((Boolean) value);
+                SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+                parentWindow.validate();
+                GraphicController.getController().setProperty(component.getId(), __GO_AXES_SIZE__, oldSize);
                 break;
-            case __GO_MENUBAR_VISIBLE__ :
+            }
+            case __GO_MENUBAR_VISIBLE__: {
+                Integer[] oldSize = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_AXES_SIZE__);
                 component.getMenuBar().setVisible((Boolean) value);
+                SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+                parentWindow.validate();
+                GraphicController.getController().setProperty(component.getId(), __GO_AXES_SIZE__, oldSize);
                 break;
-            case __GO_RESIZE__ :
+            }
+            case __GO_RESIZE__:
                 component.getParentWindow().setResizable((Boolean) value);
                 break;
-            case __GO_LAYOUT__ :
+            case __GO_LAYOUT__:
                 LayoutType newLayout = LayoutType.intToEnum((Integer) value);
                 switch (newLayout) {
-                    case BORDER : {
+                    case BORDER: {
                         Integer[] padding = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_BORDER_OPT_PADDING__);
                         component.getWidgetPane().setLayout(new BorderLayout(padding[0], padding[1]));
                         component.getWidgetPane().setLayout(new BorderLayout());
+                        component.setHasLayout(true);
                         break;
                     }
-                    case GRIDBAG : {
+                    case GRIDBAG: {
                         component.getWidgetPane().setLayout(new GridBagLayout());
+                        component.setHasLayout(true);
                         break;
                     }
-                    case GRID : {
+                    case GRID: {
                         Integer[] padding = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_GRID_OPT_PADDING__);
                         Integer[] grid = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_GRID_OPT_GRID__);
-                        Integer[] localGrid = new Integer[] {0, 0};
+                        Integer[] localGrid = new Integer[] { 0, 0 };
                         localGrid[0] = grid[0];
                         localGrid[1] = grid[1];
 
@@ -217,16 +232,18 @@ public class SwingScilabCommonPanel {
                         }
 
                         component.getWidgetPane().setLayout(new GridLayout(localGrid[0], localGrid[1], padding[0], padding[1]));
+                        component.setHasLayout(true);
                         break;
                     }
-                    case NONE :
+                    case NONE:
                     default:
                         component.getWidgetPane().setLayout(null);
+                        component.setHasLayout(false);
                         break;
                 }
                 break;
-            case __GO_GRID_OPT_PADDING__ :
-            case __GO_GRID_OPT_GRID__ : {
+            case __GO_GRID_OPT_PADDING__:
+            case __GO_GRID_OPT_GRID__: {
                 Integer layout = (Integer) GraphicController.getController().getProperty(component.getId(), __GO_LAYOUT__);
                 LayoutType layoutType = LayoutType.intToEnum(layout);
 
@@ -237,7 +254,7 @@ public class SwingScilabCommonPanel {
                 Integer[] padding = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_GRID_OPT_PADDING__);
 
                 Integer[] grid = (Integer[]) GraphicController.getController().getProperty(component.getId(), __GO_GRID_OPT_GRID__);
-                Integer[] localGrid = new Integer[] {0, 0};
+                Integer[] localGrid = new Integer[] { 0, 0 };
                 localGrid[0] = grid[0];
                 localGrid[1] = grid[1];
 
@@ -248,7 +265,7 @@ public class SwingScilabCommonPanel {
                 component.getWidgetPane().setLayout(new GridLayout(localGrid[0], localGrid[1], padding[0], padding[1]));
                 break;
             }
-            case __GO_BORDER_OPT_PADDING__ : {
+            case __GO_BORDER_OPT_PADDING__: {
                 Integer layout = (Integer) GraphicController.getController().getProperty(component.getId(), __GO_LAYOUT__);
                 LayoutType layoutType = LayoutType.intToEnum(layout);
 
@@ -261,10 +278,10 @@ public class SwingScilabCommonPanel {
                 component.getWidgetPane().setLayout(new BorderLayout());
                 break;
             }
-            case __GO_UI_ICON__ : {
-                File file = new File((String)value);
+            case __GO_UI_ICON__: {
+                File file = new File((String) value);
                 if (file.exists() == false) {
-                    String filename = FindIconHelper.findImage((String)value);
+                    String filename = FindIconHelper.findImage((String) value);
                     file = new File(filename);
                 }
 
@@ -275,13 +292,13 @@ public class SwingScilabCommonPanel {
                 }
                 break;
             }
-            case __GO_COLORMAP__ : {
+            case __GO_COLORMAP__: {
                 // Force background
                 Figure figure = (Figure) GraphicController.getController().getObjectFromId(component.getId());
                 component.setFigureBackground(ColorFactory.createColor(figure.getColorMap(), figure.getBackground()));
                 break;
             }
-            case __GO_BACKGROUND__ : {
+            case __GO_BACKGROUND__: {
                 Figure figure = (Figure) GraphicController.getController().getObjectFromId(component.getId());
                 component.setFigureBackground(ColorFactory.createColor(figure.getColorMap(), (Integer) value));
                 break;
@@ -309,11 +326,7 @@ public class SwingScilabCommonPanel {
     private static void updateChildrenCallbacks(Integer[] children, int parentFigureId) {
         for (int kChild = 0; kChild < children.length; kChild++) {
             Integer childType = (Integer) GraphicController.getController().getProperty(children[kChild], __GO_TYPE__);
-            if (childType != null && (
-                    childType == __GO_UIMENU__
-                    || childType == __GO_UIPARENTMENU__
-                    || childType == __GO_UICHILDMENU__
-                    || childType == __GO_UICHECKEDMENU__)) {
+            if (childType != null && (childType == __GO_UIMENU__ || childType == __GO_UIPARENTMENU__ || childType == __GO_UICHILDMENU__ || childType == __GO_UICHECKEDMENU__)) {
                 String cb = (String) GraphicController.getController().getProperty(children[kChild], __GO_CALLBACK__);
                 SwingView.getFromId(children[kChild]).update(__GO_CALLBACK__, replaceFigureID(cb, parentFigureId));
                 Integer[] menuChildren = (Integer[]) GraphicController.getController().getProperty(children[kChild], __GO_CHILDREN__);
@@ -333,7 +346,8 @@ public class SwingScilabCommonPanel {
     }
 
     /**
-     * Add a SwingViewObject (from SwingView.java) to container and returns its index
+     * Add a SwingViewObject (from SwingView.java) to container and returns its
+     * index
      * @param member the member to add
      */
     protected static void addMember(SwingScilabPanel component, SwingViewObject member) {
@@ -381,10 +395,10 @@ public class SwingScilabCommonPanel {
 
             // Anchor
             switch (uicontrol.getGridBagAnchorAsEnum()) {
-                case LEFT :
+                case LEFT:
                     constraints.anchor = GridBagConstraints.EAST;
                     break;
-                case UPPER :
+                case UPPER:
                     constraints.anchor = GridBagConstraints.NORTH;
                     break;
                 case LOWER:
@@ -405,15 +419,15 @@ public class SwingScilabCommonPanel {
                 case UPPER_RIGHT:
                     constraints.anchor = GridBagConstraints.NORTHWEST;
                     break;
-                case CENTER :
-                default :
+                case CENTER:
+                default:
                     constraints.anchor = GridBagConstraints.CENTER;
                     break;
             }
 
             // Fill
             switch (uicontrol.getGridBagFillAsEnum()) {
-                case BOTH :
+                case BOTH:
                     constraints.fill = GridBagConstraints.BOTH;
                     break;
                 case HORIZONTAL:
@@ -430,9 +444,7 @@ public class SwingScilabCommonPanel {
 
             // Insets
             Double[] margins = uicontrol.getMargins();
-            constraints.insets = new Insets(
-                    margins[0].intValue(), margins[1].intValue(),
-                    margins[2].intValue(), margins[3].intValue());
+            constraints.insets = new Insets(margins[0].intValue(), margins[1].intValue(), margins[2].intValue(), margins[3].intValue());
 
             // Padding
             Integer[] padding = uicontrol.getGridBagPadding();
@@ -455,7 +467,7 @@ public class SwingScilabCommonPanel {
         }
     }
 
-    protected static void  removeMember(SwingScilabPanel component, SwingViewObject member) {
+    protected static void removeMember(SwingScilabPanel component, SwingViewObject member) {
         component.getWidgetPane().remove((Component) member);
     }
 }
index da63479..a72ecfe 100644 (file)
@@ -63,6 +63,7 @@ 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.SwingViewWidget;
 import org.scilab.modules.gui.bridge.canvas.SwingScilabCanvas;
 import org.scilab.modules.gui.bridge.checkbox.SwingScilabCheckBox;
 import org.scilab.modules.gui.bridge.console.SwingScilabConsole;
@@ -77,9 +78,10 @@ import org.scilab.modules.gui.bridge.popupmenu.SwingScilabPopupMenu;
 import org.scilab.modules.gui.bridge.pushbutton.SwingScilabPushButton;
 import org.scilab.modules.gui.bridge.radiobutton.SwingScilabRadioButton;
 import org.scilab.modules.gui.bridge.slider.SwingScilabScroll;
+import org.scilab.modules.gui.bridge.textbox.SwingScilabTextBox;
+import org.scilab.modules.gui.bridge.toolbar.SwingScilabToolBar;
 import org.scilab.modules.gui.bridge.tree.SwingScilabTree;
 import org.scilab.modules.gui.bridge.uidisplaytree.SwingScilabUiDisplayTree;
-import org.scilab.modules.gui.bridge.uiimage.SwingScilabUiImage;
 import org.scilab.modules.gui.bridge.uitable.SwingScilabUiTable;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
 import org.scilab.modules.gui.canvas.Canvas;
@@ -115,10 +117,11 @@ import org.scilab.modules.gui.utils.SciClosingAction;
 import org.scilab.modules.gui.utils.SciHelpOnComponentAction;
 import org.scilab.modules.gui.utils.SciUndockingAction;
 import org.scilab.modules.gui.utils.Size;
+import org.scilab.modules.gui.widget.Widget;
 
 /**
- * Swing implementation for Scilab tabs in GUIs
- * This implementation uses FlexDock package
+ * Swing implementation for Scilab tabs in GUIs This implementation uses
+ * FlexDock package
  * @author Bruno JOFRET
  * @author Vincent COUVERT
  * @author Marouane BEN JELLOUL
@@ -127,14 +130,13 @@ import org.scilab.modules.gui.utils.Size;
 
 public class SwingScilabDockablePanel extends View implements SimpleTab, FocusListener, KeyListener, SwingScilabPanel {
 
-
-
     private static final Image SCILAB_ICON = new ImageIcon(FindIconHelper.findIcon("scilab", "256x256")).getImage();
 
     private static final long serialVersionUID = 1L;
 
     private static final String UNDOCK = "undock";
     private static final String HELP = "help";
+    protected boolean hasLayout = false;
 
     private Integer id;
 
@@ -153,7 +155,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
 
     /** Contains the canvas and widgets */
     private JLayeredPane uiContentPane;
-    private JLayeredPane layerdPane;
+    private JLayeredPane layeredPane;
 
     /** Scroll the axes */
     private SwingScilabScrollPane scrolling;
@@ -169,6 +171,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     /** A reference to the canvas used for event handling management */
     private SwingScilabCanvas contentCanvas = null;
 
+    private Dimension deltaSize = null;
+
     /**
      * Constructor
      * @param name the name of the tab
@@ -188,7 +192,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
         scrolling = null;
 
         this.setVisible(true);
-        
+
         getTitlebar().addFocusListener(this);
         addFocusListener(this);
         setCallback(null);
@@ -197,7 +201,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     /**
-     * Create a graphic tab used to display a figure with 3D graphics and/or UIcontrols
+     * Create a graphic tab used to display a figure with 3D graphics and/or
+     * UIcontrols
      * @param name name of the tab
      * @param figureId id of the displayed figure
      */
@@ -220,7 +225,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
         //setContentPane(scrolling.getAsContainer());
 
         this.setVisible(true);
-        
+
         getTitlebar().addFocusListener(this);
         addFocusListener(this);
         setCallback(null);
@@ -273,30 +278,22 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
         //contentCanvas = canvas;
 
         editorEventHandler = new EditorEventListener(figure.getIdentifier());
-        //contentCanvas.addEventHandlerKeyListener(editorEventHandler);
-        //contentCanvas.addEventHandlerMouseListener(editorEventHandler);
-        //contentCanvas.addEventHandlerMouseMotionListener(editorEventHandler);
-
-        layerdPane = new JLayeredPane();
-        layerdPane.setLayout(null);
-        layerdPane.setBorder(null);
-        layerdPane.setOpaque(true);
-        
-        //layerdPane.add(canvas, JLayeredPane.FRAME_CONTENT_LAYER);
+
+        layeredPane = new JLayeredPane();
+        layeredPane.setLayout(null);
+        layeredPane.setBorder(null);
+        layeredPane.setOpaque(true);
+
         uiContentPane = new JLayeredPane();
         uiContentPane.setOpaque(false);
         uiContentPane.setLayout(null);
         uiContentPane.setBorder(null);
-        layerdPane.add(uiContentPane, JLayeredPane.DEFAULT_LAYER + 1, 0);
 
-        scrolling = new SwingScilabScrollPane(layerdPane, uiContentPane, figure);
-        //scrolling.setCanvas(canvas);
-
-        //contentCanvas.addKeyListener(this);
+        layeredPane.add(uiContentPane, JLayeredPane.DEFAULT_LAYER + 1, 0);
+        scrolling = new SwingScilabScrollPane(layeredPane, uiContentPane, figure);
 
         setContentPane(scrolling.getAsContainer());
-        //setContentPane(uiContentPane);
-        //canvas.setVisible(true);
+
         uiContentPane.setVisible(true);
 
         /* Manage figure_position property */
@@ -307,7 +304,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
             public void ancestorMoved(HierarchyEvent e) {
                 if (e.getChanged() instanceof SwingScilabWindow) {
                     Position parentPosition = SwingScilabWindow.allScilabWindows.get(parentWindowId).getPosition();
-                    Integer[] newPosition = new Integer[] {parentPosition.getX(), parentPosition.getY()};
+                    Integer[] newPosition = new Integer[] { parentPosition.getX(), parentPosition.getY() };
                     GraphicController.getController().setProperty(id, __GO_POSITION__, newPosition);
                 }
             }
@@ -322,28 +319,33 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
             public void componentResized(ComponentEvent arg0) {
 
                 /* Update the figure_size property */
-                Size parentSize =  SwingScilabWindow.allScilabWindows.get(parentWindowId).getDims();
-                Integer[] newSize = new Integer[] {parentSize.getWidth(), parentSize.getHeight()};
+                Size parentSize = SwingScilabWindow.allScilabWindows.get(parentWindowId).getDims();
+                Integer[] newSize = new Integer[] { parentSize.getWidth(), parentSize.getHeight() };
 
                 GraphicController.getController().setProperty(id, __GO_SIZE__, newSize);
 
-                Boolean autoreSize = (Boolean) GraphicController.getController().getProperty(id, __GO_AUTORESIZE__);
+                Boolean autoResize = (Boolean) GraphicController.getController().getProperty(id, __GO_AUTORESIZE__);
 
-                if (autoreSize != null && autoreSize) {
+                if (autoResize != null && autoResize) {
                     /* Update the axes_size property */
-                    Integer[] newAxesSize = new Integer[] {getContentPane().getWidth(), getContentPane().getHeight()};
+                    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
+                    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);
+                } else if (hasLayout == false) {
+                    for (Component comp : getWidgetPane().getComponents()) {
+                        if (comp instanceof Widget) {
+                            Widget widget = (Widget) comp;
+                            SwingViewObject obj = (SwingViewObject) comp;
+                            SwingViewWidget.update(widget, __GO_POSITION__, GraphicController.getController().getProperty(obj.getId(), __GO_POSITION__));
+                        }
+                    }
                 }
-
             }
 
             public void componentMoved(ComponentEvent arg0) {
@@ -404,7 +406,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     /**
      * Call when the tab restoration is ended.
      */
-    public void endedRestoration() { }
+    public void endedRestoration() {
+    }
 
     /**
      * @return the window icon associated with this tab
@@ -435,7 +438,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
      * @param e the FocusEvent
      */
     @Override
-    public void focusLost(FocusEvent e) { }
+    public void focusLost(FocusEvent e) {
+    }
 
     /**
      * {@inheritDoc}
@@ -624,7 +628,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     /**
-     * Add a SwingViewObject (from SwingView.java) to container and returns its index
+     * Add a SwingViewObject (from SwingView.java) to container and returns its
+     * index
      * @param member the member to add
      */
     public void addMember(SwingViewObject member) {
@@ -635,10 +640,10 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
                 contentCanvas.addEventHandlerMouseListener(editorEventHandler);
                 contentCanvas.addEventHandlerMouseMotionListener(editorEventHandler);
 
-                layerdPane.add(contentCanvas, JLayeredPane.FRAME_CONTENT_LAYER);
+                layeredPane.add(contentCanvas, JLayeredPane.FRAME_CONTENT_LAYER);
 
                 scrolling.setCanvas(contentCanvas);
-                
+
                 contentCanvas.addKeyListener(this);
             }
             return;
@@ -931,22 +936,6 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
      * @param member the member to add
      * @return index of member in ArrayList
      */
-    private int addMember(SwingScilabUiImage member) {
-        return 0;
-    }
-
-    /**
-     * Remove a Image from its container
-     * @param member the Image to remove
-     */
-    private void removeMember(SwingScilabUiImage member) {
-    }
-
-    /**
-     * Add a member (dockable element) to container and returns its index
-     * @param member the member to add
-     * @return index of member in ArrayList
-     */
     public int addMember(UiDisplayTree member) {
         return this.addMember((SwingScilabUiDisplayTree) member.getAsSimpleUiDisplayTree());
     }
@@ -1330,11 +1319,12 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     /**
-     * Specify a new viewport for the axes
-     * For SwingScilabCanvas viewport can not be modified
-     * since it match the parent tab size
-     * @param posX X coordinate of upper left point of the viewport within the axes
-     * @param posY Y coordinate of upper left point of the viewport within the axes
+     * Specify a new viewport for the axes For SwingScilabCanvas viewport can
+     * not be modified since it match the parent tab size
+     * @param posX X coordinate of upper left point of the viewport within the
+     * axes
+     * @param posY Y coordinate of upper left point of the viewport within the
+     * axes
      * @param width width of the viewport
      * @param height height of the viewport
      */
@@ -1376,8 +1366,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     /**
-     * Specify whether the canvas should fit the parent tab size
-     * (and consequently the scrollpane size) or not
+     * Specify whether the canvas should fit the parent tab size (and
+     * consequently the scrollpane size) or not
      * @param onOrOff true to enable autoresize mode
      */
     @Override
@@ -1434,14 +1424,14 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     public void setFigureBackground(Color color) {
-        if (layerdPane != null) {
-            layerdPane.setBackground(color);
+        if (layeredPane != null) {
+            layeredPane.setBackground(color);
         }
     }
-    
+
     /**
      * Redefine paint children to be sure that AWT components are well painted.
-     *  @param g a Graphics
+     * @param g a Graphics
      */
     @Override
     public void paintChildren(Graphics g) {
@@ -1462,7 +1452,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
      * Update the tab after a modification of its properties
      * @param property the property name
      * @param value the property value
-     * @see org.scilab.modules.gui.SwingViewObject#update(java.lang.String, java.lang.Object)
+     * @see org.scilab.modules.gui.SwingViewObject#update(java.lang.String,
+     * java.lang.Object)
      */
     public void update(int property, Object value) {
         SwingScilabCommonPanel.update(this, property, value);
@@ -1516,7 +1507,8 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     }
 
     public void keyTyped(KeyEvent e) {
-        if (ScilabConstants.isGUI() && (eventHandler == null || !eventEnabled) && !GlobalEventWatcher.isActivated() && !editorEventHandler.isDatatipEnable() && Character.isLetterOrDigit(e.getKeyChar())) {
+        if (ScilabConstants.isGUI() && (eventHandler == null || !eventEnabled) && !GlobalEventWatcher.isActivated() && !editorEventHandler.isDatatipEnable()
+                && Character.isLetterOrDigit(e.getKeyChar())) {
             SwingScilabConsole console = (SwingScilabConsole) ScilabConsole.getConsole().getAsSimpleConsole();
             JTextPane input = (JTextPane) console.getConfiguration().getInputCommandView();
             input.requestFocus();
@@ -1529,4 +1521,28 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
     public JLayeredPane getWidgetPane() {
         return uiContentPane;
     }
+
+    public void setHasLayout(boolean hasLayout) {
+        this.hasLayout = hasLayout;
+    }
+
+    public void applyDeltaSize() {
+        if (deltaSize != null) {
+            if (deltaSize.getWidth() != 0 || deltaSize.getHeight() != 0) {
+                //update view and update model ( from componentResize of Window )
+                SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
+                Dimension oldAxesSize = getContentPane().getSize();
+                figure.setDims(new Size((int)(oldAxesSize.getWidth() + deltaSize.getWidth()), (int)(oldAxesSize.getHeight() + deltaSize.getHeight())));
+            }
+
+            deltaSize = null;
+        }
+    }
+
+    public void storeSizeDelta() {
+        Dimension axesSize = getContentPane().getSize();
+        SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
+        Size figureSize = figure.getDims();
+        deltaSize = new Dimension((int)(figureSize.getWidth() - axesSize.getWidth()), (int)(figureSize.getHeight() - axesSize.getHeight()));
+    }
 }
index d75dc87..e456016 100644 (file)
@@ -25,35 +25,39 @@ import org.scilab.modules.gui.textbox.TextBox;
 import org.scilab.modules.gui.toolbar.ToolBar;
 
 public interface SwingScilabPanel extends SwingViewObject {
-    
+
     public TextBox getInfoBar();
     public void setInfoBar(TextBox infoBar);
     public MenuBar getMenuBar();
     public void setMenuBar(MenuBar menuBar);
     public ToolBar getToolBar();
     public void setToolBar(ToolBar toolBar);
-    
+
     public void setName(String name);
     public void setEventHandler(String name);
     public void setEventHandlerEnabled(boolean enabled);
-    
+
     public void setParentWindowId(String parentWindowId);
     public String getParentWindowId();
-    
+
     public SwingScilabWindow getParentWindow();
     public Container getContentPane();
     public JLayeredPane getWidgetPane();
-    
+
     public void setVisible(boolean isVisible);
     public void setWindowIcon(String windowIcon);
-    
+
     public void addMember(SwingViewObject member);
     public void removeMember(SwingViewObject member);
-    
+
     public void revalidate();
-    
+
     public void setCallback(CommonCallBack callback);
-    
+
     public void close();
     public void setFigureBackground(Color color);
+    public void setHasLayout(boolean hasLayout);
+
+    public void applyDeltaSize();
+    public void storeSizeDelta();
 }
index d669b4f..51abd18 100644 (file)
@@ -14,10 +14,13 @@ package org.scilab.modules.gui.bridge.tab;
 
 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_POSITION__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SIZE__;
 
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Container;
+import java.awt.Dimension;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 
@@ -29,6 +32,7 @@ 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.SwingViewWidget;
 import org.scilab.modules.gui.bridge.canvas.SwingScilabCanvas;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
 import org.scilab.modules.gui.events.callback.CommonCallBack;
@@ -36,36 +40,36 @@ import org.scilab.modules.gui.menubar.MenuBar;
 import org.scilab.modules.gui.textbox.TextBox;
 import org.scilab.modules.gui.toolbar.ToolBar;
 import org.scilab.modules.gui.utils.Size;
+import org.scilab.modules.gui.widget.Widget;
 
 public class SwingScilabStaticPanel extends SwingScilabScrollPane implements SwingScilabPanel {
-
+    private static final long serialVersionUID = -3887923938827929317L;
     private Integer id;
     private TextBox infoBar;
     private MenuBar menuBar;
     private ToolBar toolBar;
-    private String eventHandler;
-    private boolean eventHandlerEnabled;
     private String parentWindowId;
-    private String windowIcon;
-
     private JLayeredPane uiContentPane;
-    private JLayeredPane layerdPane;
+    private JLayeredPane layeredPane;
 
     private SwingScilabCanvas contentCanvas;
+    protected boolean hasLayout;
+    private Dimension deltaSize = null;
 
     public SwingScilabStaticPanel(String figureTitle, Integer figureId, Figure figure) {
         super(new JLayeredPane(), new JLayeredPane(), figure);
         uiContentPane = (JLayeredPane) getUIComponent();
-        layerdPane = (JLayeredPane) getGlobalComponent();
+        layeredPane = (JLayeredPane) getGlobalComponent();
         setVisible(true);
-        layerdPane.setLayout(null);
-        layerdPane.setOpaque(true);
+        layeredPane.setLayout(null);
+        layeredPane.setOpaque(true);
+        setHasLayout(false);
 
         uiContentPane.setOpaque(false);
         uiContentPane.setLayout(null);
-        layerdPane.add(uiContentPane, JLayeredPane.DEFAULT_LAYER + 1, 0);
+        layeredPane.add(uiContentPane, JLayeredPane.DEFAULT_LAYER + 1, 0);
 
-        layerdPane.setVisible(true);
+        layeredPane.setVisible(true);
         uiContentPane.setVisible(true);
 
         /* Manage figure_size property */
@@ -97,6 +101,14 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
                                            + resizeFcn
                                            + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
                     InterpreterManagement.requestScilabExec(resizeCommand);
+                } else if (hasLayout == false) {
+                    for (Component comp : getWidgetPane().getComponents()) {
+                        if (comp instanceof Widget) {
+                            Widget widget = (Widget) comp;
+                            SwingViewObject obj = (SwingViewObject) comp;
+                            SwingViewWidget.update(widget, __GO_POSITION__, GraphicController.getController().getProperty(obj.getId(), __GO_POSITION__));
+                        }
+                    }
                 }
             }
 
@@ -121,11 +133,11 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
     }
 
     public void setFigureBackground(Color color) {
-        if (layerdPane != null) {
-            layerdPane.setBackground(color);
+        if (layeredPane != null) {
+            layeredPane.setBackground(color);
         }
     }
-    
+
     public TextBox getInfoBar() {
         return infoBar;
     }
@@ -151,11 +163,9 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
     }
 
     public void setEventHandler(String eventHandler) {
-        this.eventHandler = eventHandler;
     }
 
     public void setEventHandlerEnabled(boolean enabled) {
-        this.eventHandlerEnabled = enabled;
     }
 
     public void setParentWindowId(String parentWindowId) {
@@ -163,21 +173,14 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
     }
 
     public void setWindowIcon(String windowIcon) {
-        this.windowIcon = windowIcon;
     }
 
     public void addMember(SwingViewObject member) {
         if (member instanceof SwingScilabAxes) {
             if (contentCanvas == null) {
                 contentCanvas = new SwingScilabCanvas((Figure) GraphicController.getController().getObjectFromId(((SwingScilabAxes) member).getFigureId()));
-                //contentCanvas.addEventHandlerKeyListener(editorEventHandler);
-                //contentCanvas.addEventHandlerMouseListener(editorEventHandler);
-                //contentCanvas.addEventHandlerMouseMotionListener(editorEventHandler);
-                layerdPane.add(contentCanvas, JLayeredPane.FRAME_CONTENT_LAYER);
-
+                layeredPane.add(contentCanvas, JLayeredPane.FRAME_CONTENT_LAYER);
                 setCanvas(contentCanvas);
-
-                //contentCanvas.addKeyListener(this);
             }
             return;
         }
@@ -231,4 +234,28 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
         super.setName(name);
         getParentWindow().setName(name);
     }
+
+    public void setHasLayout(boolean hasLayout) {
+        this.hasLayout = hasLayout;
+    }
+
+    public void applyDeltaSize() {
+        if (deltaSize != null) {
+            if (deltaSize.getWidth() != 0 || deltaSize.getHeight() != 0) {
+                //update view and update model ( from componentResize of Window )
+                SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
+                Size oldFigureSize = figure.getDims();
+                figure.setDims(new Size((int)(oldFigureSize.getWidth() + deltaSize.getWidth()), (int)(oldFigureSize.getHeight() + deltaSize.getHeight())));
+            }
+
+            deltaSize = null;
+        }
+    }
+
+    public void storeSizeDelta() {
+        Dimension axesSize = getContentPane().getSize();
+        SwingScilabWindow figure = SwingScilabWindow.allScilabWindows.get(getParentWindowId());
+        Size figureSize = figure.getDims();
+        deltaSize = new Dimension((int)(figureSize.getWidth() - axesSize.getWidth()), (int)(figureSize.getHeight() - axesSize.getHeight()));
+    }
 }
index 69f970c..32ef8b9 100644 (file)
@@ -347,11 +347,9 @@ public abstract class SwingScilabWindow extends JFrame implements SimpleWindow {
      */
     @Override
     public void setPosition(Position newWindowPosition) {
-        //if (!SwingUtilities.isEventDispatchThread()) {
         if (getPosition().getX() != newWindowPosition.getX() || getPosition().getY() != newWindowPosition.getY()) {
             this.setLocation(newWindowPosition.getX(), newWindowPosition.getY());
         }
-        //}
     }
 
     /**
index ffb6a71..06e8493 100644 (file)
@@ -17,11 +17,9 @@ import java.awt.Dimension;
 import java.awt.LayoutManager;
 import java.io.Serializable;
 
-import org.scilab.modules.action_binding.InterpreterManagement;
 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;
 
 /**
  * @author Pierre Lando
@@ -60,13 +58,10 @@ public class PanelLayout implements LayoutManager, Serializable {
             if (child.equals(canvas)) {
                 canvas.setBounds(0, 0, parent.getWidth(), parent.getHeight());
                 parent.setComponentZOrder(child, parent.getComponentCount() - 1);
-            }
-
-            /* Here you can perform the layout of UI object. */
-            if (child instanceof SwingViewObject) {
+            } else if (child instanceof SwingViewObject) {
+                /* Here you can perform the layout of UI object. */
                 Integer id = ((SwingViewObject) child).getId();
-                ((SwingViewObject) child).update(GraphicObjectProperties.__GO_POSITION__,
-                                                 GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_POSITION__));
+                ((SwingViewObject) child).update(GraphicObjectProperties.__GO_POSITION__, GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_POSITION__));
             }
         }
     }