Package ptolemy.vergil.icon
Class AttributeValueIcon
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.vergil.icon.EditorIcon
-
- ptolemy.vergil.icon.DynamicEditorIcon
-
- ptolemy.vergil.icon.XMLIcon
-
- ptolemy.vergil.icon.AttributeValueIcon
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,IconAttribute
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,ValueListener
- Direct Known Subclasses:
BoxedValueIcon
,UpdatedValueIcon
public class AttributeValueIcon extends XMLIcon
An icon that displays the value of an attribute of the container or of some other entity contained by the container. The attribute is assumed to be an instance of Settable, and its name is given by the parameter attributeName. The display is not automatically updated when the attribute value is updated.- Since:
- Ptolemy II 2.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.awt.Font
_labelFont
The font used.StringAttribute
attributeName
The name of the attribute of the container whose value to display.Parameter
displayHeight
The maximum number of lines to display.Parameter
displayWidth
The number of characters to display.StringParameter
entityName
Name of the entity contained by the container whose attribute this icon will display.-
Fields inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_figures
-
Fields inherited from class ptolemy.vergil.icon.EditorIcon
_containerToBe, _iconCache
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description AttributeValueIcon(NamedObj container, java.lang.String name)
Create a new icon with the given name in the given container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Settable
_associatedAttribute()
Return the associated attribute.protected java.lang.String
_attributeValueString()
Get the string value of the attribute to render in the icon.protected java.lang.String
_displayString()
Get the string to render in the icon.Figure
createFigure()
Create a new Diva figure that visually represents this icon.-
Methods inherited from class ptolemy.vergil.icon.XMLIcon
_description, _recreateFigure, clone, createBackgroundFigure, createIcon, getXMLIcon, getXMLIcon, paintedList, toString, valueChanged
-
Methods inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_addLiveFigure, _liveFigureIterator, _trimLiveFigures
-
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _isPropertySet, getContainerOrContainerToBe, setContainerToBe
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setContainer, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
-
-
-
Field Detail
-
attributeName
public StringAttribute attributeName
The name of the attribute of the container whose value to display. This is a string that by default is empty. An empty string means that the attribute whose value to display is the container itself, rather than an attribute contained by the container.
-
displayHeight
public Parameter displayHeight
The maximum number of lines to display. This is an integer, with default value 1.
-
displayWidth
public Parameter displayWidth
The number of characters to display. This is an integer, with default value 6.
-
entityName
public StringParameter entityName
Name of the entity contained by the container whose attribute this icon will display. This is a string that defaults to the empty string, which means that the attribute is contained by the container of this attribute.
-
_labelFont
protected static final java.awt.Font _labelFont
The font used.
-
-
Constructor Detail
-
AttributeValueIcon
public AttributeValueIcon(NamedObj container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Create a new icon with the given name in the given container. The container is required to implement Settable, or an exception will be thrown.- Parameters:
container
- The container for this attribute.name
- The name of this attribute.- Throws:
IllegalActionException
- If thrown by the parent class or while setting an attributeNameDuplicationException
- If the name coincides with an attribute already in the container.
-
-
Method Detail
-
createFigure
public Figure createFigure()
Create a new Diva figure that visually represents this icon. The figure will be an instance of LabelFigure that renders the value of the specified attribute of the container.- Overrides:
createFigure
in classEditorIcon
- Returns:
- A new CompositeFigure consisting of the label.
-
_associatedAttribute
protected Settable _associatedAttribute() throws IllegalActionException
Return the associated attribute. If anentityName
is given, then the associated attribute is attribute with name given byattributeName
contained by the specified entity. If no entityName is given, then the associated attribute is the one contained by the container of this object with the specified name. If no attributeName is given either, and the the container of this object is an Attribute, then the associated attribute is that container. Otherwise, throw an exception.- Returns:
- The associated attribute.
- Throws:
IllegalActionException
- If no Settable associated attribute can be found.
-
_attributeValueString
protected java.lang.String _attributeValueString()
Get the string value of the attribute to render in the icon. This string is the expression giving the value of the attribute of the container having the name attributeName. If the string is empty, then return a string with one space (diva fails on empty strings). This method will always return the full string value of the attribute and will not be truncated.- Returns:
- The string value of the attribute to display, or a string with one space if none is found.
-
_displayString
protected java.lang.String _displayString()
Get the string to render in the icon. This string is the expression giving the value of the attribute of the container having the name attributeName, truncated so that it is no longer than displayWidth characters. If it is truncated, then the string has a trailing "...". If the string is empty, then return a string with one space (diva fails on empty strings).- Returns:
- The string to display, or a string with one space if none is found.
-
-