Frame can have Axes child 01/13701/3
Bruno JOFRET [Mon, 10 Feb 2014 17:47:28 +0000 (18:47 +0100)]
Change-Id: I8b6528faf9c9e44c369f8fb7020cb802bcaf5702

15 files changed:
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/axes/AxesContainer.java [new file with mode: 0644]
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/builder/Builder.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/figure/Figure.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObject.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/Visitor.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/uicontrol/frame/Frame.java
scilab/modules/graphics/sci_gateway/c/sci_newaxes.c
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingView.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/canvas/SwingScilabCanvas.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/frame/SwingScilabFrame.java
scilab/modules/gui/tests/unit_tests/frameWithAxes.dia.ref [new file with mode: 0644]
scilab/modules/gui/tests/unit_tests/frameWithAxes.tst [new file with mode: 0644]
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/axes/ruler/AxesRulerSpriteFactory.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/JoGLCanvas.java

diff --git a/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/axes/AxesContainer.java b/scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/axes/AxesContainer.java
new file mode 100644 (file)
index 0000000..2c36042
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab enterprises - Bruno JOFRET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.modules.graphic_objects.axes;
+
+import org.scilab.modules.graphic_objects.figure.ColorMap;
+import org.scilab.modules.graphic_objects.graphicObject.Visitor;
+
+public interface AxesContainer {
+    
+    public Integer getIdentifier();
+    public void accept(Visitor visitor);
+    public Integer getAntialiasing();
+    public Integer[] getAxesSize();
+    public Integer[] getChildren();
+    
+    public Integer getBackground();
+    public ColorMap getColorMap();
+}
index 6a59d68..1988499 100644 (file)
@@ -370,11 +370,11 @@ public final class Builder {
     }
 
     public final static int createSubWin(int parentFigure) {
-        GraphicController controller = GraphicController.getController();
-        GraphicObject parent = controller.getObjectFromId(parentFigure);
-        if (parent.getType() != GraphicObjectProperties.__GO_FIGURE__) {
-            return 0;
-        }
+        //GraphicController controller = GraphicController.getController();
+        //GraphicObject parent = controller.getObjectFromId(parentFigure);
+        //if (parent.getType() != GraphicObjectProperties.__GO_FIGURE__) {
+        //    return 0;
+        //}
 
         return cloneAxesModel(parentFigure);
     }
index 9f1b4fc..39fa574 100644 (file)
@@ -48,6 +48,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 
 import java.util.Arrays;
 
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
 import org.scilab.modules.graphic_objects.graphicObject.Visitor;
@@ -56,7 +57,7 @@ import org.scilab.modules.graphic_objects.utils.LayoutType;
  * Figure class
  * @author Manuel JULIACHS
  */
-public class Figure extends GraphicObject {
+public class Figure extends GraphicObject implements AxesContainer {
     /** Figure properties names */
     private enum FigureProperty {
         INFOMESSAGE, COLORMAP, COLORMAPSIZE, BACKGROUND, ROTATIONTYPE,
index 3b056ec..a0d562a 100644 (file)
 
 package org.scilab.modules.graphic_objects.graphicObject;
 
-import org.scilab.modules.graphic_objects.ObjectRemovedException;
-import org.scilab.modules.graphic_objects.axes.Axes;
-import org.scilab.modules.graphic_objects.figure.Figure;
-import org.scilab.modules.graphic_objects.graphicController.GraphicController;
-import org.scilab.modules.graphic_objects.legend.Legend;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_ARC__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXESMODEL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXIS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACKTYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHAMP__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN_COUNT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_COMPOUND__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATATIP__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DATA_MODEL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FAC3D__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FEC__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGUREMODEL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRAYPLOT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_HAS_LEGEND_CHILD__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_HIDDEN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LABEL__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LEGEND_CHILD__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LEGEND__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LIGHT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MATPLOT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT_AXES__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT_FIGURE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PARENT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PLOT3D__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POLYLINE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_PROGRESSIONBAR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_RECTANGLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_REFERENCED__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SEGS__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SELECTED_CHILD__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TEXT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UICONTEXTMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_EDIT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_SCROLLABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LAYER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_LISTBOX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_POPUPMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_RADIOBUTTON__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SLIDER__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TABLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_USER_DATA_SIZE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_USER_DATA__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VALID__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_WAITBAR__;
 
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.*;
+import org.scilab.modules.graphic_objects.ObjectRemovedException;
+import org.scilab.modules.graphic_objects.axes.Axes;
+import org.scilab.modules.graphic_objects.figure.Figure;
+import org.scilab.modules.graphic_objects.graphicController.GraphicController;
+import org.scilab.modules.graphic_objects.legend.Legend;
 
 /**
  * GraphicObject class
index 3c6d505..ad202da 100644 (file)
@@ -16,6 +16,7 @@ import org.scilab.modules.graphic_objects.arc.Arc;
 import org.scilab.modules.graphic_objects.axes.Axes;
 import org.scilab.modules.graphic_objects.axis.Axis;
 import org.scilab.modules.graphic_objects.compound.Compound;
+import org.scilab.modules.graphic_objects.datatip.Datatip;
 import org.scilab.modules.graphic_objects.fec.Fec;
 import org.scilab.modules.graphic_objects.figure.Figure;
 import org.scilab.modules.graphic_objects.imageplot.Grayplot;
@@ -27,10 +28,10 @@ import org.scilab.modules.graphic_objects.rectangle.Rectangle;
 import org.scilab.modules.graphic_objects.surface.Fac3d;
 import org.scilab.modules.graphic_objects.surface.Plot3d;
 import org.scilab.modules.graphic_objects.textObject.Text;
+import org.scilab.modules.graphic_objects.uicontrol.frame.Frame;
 import org.scilab.modules.graphic_objects.vectfield.Arrow;
 import org.scilab.modules.graphic_objects.vectfield.Champ;
 import org.scilab.modules.graphic_objects.vectfield.Segs;
-import org.scilab.modules.graphic_objects.datatip.Datatip;
 
 /**
  * @author Pierre Lando
@@ -48,6 +49,8 @@ public interface Visitor {
     void visit(Fec fec) throws ObjectRemovedException;
 
     void visit(Figure figure);
+    
+    void visit(Frame frame);
 
     void visit(Grayplot grayplot) throws ObjectRemovedException;
 
index 74b8b9a..f6634a0 100644 (file)
@@ -17,13 +17,18 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import javax.swing.UIDefaults;
 import javax.swing.UIManager;
 
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.console.Console;
+import org.scilab.modules.graphic_objects.figure.ColorMap;
+import org.scilab.modules.graphic_objects.figure.Figure;
+import org.scilab.modules.graphic_objects.graphicModel.GraphicModel;
+import org.scilab.modules.graphic_objects.graphicObject.Visitor;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
 
 /**
  * @author Vincent COUVERT
  */
-public class Frame extends Uicontrol {
+public class Frame extends Uicontrol implements AxesContainer {
 
     /**
      * Constructor
@@ -46,4 +51,35 @@ public class Frame extends Uicontrol {
             setVerticalAlignment("middle");
         }
     }
+
+    public void accept(Visitor visitor) {
+        visitor.visit(this);
+    }
+
+    public Integer getAntialiasing() {
+        return 0;
+    }
+
+    public Integer getBackground() {
+        Figure figure = (Figure) GraphicModel.getModel().getObjectFromId(getParentFigure());
+        if (figure != null) {
+            return figure.getBackground();
+        }
+        return -2;
+    }
+
+    public ColorMap getColorMap() {
+        Figure figure = (Figure) GraphicModel.getModel().getObjectFromId(getParentFigure());
+        if (figure != null) {
+            return figure.getColorMap();
+        }
+
+        return new ColorMap();
+    }
+
+    public Integer[] getAxesSize() {
+        Double[] pos = getUiPosition();
+        return new Integer[] {pos[2].intValue(), pos[3].intValue()};
+    }
+
 }
index 7cdd9b5..45deaa8 100644 (file)
@@ -31,6 +31,8 @@
 #include "CurrentSubwin.h"
 #include "CurrentObject.h"
 #include "createGraphicObject.h"
+#include "graphicObjectProperties.h"
+#include "getGraphicObjectProperty.h"
 
 /*--------------------------------------------------------------------------*/
 int sci_newaxes(char * fname, unsigned long fname_len)
@@ -40,27 +42,100 @@ int sci_newaxes(char * fname, unsigned long fname_len)
     long long* outindex = NULL;
 
     int iSubwinUID = 0;
-    CheckInputArgument(pvApiCtx, 0, 0);
-    CheckOutputArgument(pvApiCtx, 0, 1);
+    long long hParent = 0;
+    int iParentUID = -1;
+    int iParentType = -1;
+    int *piParentType = &iParentType;
+    int iParentStyle = -1;
+    int *piParentStyle = &iParentStyle;
+
 
-    getOrCreateDefaultSubwin();
+    CheckInputArgument(pvApiCtx, 0, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
 
-    if ((iSubwinUID = createSubWin (getCurrentFigure())) != 0)
+    if (nbInputArgument(pvApiCtx) == 0)
     {
-        if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, getHandle(iSubwinUID)))
+        getOrCreateDefaultSubwin();
+
+        if ((iSubwinUID = createSubWin (getCurrentFigure())) != 0)
         {
-            printError(&sciErr, 0);
-            Scierror(999, _("%s: Memory allocation error.\n"), fname);
-            return 1;
-        }
+            if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, getHandle(iSubwinUID)))
+            {
+                printError(&sciErr, 0);
+                Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                return 1;
+            }
 
-        AssignOutputVariable(pvApiCtx, 1) = 1;
-        ReturnArguments(pvApiCtx);
+            AssignOutputVariable(pvApiCtx, 1) = 1;
+            ReturnArguments(pvApiCtx);
+        }
+        else
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+        }
+        return 0;
     }
     else
     {
-        Scierror(999, _("%s: No more memory.\n"), fname);
+        // NbInput Argument == 1
+        int* piAddr = NULL;
+        int iType = 0;
+
+        sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+        if (sciErr.iErr)
+        {
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+            return 0;
+        }
+
+        if (isHandleType(pvApiCtx, piAddr) == FALSE || isScalar(pvApiCtx, piAddr) == FALSE)
+        {
+            Scierror(999, _("%s: Wrong size for input argument #%d: A graphic handle expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getScalarHandle(pvApiCtx, piAddr, &hParent))
+        {
+            Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1);
+            return 1;
+        }
+
+        iParentUID = getObjectFromHandle((long)hParent);
+        if (iParentUID != 0)
+        {
+            getGraphicObjectProperty(iParentUID, __GO_TYPE__, jni_int, (void **)&piParentType);
+            getGraphicObjectProperty(iParentUID, __GO_STYLE__, jni_int, (void **)&piParentStyle);
+            if (!(iParentType == __GO_FIGURE__ || iParentStyle == __GO_UI_FRAME__))
+            {
+                Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or '%s' handle expected.\n"), fname, 1, "Figure",
+                         "Frame");
+                return FALSE;
+            }
+
+            if ((iSubwinUID = createSubWin(iParentUID)) != 0)
+            {
+                if (createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, getHandle(iSubwinUID)))
+                {
+                    printError(&sciErr, 0);
+                    Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                    return 1;
+                }
+
+                AssignOutputVariable(pvApiCtx, 1) = 1;
+                ReturnArguments(pvApiCtx);
+            }
+            else
+            {
+                Scierror(999, _("%s: No more memory.\n"), fname);
+            }
+            return 0;
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A '%s' or '%s' handle expected.\n"), fname, 1, "Figure",
+                     "Frame");
+            return FALSE;
+        }
     }
-    return 0;
 }
 /*--------------------------------------------------------------------------*/
index 2712d1d..6b7de58 100644 (file)
@@ -330,7 +330,6 @@ public final class SwingView implements GraphicView {
                     @Override
                     public void run() {
                         newSVObject[0] = CreateObjectFromType(enumType, id);
-
                     }
                 });
             } catch (InterruptedException e) {
@@ -1027,7 +1026,7 @@ public final class SwingView implements GraphicView {
                 int childType = (Integer) GraphicController.getController().getProperty(childId, __GO_TYPE__);
 
                 /* Add an uicontrol */
-                if (childType == __GO_UICONTROL__) {
+                if (childType == __GO_UICONTROL__ || childType == __GO_AXES__) {
                     updatedComponent.addMember(allObjects.get(childId).getValue());
                     needRevalidate = true;
                 }
index c0f0272..7328776 100644 (file)
@@ -39,6 +39,7 @@ import javax.swing.JPanel;
 import org.scilab.forge.scirenderer.Canvas;
 import org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvas;
 import org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvasFactory;
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.figure.Figure;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.gui.SwingViewObject;
@@ -66,7 +67,7 @@ public class SwingScilabCanvas extends JPanel implements SimpleCanvas {
     private final Canvas rendererCanvas;
 
     /** The drawn figure */
-    private Figure figure;
+    private AxesContainer figure;
 
     /** The drawer visitor used to draw the figure */
     private DrawerVisitor drawerVisitor;
@@ -84,7 +85,7 @@ public class SwingScilabCanvas extends JPanel implements SimpleCanvas {
         }
     }
 
-    public SwingScilabCanvas(final Figure figure) {
+    public SwingScilabCanvas(final AxesContainer figure) {
         super(new PanelLayout());
         this.figure = figure;
 
@@ -147,7 +148,7 @@ public class SwingScilabCanvas extends JPanel implements SimpleCanvas {
      * figure getter.
      * @return the MVC figure.
      */
-    public Figure getFigure() {
+    public AxesContainer getFigure() {
         return figure;
     }
 
index 949fa93..af69f0d 100644 (file)
@@ -14,6 +14,7 @@
 package org.scilab.modules.gui.bridge.frame;
 
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CHILDREN__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ENABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
 
@@ -25,12 +26,16 @@ import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
 import java.awt.Insets;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
 
 import javax.swing.JPanel;
 import javax.swing.UIManager;
 
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.graphic_objects.graphicModel.GraphicModel;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
 import org.scilab.modules.gui.SwingView;
 import org.scilab.modules.gui.SwingViewObject;
@@ -44,6 +49,7 @@ import org.scilab.modules.gui.bridge.listbox.SwingScilabListBox;
 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.tab.SwingScilabAxes;
 import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel;
 import org.scilab.modules.gui.bridge.tab.SwingScilabTabGroup;
 import org.scilab.modules.gui.bridge.textbox.SwingScilabTextBox;
@@ -78,7 +84,7 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
 
     private static final long serialVersionUID = -7401084975837285447L;
 
-    private Integer uid;
+    private Integer uid = -1;
 
     /**
      * Constructor
@@ -87,6 +93,26 @@ 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);
+        addComponentListener(new ComponentListener() {
+            public void componentShown(ComponentEvent e) { }
+            
+            public void componentResized(ComponentEvent e) { 
+                if (getId() != -1) {
+                    Double[] newPosition = new Double[4];
+                    Double[] positions = (Double[]) GraphicController.getController().getProperty(getId(), GraphicObjectProperties.__GO_POSITION__);
+                    newPosition[0] = positions[0];
+                    newPosition[1] = positions[1];
+                    newPosition[2] = getSize().getWidth();
+                    newPosition[3] = getSize().getHeight();
+                    invalidate();
+                    GraphicController.getController().setProperty(getId(), GraphicObjectProperties.__GO_POSITION__, newPosition);
+                }
+            }
+            
+            public void componentMoved(ComponentEvent e) { }
+            
+            public void componentHidden(ComponentEvent e) { }
+        });
     }
 
     /**
@@ -140,6 +166,13 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
      * @param member the member to add
      */
     public void addMember(SwingViewObject member) {
+        if (member instanceof SwingScilabAxes) {
+            AxesContainer frame = (AxesContainer) GraphicModel.getModel().getObjectFromId(getId());
+            SwingScilabCanvas canvas = new SwingScilabCanvas(frame);
+            setLayout(new BorderLayout());
+            add(canvas, BorderLayout.CENTER);
+            return;
+        }
         Uicontrol uicontrol = (Uicontrol) GraphicModel.getModel().getObjectFromId(member.getId());
         if (getLayout() instanceof BorderLayout) {
             switch (uicontrol.getBorderPositionAsEnum()) {
@@ -721,6 +754,9 @@ public class SwingScilabFrame extends JPanel implements SwingViewObject, SimpleF
                     }
                 }
                 break;
+            case __GO_POSITION__:
+                revalidate();
+                doLayout();
             default :
                 break;
         }
diff --git a/scilab/modules/gui/tests/unit_tests/frameWithAxes.dia.ref b/scilab/modules/gui/tests/unit_tests/frameWithAxes.dia.ref
new file mode 100644 (file)
index 0000000..404c6a4
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+f = figure("layout", "gridbag", "default_axes", "off", "position", [0, 0, 800, 800]);
+for i = 1:2
+    for j = 1:2
+        frame = uicontrol(f, "style", "frame", ...
+                          "layout", "border", ...
+                          "constraints", createConstraints("gridbag", [i, j, 1, 1], [1,1], "both"));
+        newaxes(frame);
+        plot3d();
+    end
+end
+assert_checkequal(size(f.children, '*'), 4);
+for i = 1:4
+    assert_checkequal(f.children(i).type, "uicontrol");
+    assert_checkequal(f.children(i).style, "frame");
+    assert_checkequal(f.children(i).children(1).type, "Axes");
+    assert_checkequal(f.children(i).children(1).children(1).type, "Plot3d");
+    assert_checkequal(f.children(i).position(3:4), [400, 400]);
+end
diff --git a/scilab/modules/gui/tests/unit_tests/frameWithAxes.tst b/scilab/modules/gui/tests/unit_tests/frameWithAxes.tst
new file mode 100644 (file)
index 0000000..a83c942
--- /dev/null
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+f = figure("layout", "gridbag", "default_axes", "off", "position", [0, 0, 800, 800]);
+
+for i = 1:2
+    for j = 1:2
+        frame = uicontrol(f, "style", "frame", ...
+                          "layout", "border", ...
+                          "constraints", createConstraints("gridbag", [i, j, 1, 1], [1,1], "both"));
+        newaxes(frame);
+        plot3d();
+    end
+end
+
+assert_checkequal(size(f.children, '*'), 4);
+for i = 1:4
+    assert_checkequal(f.children(i).type, "uicontrol");
+    assert_checkequal(f.children(i).style, "frame");
+    assert_checkequal(f.children(i).children(1).type, "Axes");
+    assert_checkequal(f.children(i).children(1).children(1).type, "Plot3d");
+    assert_checkequal(f.children(i).position(3:4), [400, 400]);
+end
index 8259c63..16997ad 100755 (executable)
 
 package org.scilab.modules.renderer.JoGLView;
 
+import java.awt.Component;
+import java.awt.Dimension;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.SwingUtilities;
+
 import org.scilab.forge.scirenderer.Canvas;
 import org.scilab.forge.scirenderer.Drawer;
 import org.scilab.forge.scirenderer.DrawingTools;
@@ -19,20 +33,22 @@ import org.scilab.forge.scirenderer.buffers.ElementsBuffer;
 import org.scilab.forge.scirenderer.shapes.appearance.Appearance;
 import org.scilab.forge.scirenderer.shapes.geometry.DefaultGeometry;
 import org.scilab.forge.scirenderer.shapes.geometry.Geometry;
-import org.scilab.forge.scirenderer.texture.AnchorPosition;
 import org.scilab.forge.scirenderer.texture.AbstractTextureDataProvider;
+import org.scilab.forge.scirenderer.texture.AnchorPosition;
 import org.scilab.forge.scirenderer.texture.Texture;
-import org.scilab.forge.scirenderer.tranformations.Vector3d;
 import org.scilab.forge.scirenderer.tranformations.Transformation;
 import org.scilab.forge.scirenderer.tranformations.TransformationFactory;
 import org.scilab.forge.scirenderer.tranformations.TransformationStack;
+import org.scilab.forge.scirenderer.tranformations.Vector3d;
 import org.scilab.forge.scirenderer.utils.shapes.geometry.CubeFactory;
 import org.scilab.modules.graphic_objects.ObjectRemovedException;
 import org.scilab.modules.graphic_objects.arc.Arc;
 import org.scilab.modules.graphic_objects.axes.Axes;
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.axes.Camera.ViewType;
 import org.scilab.modules.graphic_objects.axis.Axis;
 import org.scilab.modules.graphic_objects.compound.Compound;
+import org.scilab.modules.graphic_objects.datatip.Datatip;
 import org.scilab.modules.graphic_objects.fec.Fec;
 import org.scilab.modules.graphic_objects.figure.ColorMap;
 import org.scilab.modules.graphic_objects.figure.Figure;
@@ -50,13 +66,14 @@ import org.scilab.modules.graphic_objects.rectangle.Rectangle;
 import org.scilab.modules.graphic_objects.surface.Fac3d;
 import org.scilab.modules.graphic_objects.surface.Plot3d;
 import org.scilab.modules.graphic_objects.textObject.Text;
+import org.scilab.modules.graphic_objects.uicontrol.frame.Frame;
 import org.scilab.modules.graphic_objects.vectfield.Arrow;
 import org.scilab.modules.graphic_objects.vectfield.Champ;
 import org.scilab.modules.graphic_objects.vectfield.Segs;
-import org.scilab.modules.graphic_objects.datatip.Datatip;
 import org.scilab.modules.renderer.JoGLView.arrowDrawing.ArrowDrawer;
 import org.scilab.modules.renderer.JoGLView.axes.AxesDrawer;
 import org.scilab.modules.renderer.JoGLView.contouredObject.ContouredObjectDrawer;
+import org.scilab.modules.renderer.JoGLView.datatip.DatatipTextDrawer;
 import org.scilab.modules.renderer.JoGLView.interaction.InteractionManager;
 import org.scilab.modules.renderer.JoGLView.label.LabelManager;
 import org.scilab.modules.renderer.JoGLView.legend.LegendDrawer;
@@ -64,24 +81,9 @@ import org.scilab.modules.renderer.JoGLView.mark.MarkSpriteManager;
 import org.scilab.modules.renderer.JoGLView.postRendering.PostRendered;
 import org.scilab.modules.renderer.JoGLView.text.TextManager;
 import org.scilab.modules.renderer.JoGLView.util.ColorFactory;
+import org.scilab.modules.renderer.JoGLView.util.LightingUtils;
 import org.scilab.modules.renderer.JoGLView.util.OutOfMemoryException;
 import org.scilab.modules.renderer.utils.textRendering.FontManager;
-import org.scilab.modules.renderer.JoGLView.datatip.DatatipTextDrawer;
-import org.scilab.modules.renderer.JoGLView.util.LightingUtils;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.SwingUtilities;
 
 /**
  * @author Pierre Lando
@@ -120,7 +122,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     private static final boolean DEBUG_MODE = false;
 
     private final Component component;
-    private final Figure figure;
+    private final AxesContainer figure;
     private final InteractionManager interactionManager;
 
     private final ColorMapTextureDataProvider colorMapTextureDataProvider;
@@ -155,7 +157,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     private final List<PostRendered> postRenderedList = new LinkedList<PostRendered>();
     private final static Map<Integer, List<Integer>> openGLChildren = new HashMap<Integer, List<Integer>>();
 
-    public DrawerVisitor(Component component, Canvas canvas, Figure figure) {
+    public DrawerVisitor(Component component, Canvas canvas, AxesContainer figure) {
         GraphicController.getController().register(this);
 
         this.component = component;
@@ -187,7 +189,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         visitorMap.put(figure.getIdentifier(), this);
     }
 
-    public static void changeVisitor(Figure figure, DrawerVisitor visitor) {
+    public static void changeVisitor(AxesContainer figure, DrawerVisitor visitor) {
         if (visitor == null) {
             visitorMap.remove(figure.getIdentifier());
         } else {
@@ -403,6 +405,22 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
             }
         }
     }
+    
+    public void visit(Frame frame) {
+        synchronized (frame) {
+            /** Set the current {@see ColorMap}. */
+            try {
+                colorMap = frame.getColorMap();
+                drawingTools.clear(ColorFactory.createColor(colorMap, frame.getBackground()));
+                drawingTools.clearDepthBuffer();
+                if (frame.isValid() && frame.getVisible()) {
+                    askAcceptVisitor(frame.getChildren());
+                }
+            } catch (Exception e) {
+                System.err.println(e);
+            }
+        }
+    }
 
     @Override
     public void visit(final Grayplot grayplot) {
@@ -907,12 +925,15 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
          * Check if property is CHILDREN and if there is a new child I should care about
          */
         Integer type = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
-        if (id != figure.getIdentifier() &&  (type == GraphicObjectProperties.__GO_UICONTROL__ || type == GraphicObjectProperties.__GO_UIMENU__)) {
+        int objectStyle = (type == GraphicObjectProperties.__GO_UICONTROL__ ? (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_STYLE__) : -1);
+        if (id.intValue() != figure.getIdentifier().intValue() 
+                && ((type == GraphicObjectProperties.__GO_UICONTROL__ && objectStyle != GraphicObjectProperties.__GO_UI_FRAME__)
+                        || type == GraphicObjectProperties.__GO_UIMENU__)) {
             return;
         }
 
         if (property == GraphicObjectProperties.__GO_CHILDREN__) {
-            if (id != figure.getIdentifier()) {
+            if (id.intValue() != figure.getIdentifier().intValue()) {
                 /* Ignore children that are not mine */
                 return;
             }
@@ -965,8 +986,8 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     canvas.setAntiAliasingLevel(figure.getAntialiasing());
                 }
 
-                if (isImmediateDrawing(id)) {
-                    if (GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__ == property) {
+                if (figure instanceof Frame || isImmediateDrawing(id)) {
+                    if (figure instanceof Frame || GraphicObjectProperties.__GO_IMMEDIATE_DRAWING__ == property) {
                         canvas.redrawAndWait();
                     } else {
                         canvas.redraw();
@@ -994,8 +1015,9 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
     protected boolean needUpdate(Integer id, int property) {
         GraphicObject object = GraphicController.getController().getObjectFromId(id);
         int objectType = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__);
+        int objectStyle = (objectType == GraphicObjectProperties.__GO_UICONTROL__ ? (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_STYLE__) : -1);
         if ((object != null) && isFigureChild(id)
-                && objectType != GraphicObjectProperties.__GO_UICONTROL__
+                || (objectType == GraphicObjectProperties.__GO_UICONTROL__ && objectStyle == GraphicObjectProperties.__GO_UI_FRAME__)
                 && objectType != GraphicObjectProperties.__GO_UIMENU__) {
 
             if (GraphicObjectProperties.__GO_VALID__ == property) {
@@ -1039,7 +1061,10 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                     }
                 }
             } else if (object instanceof Figure) {
-                if (property == GraphicObjectProperties.__GO_SIZE__ || property == GraphicObjectProperties.__GO_AXES_SIZE__ || property == GraphicObjectProperties.__GO_CHILDREN__) {
+                if (property == GraphicObjectProperties.__GO_SIZE__ 
+                        || property == GraphicObjectProperties.__GO_AXES_SIZE__ 
+                        || property == GraphicObjectProperties.__GO_CHILDREN__
+                        || property == GraphicObjectProperties.__GO_POSITION__) {
                     Figure fig = (Figure) object;
                     for (Integer gid : fig.getChildren()) {
                         GraphicObject go = GraphicController.getController().getObjectFromId(gid);
@@ -1052,8 +1077,20 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
                 if (SILENT_FIGURE_PROPERTIES.contains(property)) {
                     return false;
                 }
-            } else if (object instanceof Axes && property == GraphicObjectProperties.__GO_X_AXIS_LOCATION__ ||
-                       property == GraphicObjectProperties.__GO_Y_AXIS_LOCATION__) {
+            } else if (object instanceof Frame 
+                    && id.intValue() == figure.getIdentifier().intValue()
+                    && property == GraphicObjectProperties.__GO_POSITION__) {
+                Frame fig = (Frame) object;
+                for (Integer gid : fig.getChildren()) {
+                    GraphicObject go = GraphicController.getController().getObjectFromId(gid);
+                    if (go instanceof Axes) {
+                        axesDrawer.computeRulers((Axes) go);
+                    }
+                }
+                return true;
+            }
+            else if (object instanceof Axes && property == GraphicObjectProperties.__GO_X_AXIS_LOCATION__ ||
+                    property == GraphicObjectProperties.__GO_Y_AXIS_LOCATION__) {
                 axesDrawer.computeMargins((Axes) object);
             }
 
@@ -1131,8 +1168,18 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
      * @return true if the given id correspond to a child of the current {@see Figure}.
      */
     private boolean isFigureChild(Integer id) {
-        Integer parentFigureID = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PARENT_FIGURE__);
-        return figure.getIdentifier() == parentFigureID;
+        if (id.intValue() == figure.getIdentifier().intValue()) {
+            return true;
+        }
+        
+        Integer parentUID = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PARENT__);
+        while (parentUID != 0) {
+            if (figure.getIdentifier().intValue() == parentUID.intValue()) {
+                return true;
+            }
+            parentUID = (Integer) GraphicController.getController().getProperty(parentUID, GraphicObjectProperties.__GO_PARENT__);
+        }
+        return false;
     }
 
     /**
@@ -1169,7 +1216,7 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
      * Figure getter.
      * @return the figure this visitor draw.
      */
-    public Figure getFigure() {
+    public AxesContainer getFigure() {
         return figure;
     }
 
index 0c2fcc6..a86f4dd 100644 (file)
@@ -18,6 +18,7 @@ import org.scilab.forge.scirenderer.texture.TextureDrawer;
 import org.scilab.forge.scirenderer.texture.TextureDrawingTools;
 import org.scilab.forge.scirenderer.texture.TextureManager;
 import org.scilab.modules.graphic_objects.axes.Axes;
+import org.scilab.modules.graphic_objects.axes.AxesContainer;
 import org.scilab.modules.graphic_objects.axes.AxisProperty;
 import org.scilab.modules.graphic_objects.figure.ColorMap;
 import org.scilab.modules.graphic_objects.figure.Figure;
@@ -68,7 +69,7 @@ public class AxesRulerSpriteFactory implements RulerSpriteFactory {
         ColorMap figureColorMap;
         try {
             GraphicController controller = GraphicController.getController();
-            Figure parentFigure = (Figure) controller.getObjectFromId(axes.getParentFigure());
+            AxesContainer parentFigure = (AxesContainer) controller.getObjectFromId(axes.getParentFigure());
             figureColorMap = parentFigure.getColorMap();
         } catch (NullPointerException e) {
             figureColorMap = null;
index 8a08cff..a15ec55 100644 (file)
@@ -174,6 +174,12 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
 
     @Override
     public void redrawAndWait() {
+        if (SwingUtilities.isEventDispatchThread()) {
+            if (autoDrawable!= null) {
+                autoDrawable.display();
+            }
+            return;
+        }
         try {
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {