Package ptolemy.vergil.icon
Class NameIcon
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.vergil.icon.EditorIcon
-
- ptolemy.vergil.icon.NameIcon
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,IconAttribute
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
ConceptIcon
,DesignPatternIcon
,OctagonEventIcon
,StateIcon
,TestIcon
public class NameIcon extends EditorIcon
An icon that displays the name of the container in an appropriately sized box. Put this into a composite actor or in any actor to convert the icon for that actor into a simple box with the name of the actor instance. You will probably also want to set the actor instance to not display its name above its icon. You can do that via the Customize Name dialog (obtained by right clicking on the icon) or by creating a parameter named "_hideName" with value true.- Since:
- Ptolemy II 5.2
- 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.protected double
_roundingValue
Most recent value of the rounding parameter.protected double
_spacingValue
Most recent value of the spacing parameter.protected double
_xPadding
The horizontal padding on the left and right sides of the name.protected double
_yPadding
The vertical padding above and below the name.ColorAttribute
color
The background color to use in the box.Parameter
rounding
The amount of rounding of the corners.Parameter
spacing
If greater than zero, then use a double box where the outside one is the specified size larger than the inside one.-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.geom.Point2D
_getBackgroundSize()
Return the background size.protected java.awt.Paint
_getFill()
Return the paint to use to fill the icon.protected LabelFigure
_getLabel(CompositeFigure background, java.lang.String name)
Get the label to put on the specified background figure based on the specified name.protected float
_getLineWidth()
Return the line width to use in rendering the box.void
attributeChanged(Attribute attribute)
React to a changes in the attributes by changing the icon.Figure
createBackgroundFigure()
Create a new background figure.Figure
createFigure()
Create a new Diva figure that visually represents this icon.javax.swing.Icon
createIcon()
Create an icon.void
setContainer(NamedObj container)
Override the base class to add or set a _hideName parameter.-
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _isPropertySet, _recreateFigure, clone, getContainerOrContainerToBe, setContainerToBe
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, 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, toString, uniqueName, validateSettables, workspace
-
-
-
-
Field Detail
-
color
public ColorAttribute color
The background color to use in the box. This defaults to white.
-
rounding
public Parameter rounding
The amount of rounding of the corners. This is a double that defaults to 0.0, which indicates no rounding.
-
spacing
public Parameter spacing
If greater than zero, then use a double box where the outside one is the specified size larger than the inside one. This is a double that defaults to 0.0, which indicates a single box.
-
_labelFont
protected static final java.awt.Font _labelFont
The font used.
-
_roundingValue
protected double _roundingValue
Most recent value of the rounding parameter.
-
_spacingValue
protected double _spacingValue
Most recent value of the spacing parameter.
-
_xPadding
protected double _xPadding
The horizontal padding on the left and right sides of the name.
-
_yPadding
protected double _yPadding
The vertical padding above and below the name.
-
-
Constructor Detail
-
NameIcon
public NameIcon(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 attribute.NameDuplicationException
- If the name coincides with an attribute already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to a changes in the attributes by changing the icon.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (should not be thrown).
-
createBackgroundFigure
public Figure createBackgroundFigure()
Create a new background figure. This overrides the base class to draw a box around the value display, where the width of the box depends on the value.- Overrides:
createBackgroundFigure
in classEditorIcon
- Returns:
- A new figure.
-
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 name of the container.- Overrides:
createFigure
in classEditorIcon
- Returns:
- A new CompositeFigure consisting of the label.
-
createIcon
public javax.swing.Icon createIcon()
Create an icon.- Overrides:
createIcon
in classEditorIcon
- Returns:
- The icon.
-
setContainer
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException
Override the base class to add or set a _hideName parameter.- Overrides:
setContainer
in classAttribute
- Parameters:
container
- The container to attach this attribute to..- Throws:
IllegalActionException
- If this attribute is not of the expected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.NameDuplicationException
- If the container already has an attribute with the name of this attribute.- See Also:
Attribute.getContainer()
-
_getBackgroundSize
protected java.awt.geom.Point2D _getBackgroundSize()
Return the background size.- Returns:
- the background size.
-
_getFill
protected java.awt.Paint _getFill()
Return the paint to use to fill the icon. This base class returns the value of the color attribute.- Returns:
- The paint to use to fill the icon.
-
_getLabel
protected LabelFigure _getLabel(CompositeFigure background, java.lang.String name)
Get the label to put on the specified background figure based on the specified name.- Parameters:
background
- The background figure on which to put the label.name
- The name on which to base the label.- Returns:
- The label figure.
-
_getLineWidth
protected float _getLineWidth()
Return the line width to use in rendering the box. This base class returns 1.0f.- Returns:
- The line width to use in rendering the box.
-
-