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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.g2d.connection;
\r
14 import java.util.Collection;
\r
16 import org.simantics.g2d.diagram.handler.Topology.Connection;
\r
17 import org.simantics.g2d.element.IElement;
\r
20 * <code>ConnectionEntity</code> is an interface for querying the contents of a
\r
21 * branched connection.
\r
23 * @author Tuukka Lehtonen
\r
25 public interface ConnectionEntity {
\r
30 IElement getConnection();
\r
33 * Get all branch points that are part of this connection.
\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
39 Collection<IElement> getBranchPoints(Collection<IElement> result);
\r
42 * Get all segments that are part of this connection.
\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
48 Collection<IElement> getSegments(Collection<IElement> result);
\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
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
59 Collection<Connection> getTerminalConnections(Collection<Connection> result);
\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
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
73 public interface ConnectionListener {
\r
74 void connectionChanged(ConnectionEvent event);
\r
80 void setListener(ConnectionListener listener);
\r