protected RotateOrFlipPorts _rotatePortsCounterclockwise = new RotateOrFlipPorts(
RotateOrFlipPorts.COUNTERCLOCKWISE, "Rotate Ports Counterclockwise");
private LabelFigure _createPortLabelFigure(String string, Font font,
double x, double y, int direction) {
LabelFigure label;
if (direction == SwingConstants.SOUTH) {
// The 1.0 argument is the padding.
label = new LabelFigure(string, font, 1.0,
SwingConstants.SOUTH_WEST);
// Shift the label down so it doesn't
// collide with ports.
label.translateTo(x, y + 5);
// Rotate the label.
AffineTransform rotate = AffineTransform.getRotateInstance(
Math.PI / 2.0, x, y + 5);
label.transform(rotate);
} else if (direction == SwingConstants.EAST) {
// The 1.0 argument is the padding.
label = new LabelFigure(string, font, 1.0,
SwingConstants.SOUTH_WEST);
// Shift the label right so it doesn't
// collide with ports.
label.translateTo(x + 5, y);
} else if (direction == SwingConstants.WEST) {
// The 1.0 argument is the padding.
label = new LabelFigure(string, font, 1.0,
SwingConstants.SOUTH_EAST);
// Shift the label left so it doesn't
// collide with ports.
label.translateTo(x - 5, y);
} else { // Must be north.
// The 1.0 argument is the padding.
label = new LabelFigure(string, font, 1.0,
SwingConstants.SOUTH_WEST);
// Shift the label right so it doesn't
// collide with ports. It will probably
// collide with the actor name.
label.translateTo(x, y - 5);
// Rotate the label.
AffineTransform rotate = AffineTransform.getRotateInstance(
-Math.PI / 2.0, x, y - 5);
label.transform(rotate);
}
return label;
}