ptolemy.actor.gui
Class EffigyFactory

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.kernel.CompositeEntity
                      extended byptolemy.actor.gui.EffigyFactory
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable
Direct Known Subclasses:
BrowserEffigy.Factory, HSIFEffigyFactory, HTMLEffigyFactory, NavigableEffigy.Factory, PlotEffigy.Factory, PtolemyEffigy.Factory, TextEffigy.Factory, TokenEffigy.Factory

public class EffigyFactory
extends CompositeEntity

A configuration contains an instance of this class, and uses it to create effigies from a URL, or to create blank effigies of a particular kind. This base class assumes that it contains other effigy factories. Its createEffigy() methods defer to each contained factory in order until one is capable of creating an effigy. Subclasses of this class will usually be inner classes of an Effigy and will create the Effigy, or they might themselves be aggregates of instances of EffigyFactory.

Since:
Ptolemy II 1.0
Version:
$Id: EffigyFactory.java,v 1.18 2004/04/13 05:12:06 cxh Exp $
Author:
Steve Neuendorffer and Edward A. Lee
See Also:
Configuration, Effigy, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
 
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
EffigyFactory(CompositeEntity container, java.lang.String name)
          Create a factory with the given name and container.
EffigyFactory(Workspace workspace)
          Create a factory in the specified workspace.
 
Method Summary
 boolean canCreateBlankEffigy()
          Return true if this effigy factory is capable of creating an effigy without a URL being specified.
 Effigy createEffigy(CompositeEntity container)
          Create a new blank effigy in the given container.
 Effigy createEffigy(CompositeEntity container, java.net.URL base, java.net.URL in)
          Create a new effigy in the given container by reading the specified URL.
static java.lang.String getExtension(java.net.URL url)
          Return the extension on the name of the specified URL.
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_addEntity, _addRelation, _adjustDeferrals, _description, _exportMoMLContents, _finishedAddEntity, _removeEntity, _removeRelation, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, clone, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, entityList, entityList, exportLinks, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, isOpaque, newRelation, numberOfClassDefinitions, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, newPort, propagateExistence, setContainer, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Constructor Detail

EffigyFactory

public EffigyFactory(Workspace workspace)
Create a factory in the specified workspace.

Parameters:
workspace - The workspace.

EffigyFactory

public EffigyFactory(CompositeEntity container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Create a factory with the given name and container.

Parameters:
container - The container.
name - The name.
Throws:
IllegalActionException - If the container is incompatible with this entity.
NameDuplicationException - If the name coincides with an entity already in the container.
Method Detail

canCreateBlankEffigy

public boolean canCreateBlankEffigy()
Return true if this effigy factory is capable of creating an effigy without a URL being specified. That is, it is capable of creating a blank effigy with no model data. In this base class, this method returns true if at least one contained effigy factory returns true.

Returns:
True if this factory can create a blank effigy.

createEffigy

public Effigy createEffigy(CompositeEntity container)
                    throws java.lang.Exception
Create a new blank effigy in the given container. This base class defers to each contained effigy factory until one returns an effigy. If there are no contained effigies, or if none returns an effigy, then this method returns null. Subclasses will override this method to create an effigy of an appropriate type.

Parameters:
container - The container for the effigy.
Returns:
A new effigy.
Throws:
java.lang.Exception - If the effigy created by one of the contained factories is incompatible with the specified container, or a name duplication occurs.

createEffigy

public Effigy createEffigy(CompositeEntity container,
                           java.net.URL base,
                           java.net.URL in)
                    throws java.lang.Exception
Create a new effigy in the given container by reading the specified URL. If the specified URL is null, then create a blank effigy. The specified base is used to expand any relative file references within the URL. This base class defers to each contained effigy factory until one returns an effigy. If there are no contained effigies, or if none returns an effigy, then this method returns null. Subclasses will override this method to create an effigy of an appropriate type.

Parameters:
container - The container for the effigy.
base - The base for relative file references, or null if there are no relative file references.
in - The input URL.
Returns:
A new effigy.
Throws:
java.lang.Exception - If the stream cannot be read, or if the data is malformed in some way.

getExtension

public static java.lang.String getExtension(java.net.URL url)
Return the extension on the name of the specified URL. This is a utility method designed to help derived classes decide whether the URL matches the particular type of effigy they can create. If the URL has no extension, return an empty string.

Parameters:
url - A URL.
Returns:
The extension on the URL.