]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/LayoutManager.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / handler / LayoutManager.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.diagram.handler;\r
13 \r
14 import java.awt.geom.Rectangle2D;\r
15 \r
16 import org.simantics.g2d.diagram.IDiagram;\r
17 import org.simantics.g2d.diagram.handler.layout.BorderLayout;\r
18 import org.simantics.g2d.diagram.handler.layout.FlowLayout;\r
19 import org.simantics.g2d.diagram.handler.layout.GridLayout;\r
20 \r
21 /**\r
22  * LayoutManager puts elements on diagram. \r
23  * layout() method must be explicitely invoked.\r
24  * \r
25  * Diagram must have size hint (DiagramHints.KEY_BOUNDS).\r
26  * \r
27  * @See {@link FlowLayout}\r
28  * @See {@link GridLayout}\r
29  * @See {@link BorderLayout}\r
30  * @author Toni Kalajainen\r
31  */\r
32 public interface LayoutManager extends DiagramHandler {\r
33 \r
34         /**\r
35          * Lay-out elements on the diagram. \r
36          * \r
37          * @param diagram\r
38          */\r
39     void layout(IDiagram diagram, Rectangle2D bounds);\r
40         \r
41     /**\r
42      * Computes and returns the size of the specified\r
43      * composite's client area according to this layout.\r
44      * <p>\r
45      * This method computes the size that the client area \r
46      * of the composite must be in order to position all \r
47      * children at their preferred size inside the\r
48      * composite according to the layout algorithm\r
49      * encoded by this layout.\r
50      * </p>\r
51      * <p>\r
52      * When a width or height hint is supplied, it is\r
53      * used to constrain the result. For example, if a\r
54      * width hint is provided that is less than the\r
55      * width of the client area, the layout may choose\r
56      * to wrap and increase height, clip, overlap, or\r
57      * otherwise constrain the children.\r
58      * </p>\r
59      *\r
60      * @param composite a composite widget using this layout\r
61      * @param wHint width (<code>null</code> for preferred size)\r
62      * @param hHint height (<code>null</code> for preferred size)\r
63      * @return the computed size (width, height)\r
64      */\r
65         Rectangle2D computeSize(IDiagram diagram, Double wHint, Double hHint);     \r
66         \r
67 }\r