org.jgraph.graph

Class ConnectionSet

public class ConnectionSet extends Object implements Serializable

An object that represents a set of connections. Connections are equal, if equals returns true. Connections that are added later replace earlier connections.
Nested Class Summary
static classConnectionSet.Connection
Object that represents the connection between an edge and a port.
Field Summary
protected Setconnections
Contents of the connection set.
protected Setedges
Set of changed edges for the connection set.
Constructor Summary
ConnectionSet()
Constructs an empty ConnectionSet.
ConnectionSet(Object edge, Object port, boolean source)
Constructs a ConnectionSet with one Connection.
ConnectionSet(Set connections)
Constructs a connection set containing the specified connections and updates the set of changed edges.
ConnectionSet(Object edge, Object source, Object target)
Constructs a ConnectionSet with two Connections (to the source and target port of the edge).
Method Summary
voidaddConnections(CellView[] views)
Adds the connections in views to the connection set.
ConnectionSetclone(Map map)
Creates a new connection set based on this connection set, where the edges, and ports are mapped using map.
protected static voidconnect(ConnectionSet cs, Object edge, Object port, boolean source, boolean disconnect)
Connect or disconnect edge from source and target in cs based on disconnect.
voidconnect(Object edge, Object source, Object target)
Connect edge to source and target in the connection set.
voidconnect(Object edge, Object port, boolean source)
Connect edge to port passed in.
Iteratorconnections()
Returns an Iterator for the connections in this set.
static ConnectionSetcreate(GraphModel m, Object[] cells, boolean disconnect)
Returns a connection set that represents the connection or disconnection of cells in model based on disconnect.
voiddisconnect(Object edge)
Disconnect edge from source and target in the connection set.
voiddisconnect(Object edge, boolean source)
Disconnect edge from port.
SetgetChangedEdges()
Returns a Set for the edges in this connection set.
SetgetConnections()
SetgetEdges()
ObjectgetPort(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.
booleanisEmpty()
Returns true if the connection set is empty.
voidsetConnections(Set set)
voidsetEdges(Set set)
intsize()
Returns the number of (edge, port)-pairs.

Field Detail

connections

protected Set connections
Contents of the connection set.

edges

protected Set edges
Set of changed edges for the connection set.

Constructor Detail

ConnectionSet

public ConnectionSet()
Constructs an empty ConnectionSet.

ConnectionSet

public ConnectionSet(Object edge, Object port, boolean source)
Constructs a ConnectionSet with one Connection.

ConnectionSet

public ConnectionSet(Set connections)
Constructs a connection set containing the specified connections and updates the set of changed edges.

ConnectionSet

public ConnectionSet(Object edge, Object source, Object target)
Constructs a ConnectionSet with two Connections (to the source and target port of the edge).

Method Detail

addConnections

public void addConnections(CellView[] views)
Adds the connections in views to the connection set.

clone

public ConnectionSet clone(Map map)
Creates a new connection set based on this connection set, where the edges, and ports are mapped using map. If a port is not found, the old port is used. If both, the edge and the port are not in map, 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.

connect

protected static void connect(ConnectionSet cs, Object edge, Object port, boolean source, boolean disconnect)
Connect or disconnect edge from source and target in cs based on disconnect.

connect

public void connect(Object edge, Object source, Object target)
Connect edge to source and target in the connection set. The previous connections between edge and its source and target are replaced in the set.

connect

public void connect(Object edge, Object port, boolean source)
Connect edge to port passed in. The source indicates if port is the source of edge object. The previous connections between edge and its source or target in the set is replaced.

connections

public Iterator connections()
Returns an Iterator for the connections in this set.

create

public static ConnectionSet create(GraphModel m, Object[] cells, boolean disconnect)
Returns a connection set that represents the connection or disconnection of cells in model based on disconnect.

disconnect

public void disconnect(Object edge)
Disconnect edge from source and target in the connection set. The previous connections between edge and its source and target are replaced in the set.

disconnect

public void disconnect(Object edge, boolean source)
Disconnect edge from port. source indicates if port is the source of edge. The previous connections between edge and its source or target in the set is replaced.

getChangedEdges

public Set getChangedEdges()

Deprecated: Use getEdges

Returns a Set for the edges in this connection set.

getConnections

public Set getConnections()

Returns: the set of connections

getEdges

public Set getEdges()

Returns: the edges making us this connection set

getPort

public Object getPort(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.

isEmpty

public boolean isEmpty()
Returns true if the connection set is empty.

setConnections

public void setConnections(Set set)

Parameters: set

setEdges

public void setEdges(Set set)

Parameters: set

size

public int size()
Returns the number of (edge, port)-pairs.
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.