2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Pierre Lando
4 * Copyright (C) 2010 - Scilab Enterprises - Bruno JOFRET
6 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 package org.scilab.modules.gui.graphicWindow;
14 import java.awt.Component;
15 import java.awt.Container;
16 import java.awt.Dimension;
17 import java.awt.LayoutManager;
18 import java.io.Serializable;
20 import org.scilab.modules.action_binding.InterpreterManagement;
21 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
22 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
23 import org.scilab.modules.gui.SwingViewObject;
24 import org.scilab.modules.gui.bridge.canvas.SwingScilabCanvas;
27 * @author Pierre Lando
29 @SuppressWarnings(value = { "serial" })
30 public class PanelLayout implements LayoutManager, Serializable {
32 public static final String GL_CANVAS = "GL_CANVAS";
33 public static final String UI_CONTROL = "UI_CONTROL";
34 private Component canvas;
37 public void addLayoutComponent(String name, Component comp) {
38 if (GL_CANVAS.equals(name)) {
44 public void removeLayoutComponent(Component comp) {
48 public Dimension preferredLayoutSize(Container parent) {
49 return new Dimension(0, 0);
53 public Dimension minimumLayoutSize(Container parent) {
54 return new Dimension(0, 0);
58 public void layoutContainer(Container parent) {
59 for (Component child : parent.getComponents()) {
60 if (child.equals(canvas)) {
61 canvas.setBounds(0, 0, parent.getWidth(), parent.getHeight());
62 parent.setComponentZOrder(child, parent.getComponentCount() - 1);
65 String figureIdentifier = ((SwingScilabCanvas) parent).getFigure().getIdentifier();
66 String resizeFcn = (String) GraphicController.getController().getProperty(figureIdentifier, GraphicObjectProperties.__GO_RESIZEFCN__);
67 if (resizeFcn != null && !resizeFcn.equals("")) {
68 String resizeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;"
69 + "gcbo = getcallbackobject(\"" + figureIdentifier + "\");"
71 + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;";
72 InterpreterManagement.requestScilabExec(resizeCommand);
75 /* Here you can perform the layout of UI object. */
76 if (child instanceof SwingViewObject) {
77 String id = ((SwingViewObject) child).getId();
78 ((SwingViewObject) child).update(GraphicObjectProperties.__GO_POSITION__,
79 GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_POSITION__));