]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/TerminalLayout.java
Support for dynamic transforms for both elements and terminals
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / TerminalLayout.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.Shape;
15 import java.awt.geom.AffineTransform;
16
17 import org.simantics.g2d.diagram.handler.Topology.Terminal;
18 import org.simantics.g2d.element.IElement;
19 import org.simantics.g2d.element.handler.impl.StaticTerminals;
20 import org.simantics.g2d.utils.geom.DirectionSet;
21
22 /**
23  * 
24  * @See {@link TerminalTopology} Enumeration of terminals
25  * @See {@link StaticTerminals} Compile handler for elements with static terminals (almost all)
26  * @author Toni Kalajainen
27  */
28 public interface TerminalLayout extends ElementHandler {
29         
30         /**
31          * Get specified terminal transformation on specified element
32          * 
33          * @param node
34          * @param t
35          * @return position of a terminal or null if specified terminal does not
36          *         belong to the specified element. The returned AffineTransform
37          *         must be treated as if it were immutable since the implementation
38          *         is allowed to returned singleton/cached values.
39          */
40         AffineTransform getTerminalPosition(IElement node, Terminal t);
41         
42         /**
43          * Get Terminal direction  
44          * @param node node
45          * @param t terminal
46          * @param directions collection where directions are added (compass direction, 0 + n*360=north, n e N)
47          * @return true if this handler could tell the terminal direction 
48          */
49         boolean getTerminalDirection(IElement node, Terminal t, DirectionSet directions);
50         
51         /**
52          * Get shape of a terminal.
53          * If terminal has a shape its selection is based on it and is zoom-level dependent.
54          * If a terminal has no shape it is a point and zoom-level independent.
55          * 
56          * Only the area that fits into the element will be picked. 
57          * 
58          * @return shape shape or null
59          */
60         Shape getTerminalShape(IElement node, Terminal t);
61         
62 }