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