]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/LayoutManager.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/LayoutManager.java
new file mode 100644 (file)
index 0000000..37a98a2
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.diagram.handler;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.diagram.handler.layout.BorderLayout;\r
+import org.simantics.g2d.diagram.handler.layout.FlowLayout;\r
+import org.simantics.g2d.diagram.handler.layout.GridLayout;\r
+\r
+/**\r
+ * LayoutManager puts elements on diagram. \r
+ * layout() method must be explicitely invoked.\r
+ * \r
+ * Diagram must have size hint (DiagramHints.KEY_BOUNDS).\r
+ * \r
+ * @See {@link FlowLayout}\r
+ * @See {@link GridLayout}\r
+ * @See {@link BorderLayout}\r
+ * @author Toni Kalajainen\r
+ */\r
+public interface LayoutManager extends DiagramHandler {\r
+\r
+       /**\r
+        * Lay-out elements on the diagram. \r
+        * \r
+        * @param diagram\r
+        */\r
+    void layout(IDiagram diagram, Rectangle2D bounds);\r
+       \r
+    /**\r
+     * Computes and returns the size of the specified\r
+     * composite's client area according to this layout.\r
+     * <p>\r
+     * This method computes the size that the client area \r
+     * of the composite must be in order to position all \r
+     * children at their preferred size inside the\r
+     * composite according to the layout algorithm\r
+     * encoded by this layout.\r
+     * </p>\r
+     * <p>\r
+     * When a width or height hint is supplied, it is\r
+     * used to constrain the result. For example, if a\r
+     * width hint is provided that is less than the\r
+     * width of the client area, the layout may choose\r
+     * to wrap and increase height, clip, overlap, or\r
+     * otherwise constrain the children.\r
+     * </p>\r
+     *\r
+     * @param composite a composite widget using this layout\r
+     * @param wHint width (<code>null</code> for preferred size)\r
+     * @param hHint height (<code>null</code> for preferred size)\r
+     * @return the computed size (width, height)\r
+     */\r
+       Rectangle2D computeSize(IDiagram diagram, Double wHint, Double hHint);     \r
+       \r
+}\r