polygon.lineTo(0, height / 2);
polygon.lineTo(-width / 2, 0);
polygon.lineTo(0, -height / 2);
polygon.closePath();
Figure figure = new BasicFigure(polygon, Color.black);
if (node != null) {
ActorGraphModel model = (ActorGraphModel) getController()
.getGraphModel();
figure
.setToolTipText(relation.getName(model
.getPtolemyModel()));
// Old way to set the color.
try {
StringAttribute colorAttr = (StringAttribute) (relation
.getAttribute("_color", StringAttribute.class));
if (colorAttr != null) {
String color = colorAttr.getExpression();
((BasicFigure) figure).setFillPaint(SVGUtilities
.getColor(color));
}
} catch (IllegalActionException e) {
// Ignore.
}
// New way to set the color
try {
ColorAttribute colorAttr = (ColorAttribute) (relation
.getAttribute("_color", ColorAttribute.class));
if (colorAttr != null) {
Color color = colorAttr.asColor();
((BasicFigure) figure).setFillPaint(color);
}
} catch (IllegalActionException e) {
// Ignore.
}
}
CompositeFigure result = new CompositeFigure(figure);
if (relation instanceof IORelation) {
if (((IORelation) relation).getWidth() > 1) {
// Restore width and height to the default to get a reasonable slash.
width = 12.0;
height = 12.0;
Line2D.Double line = new Line2D.Double(-width / 2,
height / 2, width / 2, -height / 2);
Figure lineFigure = new BasicFigure(line, Color.black);
result.add(lineFigure);
LabelFigure label = new LabelFigure(""
+ ((IORelation) relation).getWidth(),
_relationLabelFont, 0, SwingConstants.SOUTH_WEST);