Package ptolemy.vergil.icon
Class ImageIcon
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.vergil.icon.EditorIcon
-
- ptolemy.vergil.icon.DynamicEditorIcon
-
- ptolemy.vergil.icon.ImageIcon
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.lang.Cloneable
,Changeable
,Debuggable
,DebugListener
,Derivable
,IconAttribute
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class ImageIcon extends DynamicEditorIcon implements java.awt.image.ImageObserver
An icon that displays a specified java.awt.Image.- Since:
- Ptolemy II 4.0
- 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 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 Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.Figure
createBackgroundFigure()
Create a new default background figure, which is scaled image, if it has been set, or a default image if not.javax.swing.Icon
createIcon()
Create a new Swing icon.boolean
imageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height)
This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.void
scaleImage(double percentage)
Specify a scaling for the image as a percentage.void
setImage(java.awt.Image image)
Specify an image to display.-
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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _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, toString, uniqueName, validateSettables, workspace
-
-
-
-
Constructor Detail
-
ImageIcon
public ImageIcon(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 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 new default background figure, which is scaled image, if it has been set, or a default image if not. This must be called in the Swing thread, or a concurrent modification exception could occur.- Overrides:
createBackgroundFigure
in classEditorIcon
- Returns:
- A figure representing the specified shape.
-
createIcon
public javax.swing.Icon createIcon()
Create a new Swing icon. This overrides the base class to wait until image has been rendered. Otherwise, we get a null pointer exception in Diva, and also the library collapses and has to be re-opened.- Overrides:
createIcon
in classEditorIcon
- Returns:
- A new Swing Icon.
-
imageUpdate
public boolean imageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height)
This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.- Specified by:
imageUpdate
in interfacejava.awt.image.ImageObserver
- Parameters:
image
- The image being observed.infoflags
- The bitwise inclusive OR of the following flags: WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.x
- The x coordinate of the image.y
- The y coordinate of the image.width
- The width of the image.height
- The height of the image.- Returns:
- False if the infoflags indicate that the image is completely loaded; true otherwise.
-
scaleImage
public void scaleImage(double percentage)
Specify a scaling for the image as a percentage.- Parameters:
percentage
- The scaling percentage.
-
setImage
public void setImage(java.awt.Image image)
Specify an image to display. Note that this does not actually result in the image displaying. You must call scaleImage().- Parameters:
image
- The image to display.
-
-