]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/connection/ConnectionEntity.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / connection / ConnectionEntity.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.connection;\r
13 \r
14 import java.util.Collection;\r
15 \r
16 import org.simantics.g2d.diagram.handler.Topology.Connection;\r
17 import org.simantics.g2d.element.IElement;\r
18 \r
19 /**\r
20  * <code>ConnectionEntity</code> is an interface for querying the contents of a\r
21  * branched connection.\r
22  * \r
23  * @author Tuukka Lehtonen\r
24  */\r
25 public interface ConnectionEntity {\r
26 \r
27     /**\r
28      * @return\r
29      */\r
30     IElement getConnection();\r
31 \r
32     /**\r
33      * Get all branch points that are part of this connection.\r
34      * \r
35      * @param result the collection to store the result into or\r
36      *        <code>null</code> to allocate a new collection\r
37      * @return the result collection\r
38      */\r
39     Collection<IElement> getBranchPoints(Collection<IElement> result);\r
40 \r
41     /**\r
42      * Get all segments that are part of this connection.\r
43      * \r
44      * @param result the collection to store the result into or\r
45      *        <code>null</code> to allocate a new collection\r
46      * @return the result collection\r
47      */\r
48     Collection<IElement> getSegments(Collection<IElement> result);\r
49 \r
50     /**\r
51      * Get all topological terminal connections of this connection entity.\r
52      * Terminal connections are the only way to attach a connection to an\r
53      * element terminal.\r
54      * \r
55      * @param result the collection to store the result into or\r
56      *        <code>null</code> to allocate a new collection\r
57      * @return the result collection\r
58      */\r
59     Collection<Connection> getTerminalConnections(Collection<Connection> result);\r
60 \r
61     public static class ConnectionEvent {\r
62         public final IElement             connection;\r
63         public final Collection<IElement> removedParts;\r
64         public final Collection<IElement> addedParts;\r
65 \r
66         public ConnectionEvent(IElement connection, Collection<IElement> removedParts, Collection<IElement> addedParts) {\r
67             this.connection = connection;\r
68             this.removedParts = removedParts;\r
69             this.addedParts = addedParts;\r
70         }\r
71     }\r
72 \r
73     public interface ConnectionListener {\r
74         void connectionChanged(ConnectionEvent event);\r
75     }\r
76 \r
77     /**\r
78      * @param listener\r
79      */\r
80     void setListener(ConnectionListener listener);\r
81 \r
82 }\r