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