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