]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/BendsHandler.java
Sync git svn branch with SVN repository r33324.
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / BendsHandler.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.element.handler;\r
13 \r
14 import java.awt.geom.Path2D;\r
15 import java.awt.geom.Point2D;\r
16 import java.util.List;\r
17 \r
18 import org.simantics.g2d.diagram.handler.Topology;\r
19 import org.simantics.g2d.element.IElement;\r
20 import org.simantics.g2d.element.ElementClass.Single;\r
21 \r
22 /**\r
23  * Interface for adapting editing edge bends between information models.\r
24  * \r
25  * Bend is a control point of an edge. The path of an edge follows thru all its \r
26  * edges.  \r
27  * \r
28  * @see Topology \r
29  * @author Toni Kalajainen\r
30  */\r
31 @Single\r
32 public interface BendsHandler extends ElementHandler { \r
33 \r
34         /** Information for painter */\r
35         public static enum AngleType { \r
36                 Line,                           /* Straight from begin to end */ \r
37                 RightAngled,            /* 90-degree angles */\r
38                 Linear,                         /* 1st degree lines, free angles */\r
39                 Quadratic                       /* 3rd degree line segments */\r
40                 // FIXME: 2nd, not 3rd degree ?\r
41         }\r
42         AngleType getAngleType(IElement e);\r
43         void setAngleType(IElement e, AngleType angleType);\r
44         \r
45         public interface Bend {}\r
46         \r
47         /**\r
48          * Get bends\r
49          * @param e\r
50          * @param bends collection to be filled with bends\r
51          */\r
52         void getBends(IElement e, List<Bend> bends);\r
53         \r
54         \r
55         /**\r
56          * Get bend position in element coordinate system\r
57          * \r
58          * @param e\r
59          * @param b\r
60          * @param pos point object to be filled with the position (not null) \r
61          * @return point object pos \r
62          */\r
63         void getBendPosition(IElement e, Bend b, Point2D pos);\r
64         \r
65         /**\r
66          * Add bend\r
67          * @param e\r
68          * @param index\r
69          * @param pos element coordinate system position\r
70          * @return\r
71          */\r
72         Bend addBend(IElement e, int index, Point2D pos);\r
73         \r
74         /**\r
75          * Set bends\r
76          * @param e\r
77          * @param bends\r
78          * @return true if successful \r
79          */\r
80         boolean removeBend(IElement e, Bend b);\r
81         \r
82         /**\r
83          * move position of a bend\r
84          * @param e\r
85          * @param b\r
86          * @param pos position in element coordinate system\r
87          */\r
88         void moveBend(IElement e, Bend b, Point2D pos); \r
89         \r
90         /**\r
91          * Get bends count\r
92          * @param e bends\r
93          * @return bends count\r
94          */\r
95         int getBendsCount(IElement e);\r
96         \r
97         /**\r
98          * Get Element path\r
99          * @param e\r
100          * @return\r
101          */\r
102         Path2D getPath(IElement e);\r
103         \r
104         /**\r
105          * Set element path\r
106          * @param e\r
107          * @param p\r
108          */\r
109         void setPath(IElement e, Path2D p);\r
110 }\r