ptolemy.vergil.icon
Class ShapeIcon

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.vergil.icon.EditorIcon
              extended byptolemy.vergil.icon.DynamicEditorIcon
                  extended byptolemy.vergil.icon.ShapeIcon
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable

public class ShapeIcon
extends DynamicEditorIcon

An icon that displays a specified java.awt.Shape.

Since:
Ptolemy II 4.0
Version:
$Id: ShapeIcon.java,v 1.26 2004/04/14 19:08:07 neuendor Exp $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (johnr)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 
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, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
ShapeIcon(NamedObj container, java.lang.String name)
          Create a new icon with the given name in the given container.
ShapeIcon(NamedObj container, java.lang.String name, java.awt.Shape defaultShape)
          Create a new icon with the given name in the given container with the given default shape.
 
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 shape set by setShape, if it has been called, or a small box if not.
 boolean isCentered()
          Return whether the figure should be centered on its origin.
 void setCentered(boolean centered)
          Specify whether the figure should be centered or not.
 void setFillColor(java.awt.Color fillColor)
          Specify the fill color to use.
 void setLineColor(java.awt.Color lineColor)
          Specify the line color to use.
 void setLineWidth(float lineWidth)
          Specify the line width to use.
 void setShape(java.awt.Shape path)
          Specify a path to display.
 
Methods inherited from class ptolemy.vergil.icon.DynamicEditorIcon
_addLiveFigure, _liveFigureIterator, _trimLiveFigures
 
Methods inherited from class ptolemy.vergil.icon.EditorIcon
_createDefaultBackgroundFigure, _recreateFigure, createFigure, createIcon, exportMoML, getContainerOrContainerToBe, setContainerToBe
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, getContainer, setContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShapeIcon

public ShapeIcon(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.

ShapeIcon

public ShapeIcon(NamedObj container,
                 java.lang.String name,
                 java.awt.Shape defaultShape)
          throws IllegalActionException,
                 NameDuplicationException
Create a new icon with the given name in the given container with the given default shape.

Parameters:
container - The container.
name - The name of the attribute.
defaultShape - The default shape.
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

createBackgroundFigure

public Figure createBackgroundFigure()
Create a new default background figure, which is the shape set by setShape, if it has been called, or a small box 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.

isCentered

public boolean isCentered()
Return whether the figure should be centered on its origin.

Returns:
False If the origin of the figure, as returned by getOrigin(), is the upper left corner.

setCentered

public void setCentered(boolean centered)
Specify whether the figure should be centered or not. By default, the origin of the figure is the center. This is deferred and executed in the Swing thread.

Parameters:
centered - False to make the figure's origin at the upper left.

setFillColor

public void setFillColor(java.awt.Color fillColor)
Specify the fill color to use. This is deferred and executed in the Swing thread.

Parameters:
fillColor - The fill color to use.

setLineColor

public void setLineColor(java.awt.Color lineColor)
Specify the line color to use. This is deferred and executed in the Swing thread.

Parameters:
lineColor - The line color to use.

setLineWidth

public void setLineWidth(float lineWidth)
Specify the line width to use. This is deferred and executed in the Swing thread.

Parameters:
lineWidth - The line width to use.

setShape

public void setShape(java.awt.Shape path)
Specify a path to display. This is deferred and executed in the Swing thread.

Parameters:
path - The path to display.