* @param headSite The head site.
* @return The Connector that represents the edge.
*/
public Connector render(Object edge, Site tailSite, Site headSite) {
Link link = (Link) edge;
ManhattanConnector connector = new LinkManhattanConnector(tailSite,
headSite, link);
if ((link.getHead() != null) && (link.getTail() != null)) {
connector.setLineWidth((float) 2.0);
}
connector.setUserObject(edge);
// The default bend radius of 50 is too large...
// parallel curves look bad.
connector.setBendRadius(20);
Relation relation = link.getRelation();
if (relation != null) {
String tipText = relation.getName();
String displayName = relation.getDisplayName();
if (!tipText.equals(displayName)) {
tipText = displayName + " (" + tipText + ")";
}
connector.setToolTipText(tipText);
try {
// FIXME: This isn't quite right for relation groups.
StringAttribute colorAttribute = (StringAttribute) (relation
.getAttribute("_color", StringAttribute.class));
if (colorAttribute != null) {
String color = colorAttribute.getExpression();
if (color != null && !color.trim().equals("")) {
connector.setStrokePaint(SVGUtilities
.getColor(color));
}
}
} catch (IllegalActionException e) {
// Ignore;
}
try {
// FIXME: This isn't quite right for relation groups.
ColorAttribute colorAttribute = (ColorAttribute) (relation
.getAttribute("color", ColorAttribute.class));
if (colorAttribute != null) {
Color color = colorAttribute.asColor();
connector.setStrokePaint(color);
}
} catch (IllegalActionException e) {
// Ignore;
}
StringAttribute _explAttr = (StringAttribute) (relation
.getAttribute("_explanation"));
if (_explAttr != null) {
connector.setToolTipText(_explAttr.getExpression());
}
// NOTE: The preferences mechanism may set this.
Token radiusValue = PtolemyPreferences.preferenceValue(
relation, "_linkBendRadius");
if (radiusValue instanceof DoubleToken) {
double overrideRadius = ((DoubleToken) radiusValue)
.doubleValue();
connector.setBendRadius(overrideRadius);
}
}
return connector;
}