*/
public void route() {
repaint();
TransformContext currentContext = getTransformContext();
Site headSite = getHeadSite();
Site tailSite = getTailSite();
Figure tailFigure = tailSite.getFigure();
Figure headFigure = headSite.getFigure();
Point2D headPt;
Point2D tailPt;
// Get the transformed head and tail points. Sometimes
// people will call this before the connector is added
// to a container, so deal with it
if (currentContext != null) {
tailPt = tailSite.getPoint(currentContext);
headPt = headSite.getPoint(currentContext);
} else {
tailPt = tailSite.getPoint();
headPt = headSite.getPoint();
}
// Figure out the centers of the attached figures
Point2D tailCenter;
// Figure out the centers of the attached figures
Point2D headCenter;
if (tailFigure != null) {
tailCenter = CanvasUtilities.getCenterPoint(tailFigure,
currentContext);
} else {
tailCenter = tailPt;
}
if (headFigure != null) {
headCenter = CanvasUtilities.getCenterPoint(headFigure,
currentContext);
} else {
headCenter = headPt;
}
// Change self-loop mode if necessary
boolean selfloop = _selfloop;
if ((tailFigure != null) && (headFigure != null)) {
selfloop = (tailFigure == headFigure);
}
if (selfloop && !_selfloop) {
setSelfLoop(true);
} else if (!selfloop && _selfloop) {
setSelfLoop(false);
}
// Figure out the angle between the centers. If a selfloop,
// use the angle that was previously stored.
double gamma;
double x = headCenter.getX() - tailCenter.getX();
double y = headCenter.getY() - tailCenter.getY();
if (_selfloop) {
gamma = _gamma;
} else {
gamma = Math.atan2(y, x);
}
// Tell the sites to adjust their positions
double alpha = _exitAngle;
double beta = (Math.PI / 2.0) - alpha;
double headNormal = gamma - alpha - Math.PI;
double tailNormal = gamma + alpha;
tailSite.setNormal(tailNormal);
headSite.setNormal(headNormal);
// Recompute the head and tail points
if (currentContext != null) {
tailPt = tailSite.getPoint(currentContext);
headPt = headSite.getPoint(currentContext);
} else {
tailPt = tailSite.getPoint();
headPt = headSite.getPoint();
}
// Adjust for decorations on the ends
if (getHeadEnd() != null) {