diva.graph
Class BasicEdgeController

java.lang.Object
  extended by diva.graph.BasicEdgeController
All Implemented Interfaces:
EdgeController
Direct Known Subclasses:
LinkController, TransitionController, TransitionController

public class BasicEdgeController
extends java.lang.Object
implements EdgeController

A basic implementation of EdgeController, which works with graphs that have edges connecting simple nodes.

Version:
$Id: BasicEdgeController.java 43782 2006-09-21 15:10:05Z cxh $
Author:
Michael Shilman
Accepted Rating:
Red

Nested Class Summary
protected  class BasicEdgeController.EdgeDropper
          An inner class that handles interactive changes to connectivity.
 
Field Summary
private  ConnectorTarget _connectorTarget
          The connector target
private  GraphController _controller
           
private  Interactor _interactor
           
private  EdgeRenderer _renderer
           
 
Constructor Summary
BasicEdgeController(GraphController controller)
          Create a new edge controller with basic interaction.
 
Method Summary
 void addEdge(java.lang.Object edge, java.lang.Object node, int end, double x, double y)
          Add an edge to this graph editor and render it from the given tail node to an autonomous site at the given location.
 void addEdge(java.lang.Object edge, java.lang.Object tail, java.lang.Object head)
          Add an edge to this graph between the given tail and head nodes.
 void clearEdge(java.lang.Object edge)
          Remove the figure for the given edge, but do not remove the edge from the graph model.
 Figure drawEdge(java.lang.Object edge)
          Draw the edge and add it to the layer, establishing a two-way correspondence between the model and the view.
 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.
 EdgeRenderer getEdgeRenderer()
          Return the edge renderer for this view.
 void removeEdge(java.lang.Object edge)
          Remove the edge.
 Connector render(java.lang.Object edge, FigureLayer layer, Site tailSite, Site headSite)
          Render the edge on the given layer between the two sites.
 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 setEdgeRenderer(EdgeRenderer er)
          Set the edge renderer for this view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_connectorTarget

private ConnectorTarget _connectorTarget
The connector target


_interactor

private Interactor _interactor

_renderer

private EdgeRenderer _renderer

_controller

private GraphController _controller
Constructor Detail

BasicEdgeController

public BasicEdgeController(GraphController controller)
Create a new edge controller with basic interaction. Specifically, this method creates an edge interactor and initializes its manipulator 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(java.lang.Object edge,
                    java.lang.Object node,
                    int end,
                    double x,
                    double y)
Add an edge to this graph editor and render it from the given tail node to an autonomous site at the given location. Give the new edge the given semanticObject. The "end" flag is either HEAD_END or TAIL_END, from diva.canvas.connector.ConnectorEvent.

Specified by:
addEdge in interface EdgeController
Throws:
GraphException - If the connector target cannot return a valid site on the node's figure.
See Also:
ConnectorEvent

addEdge

public void addEdge(java.lang.Object edge,
                    java.lang.Object tail,
                    java.lang.Object head)
Add an edge to this graph between the given tail and head nodes. Give the new edge the given semanticObject.

Specified by:
addEdge in interface EdgeController

clearEdge

public void clearEdge(java.lang.Object edge)
Remove the figure for the given edge, but do not remove the edge from the graph model.

Specified by:
clearEdge in interface EdgeController

drawEdge

public Figure drawEdge(java.lang.Object edge)
Draw the edge and add it to the layer, establishing a two-way correspondence between the model and the view. If the edge already has been associated with some figure in the view, then use any information in that figure to help draw the edge.

Specified by:
drawEdge in interface EdgeController

getConnectorTarget

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

Specified by:
getConnectorTarget in interface EdgeController

getController

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

Specified by:
getController in interface EdgeController

getEdgeInteractor

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

Specified by:
getEdgeInteractor in interface EdgeController

getEdgeRenderer

public EdgeRenderer getEdgeRenderer()
Return the edge renderer for this view.

Specified by:
getEdgeRenderer in interface EdgeController

removeEdge

public void removeEdge(java.lang.Object edge)
Remove the edge.

Specified by:
removeEdge in interface EdgeController

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.

Specified by:
setConnectorTarget in interface EdgeController

setEdgeInteractor

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

Specified by:
setEdgeInteractor in interface EdgeController

setEdgeRenderer

public void setEdgeRenderer(EdgeRenderer er)
Set the edge renderer for this view.

Specified by:
setEdgeRenderer in interface EdgeController

render

public Connector render(java.lang.Object edge,
                        FigureLayer layer,
                        Site tailSite,
                        Site headSite)
Render the edge on the given layer between the two sites.

Specified by:
render in interface EdgeController