net.clackrouter.router.graph
Class RouterGraphHelper

java.lang.Object
  extended by net.clackrouter.router.graph.RouterGraphHelper

public class RouterGraphHelper
extends java.lang.Object

Main GUI class to handle the JGraph end of components being added, removed, and connected within Clack.

Every ClackGraphpad has a reference to a ClackGraphHelper


Constructor Summary
RouterGraphHelper(ClackFramework gp)
           
 
Method Summary
 ComponentCell addRouterComponentCell(Router router, ClackComponent component, java.awt.geom.Rectangle2D bounds)
          Adds a ComponentCell to the RouterGraph representing the router that was passed to the ClackComponent when it was created.
 void addRouterWire(ComponentCell sourceCell, int src_port_num, ComponentCell targetCell, int target_port_num)
          Adds a RouterWire to the graph between two component ports that have been connected.
 void attemptPortConnection(DefaultPort source_port, DefaultPort target_port)
          Show connection dialog to connect two ports and attempt to make the connection
 void cellRemovedFromModel(DefaultGraphCell cell)
          Called when ClackDocument.graphChanged(GraphModelEvent) recognizes that something has been removed from the RouterGraph.
static void showConnectionErrorDialog(java.awt.Component comp, java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RouterGraphHelper

public RouterGraphHelper(ClackFramework gp)
Method Detail

addRouterComponentCell

public ComponentCell addRouterComponentCell(Router router,
                                            ClackComponent component,
                                            java.awt.geom.Rectangle2D bounds)
Adds a ComponentCell to the RouterGraph representing the router that was passed to the ClackComponent when it was created.

This keeps the graph in synch with the router when a component is added. Components are added with the specified bounds, or at the location of the last click if no bounds are provided.

Parameters:
component - - component added to the router
bounds - - location in RouterGraph to add componentCell
Returns:
the created cell

addRouterWire

public void addRouterWire(ComponentCell sourceCell,
                          int src_port_num,
                          ComponentCell targetCell,
                          int target_port_num)
Adds a RouterWire to the graph between two component ports that have been connected.

Parameters:
sourceCell - source component cell
src_port_num - source port number
targetCell - target component cell
target_port_num - target port number

attemptPortConnection

public void attemptPortConnection(DefaultPort source_port,
                                  DefaultPort target_port)
Show connection dialog to connect two ports and attempt to make the connection

Parameters:
source_port -
target_port -

cellRemovedFromModel

public void cellRemovedFromModel(DefaultGraphCell cell)
Called when ClackDocument.graphChanged(GraphModelEvent) recognizes that something has been removed from the RouterGraph.

If a RouterWire has been removed, we disconnect the underlying ports

If a component has been removed, we delete all edges connected to this component

Parameters:
cell - - cell that has been removed from the graph

showConnectionErrorDialog

public static void showConnectionErrorDialog(java.awt.Component comp,
                                             java.lang.String msg)