1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.connection;
14 import java.util.Collection;
16 import org.simantics.g2d.diagram.handler.Topology.Connection;
17 import org.simantics.g2d.element.IElement;
20 * <code>ConnectionEntity</code> is an interface for querying the contents of a
21 * branched connection.
23 * @author Tuukka Lehtonen
25 public interface ConnectionEntity {
30 IElement getConnection();
33 * Get all branch points that are part of this connection.
35 * @param result the collection to store the result into or
36 * <code>null</code> to allocate a new collection
37 * @return the result collection
39 Collection<IElement> getBranchPoints(Collection<IElement> result);
42 * Get all segments that are part of this connection.
44 * @param result the collection to store the result into or
45 * <code>null</code> to allocate a new collection
46 * @return the result collection
48 Collection<IElement> getSegments(Collection<IElement> result);
51 * Get all topological terminal connections of this connection entity.
52 * Terminal connections are the only way to attach a connection to an
55 * @param result the collection to store the result into or
56 * <code>null</code> to allocate a new collection
57 * @return the result collection
59 Collection<Connection> getTerminalConnections(Collection<Connection> result);
61 public static class ConnectionEvent {
62 public final IElement connection;
63 public final Collection<IElement> removedParts;
64 public final Collection<IElement> addedParts;
66 public ConnectionEvent(IElement connection, Collection<IElement> removedParts, Collection<IElement> addedParts) {
67 this.connection = connection;
68 this.removedParts = removedParts;
69 this.addedParts = addedParts;
73 public interface ConnectionListener {
74 void connectionChanged(ConnectionEvent event);
80 void setListener(ConnectionListener listener);