Package org.jgraph.graph
Class ConnectionSet
- java.lang.Object
-
- org.jgraph.graph.ConnectionSet
-
- All Implemented Interfaces:
java.io.Serializable
public class ConnectionSet extends java.lang.Object implements java.io.Serializable
An object that represents a set of connections. Connections are equal, if equals returns true. Connections that are added later replace earlier connections.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionSet.Connection
Object that represents the connection between an edge and a port.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set
connections
Contents of the connection set.protected java.util.Set
edges
Set of changed edges for the connection set.
-
Constructor Summary
Constructors Constructor Description ConnectionSet()
Constructs an empty ConnectionSet.ConnectionSet(java.lang.Object edge, java.lang.Object port, boolean source)
Constructs a ConnectionSet with one Connection.ConnectionSet(java.lang.Object edge, java.lang.Object source, java.lang.Object target)
Constructs a ConnectionSet with two Connections (to the source and target port of the edge).ConnectionSet(java.util.Set connections)
Constructs a connection set containing the specified connections and updates the set of changed edges.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnections(CellView[] views)
Adds the connections inviews
to the connection set.ConnectionSet
clone(java.util.Map map)
Creates a new connection set based on this connection set, where the edges, and ports are mapped usingmap
.void
connect(java.lang.Object edge, java.lang.Object port, boolean source)
Connectedge
toport
passed in.void
connect(java.lang.Object edge, java.lang.Object source, java.lang.Object target)
Connectedge
tosource
andtarget
in the connection set.protected static void
connect(ConnectionSet cs, java.lang.Object edge, java.lang.Object port, boolean source, boolean disconnect)
Connect or disconnectedge
fromsource
andtarget
incs
based ondisconnect
.java.util.Iterator
connections()
Returns anIterator
for the connections in this set.static ConnectionSet
create(GraphModel m, java.lang.Object[] cells, boolean disconnect)
Returns a connection set that represents the connection or disconnection ofcells
inmodel
based ondisconnect
.void
disconnect(java.lang.Object edge)
Disconnectedge
fromsource
andtarget
in the connection set.void
disconnect(java.lang.Object edge, boolean source)
Disconnectedge
fromport
.java.util.Set
getChangedEdges()
Returns aSet
for the edges in this connection set.java.util.Set
getConnections()
java.util.Set
getEdges()
java.lang.Object
getPort(java.lang.Object edge, boolean source)
Returns the source or target of the specified edge in this connection set or null if the connection set contains no corresponding entry for the edge.boolean
isEmpty()
Returnstrue
if the connection set is empty.void
setConnections(java.util.Set set)
void
setEdges(java.util.Set set)
int
size()
Returns the number of (edge, port)-pairs.
-
-
-
Constructor Detail
-
ConnectionSet
public ConnectionSet()
Constructs an empty ConnectionSet.
-
ConnectionSet
public ConnectionSet(java.lang.Object edge, java.lang.Object port, boolean source)
Constructs a ConnectionSet with one Connection.
-
ConnectionSet
public ConnectionSet(java.util.Set connections)
Constructs a connection set containing the specified connections and updates the set of changed edges.
-
ConnectionSet
public ConnectionSet(java.lang.Object edge, java.lang.Object source, java.lang.Object target)
Constructs a ConnectionSet with two Connections (to the source and target port of the edge).
-
-
Method Detail
-
create
public static ConnectionSet create(GraphModel m, java.lang.Object[] cells, boolean disconnect)
Returns a connection set that represents the connection or disconnection ofcells
inmodel
based ondisconnect
.
-
connect
protected static void connect(ConnectionSet cs, java.lang.Object edge, java.lang.Object port, boolean source, boolean disconnect)
Connect or disconnectedge
fromsource
andtarget
incs
based ondisconnect
.
-
addConnections
public void addConnections(CellView[] views)
Adds the connections inviews
to the connection set.
-
connect
public void connect(java.lang.Object edge, java.lang.Object source, java.lang.Object target)
Connectedge
tosource
andtarget
in the connection set. The previous connections betweenedge
and its source and target are replaced in the set.
-
connect
public void connect(java.lang.Object edge, java.lang.Object port, boolean source)
Connectedge
toport
passed in. Thesource
indicates ifport
is the source ofedge
object. The previous connections betweenedge
and its source or target in the set is replaced.
-
disconnect
public void disconnect(java.lang.Object edge)
Disconnectedge
fromsource
andtarget
in the connection set. The previous connections betweenedge
and its source and target are replaced in the set.
-
disconnect
public void disconnect(java.lang.Object edge, boolean source)
Disconnectedge
fromport
.source
indicates ifport
is the source ofedge
. The previous connections betweenedge
and its source or target in the set is replaced.
-
isEmpty
public boolean isEmpty()
Returnstrue
if the connection set is empty.
-
size
public int size()
Returns the number of (edge, port)-pairs.
-
connections
public java.util.Iterator connections()
Returns anIterator
for the connections in this set.
-
getChangedEdges
public java.util.Set getChangedEdges()
Returns aSet
for the edges in this connection set.
-
getPort
public java.lang.Object getPort(java.lang.Object edge, boolean source)
Returns the source or target of the specified edge in this connection set or null if the connection set contains no corresponding entry for the edge.
-
clone
public ConnectionSet clone(java.util.Map map)
Creates a new connection set based on this connection set, where the edges, and ports are mapped usingmap
. If a port is not found, the old port is used. If both, the edge and the port are not inmap
, the entry is ignored.Note: Consequently, unselected edges are only reconnected at the first "paste" after a "cut", because in this case the ConnectionSet is not cloned.
-
getConnections
public java.util.Set getConnections()
- Returns:
- the set of connections
-
getEdges
public java.util.Set getEdges()
- Returns:
- the edges making us this connection set
-
setConnections
public void setConnections(java.util.Set set)
- Parameters:
set
-
-
setEdges
public void setEdges(java.util.Set set)
- Parameters:
set
-
-
-