diva.graphx
Class EdgeController

java.lang.Object
  extended by diva.graphx.EdgeController
Direct Known Subclasses:
SimpleEdgeController

public abstract class EdgeController
extends Object

A edge controller is the object responsible for managing all instances of a particular type of edge, and the corresponding Figures that are used to represent them on the canvas. Each graph controller contains one or more edge controllers.

Edge controllers assume that each edge is represented by a single Connector on the canvas. (If the edge is composite, then of course it's Connector also has sub-connectors, corresponding to child nodes and edges.) The mapping between connectors and edge objects is set up in the same manner as NodeController (@see NodeController).

This class has one abstract method which must be implemented by application-specific subclasses, renderEdge(). This method creates a Figure given a edge. A second method, drawEdgeChildren(), should be overridden by any subclass that manages composite edges.

Finally, concrete subclasses that want to change the default interactor will do so in the subclass' constructor. Subclass constructors must always call super() to ensure that the controller is properly initialized.

Version:
$Revision: 1.4 $
Author:
Michael Shilman, John Reekie

Nested Class Summary
protected  class EdgeController.EdgeDropper
          An inner class that handles interactive changes to connectivity.
protected  class EdgeController.EdgeTarget
          An inner class that is used as the target for connectors
 
Constructor Summary
EdgeController(GraphController controller)
          Create a new edge controller with basic interaction.
 
Method Summary
 void addEdge(Object edge, Object parent)
          Add an edge that to the graph, and draw it on the canvas.
 void addEdge(Object edge, Object parent, Object tail, Object head)
          Add an edge to the model and render it on the canvas.
 void bind(Object edge, Connector connector)
          Create or overwrite a binding from an edge to a connector.
 void drawEdge(Object edge, Object parent, Site tailSite, Site headSite)
          Draw the edge inside the given parent, and between the two given sites.
 void drawEdgeChildren(Object parent, Figure container)
          Draw the children of the given edge.
 Connector getConnector(Object node)
          Get the connector corresponding to the given edge.
 ConnectorTarget getConnectorTarget()
          Get the target used to find sites on nodes to connect to.
 GraphController getController()
          Get the graph controller that this controller is contained in.
 Interactor getEdgeInteractor()
          Get the interactor given to edge figures.
 void removeEdge(Object edge)
          Remove the given edge, and its associated figure.
abstract  Connector renderEdge(Object edge, Object parent, FigureContainer container, Site tailSite, Site headSite)
          Render a visual representation of the given edge, between the given head and tail sites, and add it to the given figure container.
 void setConnectorTarget(ConnectorTarget t)
          Set the target used to find sites on nodes to connect to.
 void setEdgeInteractor(Interactor interactor)
          Set the interactor given to edge figures.
 void setHead(Object edge, Object head)
          Set the head of an edge to the given node.
 void setTail(Object edge, Object tail)
          Set the tail of an edge to the given node.
 void unbind(Object edge, Connector connector)
          Remove a binding from an edge to a connector.
 void undrawEdge(Object edge)
          Remove the figure associated with the given edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeController

public EdgeController(GraphController controller)
Create a new edge controller with basic interaction. Specifically, this method creates an edge interactor and initializes its menipulator so that edges get attached appropriately. Furthermore, the edge interactor is initialized with the selection model of the graph controller. The manipulator is activated by either a regular click or a control click. Also initialize a basic connector target that generally attaches to the perimeter of nodes, except that it is smart enough to properly handle terminals.

Method Detail

addEdge

public void addEdge(Object edge,
                    Object parent)
Add an edge that to the graph, and draw it on the canvas. The edge is not connected to a node at either end.


addEdge

public void addEdge(Object edge,
                    Object parent,
                    Object tail,
                    Object head)
Add an edge to the model and render it on the canvas. The edge is placed inside the given parent, and connected to the two given tail and head nodes.


bind

public void bind(Object edge,
                 Connector connector)
Create or overwrite a binding from an edge to a connector.


drawEdge

public void drawEdge(Object edge,
                     Object parent,
                     Site tailSite,
                     Site headSite)
Draw the edge inside the given parent, and between the two given sites. If the edge is a hyperedge, then this method will call the drawEdgeChildren() method to draw contained nodes and edges.


drawEdgeChildren

public void drawEdgeChildren(Object parent,
                             Figure container)
Draw the children of the given edge. The container argument is the Figure that was previously drawn for this node. Subclasses that control hyperedges must override this method to iterate through child elements and call drawNode() or drawEdge() on the appropriate controller for each of them.


getConnectorTarget

public ConnectorTarget getConnectorTarget()
Get the target used to find sites on nodes to connect to.


getController

public GraphController getController()
Get the graph controller that this controller is contained in.


getConnector

public Connector getConnector(Object node)
Get the connector corresponding to the given edge. Returns null if the edge is not known to this controller.


getEdgeInteractor

public Interactor getEdgeInteractor()
Get the interactor given to edge figures.


removeEdge

public void removeEdge(Object edge)
Remove the given edge, and its associated figure. Notify any view listeners.


setConnectorTarget

public void setConnectorTarget(ConnectorTarget t)
Set the target used to find sites on nodes to connect to. This sets the local connector target (which is often used to find the starting point of an edge) and the manipulator's connector target, which is used after the connector is being dragged.


setEdgeInteractor

public void setEdgeInteractor(Interactor interactor)
Set the interactor given to edge figures.


renderEdge

public abstract Connector renderEdge(Object edge,
                                     Object parent,
                                     FigureContainer container,
                                     Site tailSite,
                                     Site headSite)
Render a visual representation of the given edge, between the given head and tail sites, and add it to the given figure container. If the node is at the top level of the graph, then the container will be a FigureLayer, otherwise it will be a Figure class that also implements the FigureContainer interface.


setHead

public void setHead(Object edge,
                    Object head)
Set the head of an edge to the given node. If the node is the same as the current head, then do nothing. If the node is null, then disconnect the edge and draw the edge to an autonomous site. Otherwise, reconnect the edge to the new head.


setTail

public void setTail(Object edge,
                    Object tail)
Set the tail of an edge to the given node. If the node is the same as the current tail, then do nothing. If the node is null, then disconnect the edge and draw the edge to an autonomous site. Otherwise, reconnect the edge to the new tail.


unbind

public void unbind(Object edge,
                   Connector connector)
Remove a binding from an edge to a connector. Throw an exception if the binding is not valid. (This is very very bad and should not happen. If it does then there is a serious bug somewhere else.)


undrawEdge

public void undrawEdge(Object edge)
Remove the figure associated with the given edge. The model itself is not touched at all.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.