]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/BendsHandler.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / BendsHandler.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/BendsHandler.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/BendsHandler.java
new file mode 100644 (file)
index 0000000..1d6290c
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************\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.element.handler;\r
+\r
+import java.awt.geom.Path2D;\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.g2d.diagram.handler.Topology;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.ElementClass.Single;\r
+\r
+/**\r
+ * Interface for adapting editing edge bends between information models.\r
+ * \r
+ * Bend is a control point of an edge. The path of an edge follows thru all its \r
+ * edges.  \r
+ * \r
+ * @see Topology \r
+ * @author Toni Kalajainen\r
+ */\r
+@Single\r
+public interface BendsHandler extends ElementHandler { \r
+\r
+       /** Information for painter */\r
+       public static enum AngleType { \r
+               Line,                           /* Straight from begin to end */ \r
+               RightAngled,            /* 90-degree angles */\r
+               Linear,                         /* 1st degree lines, free angles */\r
+               Quadratic                       /* 3rd degree line segments */\r
+               // FIXME: 2nd, not 3rd degree ?\r
+       }\r
+       AngleType getAngleType(IElement e);\r
+       void setAngleType(IElement e, AngleType angleType);\r
+       \r
+       public interface Bend {}\r
+       \r
+       /**\r
+        * Get bends\r
+        * @param e\r
+        * @param bends collection to be filled with bends\r
+        */\r
+       void getBends(IElement e, List<Bend> bends);\r
+       \r
+       \r
+       /**\r
+        * Get bend position in element coordinate system\r
+        * \r
+        * @param e\r
+        * @param b\r
+        * @param pos point object to be filled with the position (not null) \r
+        * @return point object pos \r
+        */\r
+       void getBendPosition(IElement e, Bend b, Point2D pos);\r
+       \r
+       /**\r
+        * Add bend\r
+        * @param e\r
+        * @param index\r
+        * @param pos element coordinate system position\r
+        * @return\r
+        */\r
+       Bend addBend(IElement e, int index, Point2D pos);\r
+       \r
+       /**\r
+        * Set bends\r
+        * @param e\r
+        * @param bends\r
+        * @return true if successful \r
+        */\r
+       boolean removeBend(IElement e, Bend b);\r
+       \r
+       /**\r
+        * move position of a bend\r
+        * @param e\r
+        * @param b\r
+        * @param pos position in element coordinate system\r
+        */\r
+       void moveBend(IElement e, Bend b, Point2D pos); \r
+       \r
+       /**\r
+        * Get bends count\r
+        * @param e bends\r
+        * @return bends count\r
+        */\r
+       int getBendsCount(IElement e);\r
+       \r
+       /**\r
+        * Get Element path\r
+        * @param e\r
+        * @return\r
+        */\r
+       Path2D getPath(IElement e);\r
+       \r
+       /**\r
+        * Set element path\r
+        * @param e\r
+        * @param p\r
+        */\r
+       void setPath(IElement e, Path2D p);\r
+}\r