Package ptolemy.vergil.icon
Class XMLIcon
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.vergil.icon.EditorIcon
-
- ptolemy.vergil.icon.DynamicEditorIcon
-
- ptolemy.vergil.icon.XMLIcon
-
- All Implemented Interfaces:
java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,IconAttribute
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,ValueListener
- Direct Known Subclasses:
AttributeValueIcon
,BoxedValuesIcon
,CopyCatIcon
,IterativeParameterIcon
,ValueIcon
public class XMLIcon extends DynamicEditorIcon implements ValueListener
An icon is a visual representation of an entity. Three such visual representations are supported here. A background figure is returned by the createBackgroundFigure() method. This figure is specified by an attribute named "_iconDescription" of the container, if there is one. If there is no such attribute, then a default icon is used. The createFigure() method returns this same background figure, but decorated with a label giving the name of the container, unless the container contains a parameter named "_hideName" with value true. The createIcon() method returns a Swing icon given by an attribute named "_smallIconDescription", if there is one. If there is no such attribute, then the icon is simply a small representation of the background figure.The XML schema used in the "_iconDescription" and "_smallIconDescription" attributes is SVG (scalable vector graphics), although currently Diva only supports a small subset of SVG.
- Since:
- Ptolemy II 2.0
- Version:
- $Id$
- Author:
- Steve Neuendorffer, John Reekie, Contributors: Edward A. Lee, Chad Berkley (Kepler)
- Pt.AcceptedRating:
- Red (johnr)
- Pt.ProposedRating:
- Yellow (neuendor)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_description(int detail, int indent, int bracket)
Return a description of the object.protected void
_recreateFigure()
Recreate the figure.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.Figure
createBackgroundFigure()
Create a background figure based on this icon.javax.swing.Icon
createIcon()
Create a new Swing icon.static XMLIcon
getXMLIcon(NamedObj container, java.lang.String name)
Instantiate an XMLIcon in a NamedObj.static XMLIcon
getXMLIcon(Workspace workspace, java.lang.String name)
Instantiate an XMLIcon in a Workspace.PaintedList
paintedList()
Return the painted list contained by this icon.java.lang.String
toString()
Return a string representing this Icon.void
valueChanged(Settable settable)
React to the fact that the value of an attribute named "_iconDescription" contained by the same container has changed value by redrawing the figure.-
Methods inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_addLiveFigure, _liveFigureIterator, _trimLiveFigures
-
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _isPropertySet, createFigure, 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
-
-
-
-
Constructor Detail
-
XMLIcon
public XMLIcon(Workspace workspace, java.lang.String name) throws IllegalActionException
Construct an icon in the specified workspace and name. This constructor is typically used in conjunction with setContainerToBe() and createFigure() to create an icon and generate a figure without having to have write access to the workspace. If the workspace argument is null, then use the default workspace. The object is added to the directory of the workspace.- Parameters:
workspace
- The workspace that will list the attribute.name
- The name of this attribute.- Throws:
IllegalActionException
- If the specified name contains a period.- See Also:
Increment the version number of the workspace.
-
XMLIcon
public XMLIcon(NamedObj container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Create a new icon with the given name in the given container. By default, the icon contains no graphic objects.- 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
-
getXMLIcon
public static XMLIcon getXMLIcon(NamedObj container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Instantiate an XMLIcon in a NamedObj.This method looks for the _alternateXMLIcon attribute in the configuration. If it is found, it returns an XMLIcon of the class found there, if not, it returns an instance of this class.
- Parameters:
container
- The container for this attribute.name
- The name of this attribute.- Returns:
- an instance of the XMLIcon class.
- Throws:
NameDuplicationException
- If an object with that name already exists in the container.IllegalActionException
- If the specified name contains a period.
-
getXMLIcon
public static XMLIcon getXMLIcon(Workspace workspace, java.lang.String name) throws NameDuplicationException, IllegalActionException
Instantiate an XMLIcon in a Workspace.This method looks for the _alternateXMLIcon attribute in the configuration. If it is found, it returns an XMLIcon of the class found there, if not, it returns an instance of this class.
- Parameters:
workspace
- The workspace that will list the attribute.name
- The name of this attribute.- Returns:
- an instance of the XMLIcon class.
- Throws:
NameDuplicationException
- If an object with that name already exists in the container.IllegalActionException
- If the specified name contains a period.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.- Overrides:
clone
in classDynamicEditorIcon
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- The new Attribute.
- Throws:
java.lang.CloneNotSupportedException
- Not thrown in this base class- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
createBackgroundFigure
public Figure createBackgroundFigure()
Create a background figure based on this icon. The background figure will be painted with each graphic element that this icon contains.- Overrides:
createBackgroundFigure
in classEditorIcon
- Returns:
- A figure for this icon.
-
createIcon
public javax.swing.Icon createIcon()
Create a new Swing icon. This class looks for an attribute called "_smallIconDescription", and if it exists, uses it to create the icon. If it does not exist, then it simply creates a small version of the background figure returned by createBackgroundFigure().- Overrides:
createIcon
in classEditorIcon
- Returns:
- A new Swing Icon.
-
paintedList
public PaintedList paintedList()
Return the painted list contained by this icon. This is used by the icon editor.- Returns:
- The painted list contained by this icon.
-
toString
public java.lang.String toString()
Return a string representing this Icon.
-
valueChanged
public void valueChanged(Settable settable)
React to the fact that the value of an attribute named "_iconDescription" contained by the same container has changed value by redrawing the figure.- Specified by:
valueChanged
in interfaceValueListener
- Parameters:
settable
- The object that has changed value.
-
_description
protected java.lang.String _description(int detail, int indent, int bracket) throws IllegalActionException
Return a description of the object. Lines are indented according to to the level argument using the protected method _getIndentPrefix(). Zero, one or two brackets can be specified to surround the returned description. If one is specified it is the the leading bracket. This is used by derived classes that will append to the description. Those derived classes are responsible for the closing bracket. An argument other than 0, 1, or 2 is taken to be equivalent to 0. This method is read-synchronized on the workspace.- Overrides:
_description
in classNamedObj
- Parameters:
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).- Returns:
- A description of the object.
- Throws:
IllegalActionException
-
_recreateFigure
protected void _recreateFigure()
Recreate the figure. Call to cause createIcon() to call createBackgroundFigure() to obtain a new figure.- Overrides:
_recreateFigure
in classEditorIcon
-
-