// compose their background figures to make this one.
CompositeFigure figure = null;
Iterator attributes = attributeList().iterator();
while (attributes.hasNext()) {
Attribute attribute = (Attribute) attributes.next();
// There is a level of indirection where the "subIcon" is a
// "visible attribute" containing an attribute named "_icon"
// that actually has the icon.
Iterator subIcons = attribute.attributeList(EditorIcon.class)
.iterator();
while (subIcons.hasNext()) {
EditorIcon subIcon = (EditorIcon) subIcons.next();
if (figure == null) {
// NOTE: This used to use a constructor that
// takes a "background figure" argument, which would
// then treat this first figure specially. This is not
// right since getShape() on the figure will then return
// only the shape of the composite, which results in the
// wrong selection region being highlighted.
figure = new CompositeFigure();
}
Figure subFigure = subIcon.createBackgroundFigure();
// Translate the figure to the location of the subfigure,
// if there is a location. Also, center it if necessary.
try {
// NOTE: This is inelegant, but only the subclasses
// have the notion of centering.
// FIXME: Don't use FilledShapeAttribute... promote
// centered capability to a base class.
if (attribute instanceof FilledShapeAttribute
&& subFigure instanceof BasicFigure) {
boolean centeredValue = ((BooleanToken) ((FilledShapeAttribute) attribute).centered
.getToken()).booleanValue();
if (centeredValue) {
((BasicFigure) subFigure).setCentered(true);
}
}
Locatable location = (Locatable) attribute.getAttribute(
"_location", Locatable.class);
if (location != null) {
double[] locationValue = location.getLocation();
CanvasUtilities.translateTo(subFigure,