diva.canvas.connector
Class ManhattanConnector

java.lang.Object
  extended by diva.canvas.AbstractFigure
      extended by diva.canvas.connector.AbstractConnector
          extended by diva.canvas.connector.ManhattanConnector
All Implemented Interfaces:
CanvasComponent, Connector, Figure, VisibleComponent, UserObjectContainer
Direct Known Subclasses:
LinkManhattanConnector

public class ManhattanConnector
extends AbstractConnector

A Connector that draws itself with perpendicular lines. To help it route itself, the connector contains an instance of ManhattanRouter, which can be changed to create other kinds of (or smarter) connectors. By default the connector routes itself with rounded corners, which tend to look a little nicer in complex views. To get standard right angles at the corners, set the bend radius to zero.

Version:
$Id: ManhattanConnector.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie, Michael Shilman

Field Summary
private  double _bendRadius
          The radius for filleting the corners of the connector.
private  java.awt.geom.Point2D _labelLocation
          The location to attach the label to.
private  ManhattanRouter _router
          The router used to route this connector.
 
Constructor Summary
ManhattanConnector(Site tail, Site head)
          Create a new manhattan connector between the given sites.
ManhattanConnector(Site tail, Site head, ManhattanRouter router)
          Create a new manhattan connector between the given sites and with the given router.
 
Method Summary
 double getBendRadius()
          Return the maximum bend radius of the manhattan-routed edge.
 ManhattanRouter getRouter()
          Return the router.
 void repositionLabel()
          Tell the connector to reposition the text label.
 void route()
          Tell the connector to route itself between the current positions of the head and tail sites.
 void setBendRadius(double r)
          Set the maximum bend radius of the manhattan-routed edge.
 void setRouter(ManhattanRouter router)
          Set the router and route again.
 void translate(double x, double y)
          Translate the connector.
 
Methods inherited from class diva.canvas.connector.AbstractConnector
getBounds, getDashArray, getHeadEnd, getHeadSite, getLabelFigure, getLineWidth, getShape, getStroke, getStrokePaint, getTailEnd, getTailSite, headMoved, hit, intersects, paint, reroute, setDashArray, setHeadEnd, setHeadSite, setLabelFigure, setLineWidth, setShape, setStroke, setStrokePaint, setTailEnd, setTailSite, tailMoved, transform
 
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface diva.canvas.Figure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, setInteractor, setParent, setToolTipText
 
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
 
Methods inherited from interface diva.canvas.CanvasComponent
getTransformContext, repaint, repaint
 
Methods inherited from interface diva.util.UserObjectContainer
getUserObject, setUserObject
 

Field Detail

_bendRadius

private double _bendRadius
The radius for filleting the corners of the connector.


_labelLocation

private java.awt.geom.Point2D _labelLocation
The location to attach the label to.


_router

private ManhattanRouter _router
The router used to route this connector.

Constructor Detail

ManhattanConnector

public ManhattanConnector(Site tail,
                          Site head)
Create a new manhattan connector between the given sites. The connector is drawn with a width of one and in black. The router is an instance of BasicManhattanRouter. The connector is not routed until route() is called. The corners of the connector will be rounded with a bend radius of 50.


ManhattanConnector

public ManhattanConnector(Site tail,
                          Site head,
                          ManhattanRouter router)
Create a new manhattan connector between the given sites and with the given router. The connector is drawn with a width of one and in black. The connector is routed between the head and tail sites. The corners of the connector will be rounded with a bend radius of 50.

Method Detail

getRouter

public ManhattanRouter getRouter()
Return the router.


getBendRadius

public double getBendRadius()
Return the maximum bend radius of the manhattan-routed edge. A value of zero means that the corners of the route are square; the larger the value, the more curvy the corners will be.


repositionLabel

public void repositionLabel()
Tell the connector to reposition the text label.

Specified by:
repositionLabel in class AbstractConnector

route

public void route()
Tell the connector to route itself between the current positions of the head and tail sites.

Specified by:
route in interface Connector
Specified by:
route in class AbstractConnector

setBendRadius

public void setBendRadius(double r)
Set the maximum bend radius of the manhattan-routed edge. A value of zero means that the corners of the route are square; the larger the value, the more curvy the corners will be.

See Also:
getBendRadius()

setRouter

public void setRouter(ManhattanRouter router)
Set the router and route again.


translate

public void translate(double x,
                      double y)
Translate the connector. This method is implemented, since controllers may wish to translate connectors when the sites at both ends are moved the same distance.

Specified by:
translate in interface Figure
Specified by:
translate in class AbstractConnector