1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.diagram.handler;
14 import java.awt.geom.Rectangle2D;
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;
22 * LayoutManager puts elements on diagram.
23 * layout() method must be explicitely invoked.
25 * Diagram must have size hint (DiagramHints.KEY_BOUNDS).
27 * @See {@link FlowLayout}
28 * @See {@link GridLayout}
29 * @See {@link BorderLayout}
30 * @author Toni Kalajainen
32 public interface LayoutManager extends DiagramHandler {
35 * Lay-out elements on the diagram.
39 void layout(IDiagram diagram, Rectangle2D bounds);
42 * Computes and returns the size of the specified
43 * composite's client area according to this layout.
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.
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.
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)
65 Rectangle2D computeSize(IDiagram diagram, Double wHint, Double hHint);