ConnectionManager

public class ConnectionManager extends Object

Controller for Connections.

Public Constructor Summary

Public Method Summary

void
addConnection(Connection conn)
Figure out which list the connection belongs in; insert it.
void
clear()
Clear all the internal state of the manager.
Connection
closestConnection(Connection conn, double maxRadius)
Find the closest compatible connection to this connection.
Pair<ConnectionConnection>
findBestConnection(Block block, float radiusConnectionWS)
Iterate over all of the connections on the block and find the one that is closest to a valid connection on another block.
void
getNeighbors(Connection conn, int maxRadius, List<Connection> result)
Find all compatible connections within the given radius.
void
moveConnectionTo(Connection conn, WorkspacePoint newLocation, WorkspacePoint offset)
Move the given connector to a specific location and update the relevant list.
void
removeConnection(Connection conn)
Remove a connection from the list that handles connections of its type.

Inherited Method Summary

Public Constructors

public ConnectionManager ()

Public Methods

public void addConnection (Connection conn)

Figure out which list the connection belongs in; insert it.

Parameters
conn The connection to add.

public void clear ()

Clear all the internal state of the manager.

public Connection closestConnection (Connection conn, double maxRadius)

Find the closest compatible connection to this connection.

Parameters
conn The base connection for the search.
maxRadius How far out to search for compatible connections.
Returns
  • The closest compatible connection.

public Pair<ConnectionConnection> findBestConnection (Block block, float radiusConnectionWS)

Iterate over all of the connections on the block and find the one that is closest to a valid connection on another block.

Parameters
block The Block whose connections to search.
radiusConnectionWS The maximum distance between viable connections in workspace units.
Returns
  • A pair of connections, where the first is a connection on block and the second is the closest compatible connection.

public void getNeighbors (Connection conn, int maxRadius, List<Connection> result)

Find all compatible connections within the given radius. This function is used for bumping so type checking does not apply.

Parameters
conn The base connection for the search.
maxRadius How far out to search for compatible connections.
result
Returns
  • A list of all nearby compatible connections.

public void moveConnectionTo (Connection conn, WorkspacePoint newLocation, WorkspacePoint offset)

Move the given connector to a specific location and update the relevant list.

Parameters
conn The connection to move.
newLocation The position to move to.
offset An additional offset, usually the position of the parent view in the workspace view.

public void removeConnection (Connection conn)

Remove a connection from the list that handles connections of its type.

Parameters
conn The connection to remove.