ptolemy.vergil.icon
Class NameIcon

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.vergil.icon.EditorIcon
              extended by ptolemy.vergil.icon.NameIcon
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
DesignPatternIcon, OctagonEventIcon, StateIcon, 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: NameIcon.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
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.
 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, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
NameIcon(NamedObj container, java.lang.String name)
          Create a new icon with the given name in the given container.
 
Method Summary
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  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.
 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, createIcon, 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, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, 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, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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 class NamedObj
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 class EditorIcon
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 class EditorIcon
Returns:
A new CompositeFigure consisting of the label.

setContainer

public void setContainer(NamedObj container)
                  throws IllegalActionException,
                         NameDuplicationException
Override the base class to add or set a _hideName parameter.

Overrides:
setContainer in class Attribute
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 Color.white.

Returns:
The paint to use to fill the icon.

_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.