String name = container.getDisplayName();
// Do not add a label figure if the name is null.
if ((name != null) && !name.equals("")) {
if (!_isPropertySet(container, "_centerName")) {
LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
SwingConstants.SOUTH_WEST);
// Shift the label slightly right so it doesn't
// collide with ports.
label.translateTo(backBounds.getX() + 5, backBounds.getY());
figure.add(label);
} else {
LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
SwingConstants.CENTER);
label.translateTo(backBounds.getCenterX(), backBounds
.getCenterY());
figure.add(label);
}
}
}
// If specified by a preference, then show parameters.
Token show = PtolemyPreferences.preferenceValueLocal(container,
"_showParameters");
if (show instanceof StringToken) {
String value = ((StringToken) show).stringValue();
boolean showOverriddenParameters = value
.equals("Overridden parameters only");
boolean showAllParameters = value.equals("All");
if ((showOverriddenParameters && !_isPropertySet(container,
"_hideAllParameters"))
|| showAllParameters) {
StringBuffer parameters = new StringBuffer();
Iterator settables = container.attributeList(Settable.class)
.iterator();
while (settables.hasNext()) {
Settable settable = (Settable) settables.next();
if (settable.getVisibility() != Settable.FULL) {
continue;
}
if (!showAllParameters
&& !((NamedObj) settable).isOverridden()) {
continue;
}
if (!showAllParameters
&& _isPropertySet((NamedObj) settable, "_hide")) {
continue;
}
String name = settable.getName();
String displayName = settable.getDisplayName();
parameters.append(displayName);
if (showAllParameters && !name.equals(displayName)) {
parameters.append(" (" + name + ")");
}
parameters.append(": ");
parameters.append(settable.getExpression());
if (settables.hasNext()) {
parameters.append("\n");
}
}
LabelFigure label = new LabelFigure(parameters.toString(),
_parameterFont, 1.0, SwingConstants.NORTH_WEST);
// Shift the label slightly right so it doesn't
// collide with ports.
label.translateTo(backBounds.getX() + 5, backBounds.getY()
+ backBounds.getHeight());
figure.add(label);
}
}