ptolemy.vergil.icon
Class TextIcon

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.DynamicEditorIcon
                  extended by ptolemy.vergil.icon.TextIcon
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class TextIcon
extends DynamicEditorIcon

An icon that displays specified text.

Since:
Ptolemy II 4.0
Version:
$Id: TextIcon.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
private  int _anchor
           
private  java.lang.String _DEFAULT_TEXT
           
private  java.awt.Font _font
           
private  java.lang.String _iconText
           
private  java.lang.String _text
           
private  java.awt.Color _textColor
           
 
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
TextIcon(NamedObj container, java.lang.String name)
          Create a new icon with the given name in the given container.
 
Method Summary
 java.lang.Object clone(Workspace workspace)
          Clone the object into the specified workspace.
 Figure createBackgroundFigure()
          Create a new default background figure, which is the text set by setText, if it has been called, or default text if not.
 javax.swing.Icon createIcon()
          Create a new Swing icon.
 void setAnchor(int anchor)
          Specify origin of the text.
 void setFont(java.awt.Font font)
          Specify the font to use.
 void setIconText(java.lang.String text)
          Specify the text to display in the icon.
 void setText(java.lang.String text)
          Specify text to display.
 void setTextColor(java.awt.Color textColor)
          Specify the text color to use.
 
Methods inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_addLiveFigure, _liveFigureIterator, _trimLiveFigures
 
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _isPropertySet, _recreateFigure, 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, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, 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

_DEFAULT_TEXT

private java.lang.String _DEFAULT_TEXT

_anchor

private int _anchor

_font

private java.awt.Font _font

_iconText

private java.lang.String _iconText

_text

private java.lang.String _text

_textColor

private java.awt.Color _textColor
Constructor Detail

TextIcon

public TextIcon(NamedObj container,
                java.lang.String name)
         throws IllegalActionException,
                NameDuplicationException
Create a new icon with the given name in the given container.

Parameters:
container - The container.
name - The name of the attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

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 class DynamicEditorIcon
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 new default background figure, which is the text set by setText, if it has been called, or default text if not. This must be called in the Swing thread, or a concurrent modification exception could occur.

Overrides:
createBackgroundFigure in class EditorIcon
Returns:
A figure representing the specified shape.

createIcon

public javax.swing.Icon createIcon()
Create a new Swing icon. This returns an icon with the text "-A-", or if it has been called, the text specified by setIconText().

Overrides:
createIcon in class EditorIcon
Returns:
A new Swing Icon.
See Also:
setIconText(String)

setAnchor

public void setAnchor(int anchor)
Specify origin of the text. The anchor should be one of the constants defined in SwingConstants.

Parameters:
anchor - The anchor of the text.

setFont

public void setFont(java.awt.Font font)
Specify the font to use. This is deferred and executed in the Swing thread.

Parameters:
font - The font to use.

setIconText

public void setIconText(java.lang.String text)
Specify the text to display in the icon. If this is not called, then the text displayed is "-A-".

Parameters:
text - The text to display in the icon.

setText

public void setText(java.lang.String text)
Specify text to display. This is deferred and executed in the Swing thread.

Parameters:
text - The text to display.

setTextColor

public void setTextColor(java.awt.Color textColor)
Specify the text color to use. This is deferred and executed in the Swing thread.

Parameters:
textColor - The fill color to use.