ptolemy.actor.gt.controller
Class Transform

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.domains.modal.kernel.State
                      extended by ptolemy.domains.ptera.kernel.Event
                          extended by ptolemy.actor.gt.controller.GTEvent
                              extended by ptolemy.actor.gt.controller.Transform
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, TransformationListener, Initializable, ConfigurableEntity, Changeable, Configurable, Debuggable, DebugListener, Derivable, DropTargetHandler, Flowable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
Match

public class Transform
extends GTEvent
implements ConfigurableEntity, TransformationListener

An event to transform the model in the model parameter with the encapsulated transformation rule.

Since:
Ptolemy II 8.0
Version:
$Id: Transform.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Thomas Huining Feng
See Also:
Serialized Form
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
static class Transform.EmbeddedConfigurer
          The configurer to be embedded in the transform event.
 
Nested classes/interfaces inherited from class ptolemy.domains.ptera.kernel.Event
Event.EventParameter, Event.RefiringData
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  Configurer _configurer
          The configurer.
private  java.lang.String _configureSource
          The configure source.
protected  TransformationRule _transformation
          The encapsulated transformation rule.
 TransformEventController.Factory controllerFactory
          The controller factory for this event to specialize the popup menu.
 Parameter defer
          Whether the transformation should be deferred with a change request.
 Parameter matched
          Whether the last pattern matching was successful (read-only).
 TransformationMode mode
          The transformation mode.
 
Fields inherited from class ptolemy.actor.gt.controller.GTEvent
refinementExtender
 
Fields inherited from class ptolemy.domains.ptera.kernel.Event
actions, isEndingEvent, isFinalEvent, isInitialEvent, parameters
 
Fields inherited from class ptolemy.domains.modal.kernel.State
incomingPort, isFinalState, isInitialState, outgoingPort, refinementName, saveRefinementsInConfigurer
 
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
Transform(CompositeEntity container, java.lang.String name)
          Construct an event with the given name contained by the specified composite entity.
 
Method Summary
private static void _clearURI(NamedObj object)
          Clear the URI attribute of the given object.
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Write a MoML description of the contents of this object, which in this class are the attributes plus the ports.
protected  boolean _isActiveRefinement(TypedActor refinement)
          Return whether the given refinement is active.
 void addObject(NamedObj object)
          Invoked when the specified object is added to a container.
 java.lang.Object clone(Workspace workspace)
          Clone the event into the specified workspace.
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Configure this event with a transformation rule (an instance of TransformationRule) stored in the moml.
 Event.RefiringData fire(Token arguments)
          Process this event and transform (or pattern-match) the model in the model parameter depending on the transformation model mode.
 Configurer getConfigurer()
          Get the Transform.EmbeddedConfigurer object for this entity.
 java.lang.String getConfigureSource()
          Return the input source that was specified the last time the configure method was called.
 java.lang.String getConfigureText()
          Return the text string that represents the current configuration of this object.
 TypedActor[] getRefinement()
          Get the refinement of this event, which is an instance of TransformationRule.
 
Methods inherited from class ptolemy.actor.gt.controller.GTEvent
getModelParameter, setContainer
 
Methods inherited from class ptolemy.domains.ptera.kernel.Event
_getParserScope, addInitializable, attributeChanged, getController, initialize, isEndingEvent, isFinalEvent, isInitialEvent, preinitialize, refire, removeInitializable, scheduleEvents, stop, wrapup
 
Methods inherited from class ptolemy.domains.modal.kernel.State
dropObject, getIncomingPort, getObjectInRefinement, getOutgoingPort, nonpreemptiveTransitionList, preemptiveTransitionList
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, 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, getDisplayName, getFullName, getName, getName
 

Field Detail

controllerFactory

public TransformEventController.Factory controllerFactory
The controller factory for this event to specialize the popup menu.


defer

public Parameter defer
Whether the transformation should be deferred with a change request.


matched

public Parameter matched
Whether the last pattern matching was successful (read-only).


mode

public TransformationMode mode
The transformation mode.


_transformation

protected TransformationRule _transformation
The encapsulated transformation rule.


_configureSource

private java.lang.String _configureSource
The configure source.


_configurer

private Configurer _configurer
The configurer.

Constructor Detail

Transform

public Transform(CompositeEntity container,
                 java.lang.String name)
          throws IllegalActionException,
                 NameDuplicationException
Construct an event with the given name contained by the specified composite entity. The container argument must not be null, or a NullPointerException will be thrown. This event will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This constructor write-synchronizes on the workspace.

Parameters:
container - The container.
name - The name of the state.
Throws:
IllegalActionException - If the state cannot be contained by the proposed container.
NameDuplicationException - If the name coincides with that of an entity already in the container.
Method Detail

addObject

public void addObject(NamedObj object)
Invoked when the specified object is added to a container.

Specified by:
addObject in interface TransformationListener
Parameters:
object - The added object.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the event into the specified workspace. This calls the base class and then sets the attribute and port public members to refer to the attributes and ports of the new state.

Overrides:
clone in class Event
Parameters:
workspace - The workspace for the new event.
Returns:
A new event.
Throws:
java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

configure

public void configure(java.net.URL base,
                      java.lang.String source,
                      java.lang.String text)
               throws java.lang.Exception
Configure this event with a transformation rule (an instance of TransformationRule) stored in the moml.

Specified by:
configure in interface Configurable
Overrides:
configure in class State
Parameters:
base - The base relative to which references within the input are found, or null if this is not known, or there is none.
source - The input source, which specifies a URL, or null if none.
text - Configuration information given as text, or null if none.
Throws:
java.lang.Exception - If something goes wrong.

fire

public Event.RefiringData fire(Token arguments)
                        throws IllegalActionException
Process this event and transform (or pattern-match) the model in the model parameter depending on the transformation model mode.

Overrides:
fire in class Event
Parameters:
arguments - The arguments used to process this event, which must be either an ArrayToken or a RecordToken.
Returns:
A refiring data structure that contains a non-negative double number if refire() should be called after that amount of model time, or null if refire() need not be called.
Throws:
IllegalActionException - If the model cannot be transformed, or if thrown by the superclass.
See Also:
TransformationMode

getConfigureSource

public java.lang.String getConfigureSource()
Return the input source that was specified the last time the configure method was called.

Specified by:
getConfigureSource in interface Configurable
Overrides:
getConfigureSource in class State
Returns:
The string representation of the input URL, or null if the no source has been used to configure this object, or null if no external source need be used to configure this object.

getConfigureText

public java.lang.String getConfigureText()
Return the text string that represents the current configuration of this object. Note that any configuration that was previously specified using the source attribute need not be represented here as well.

Specified by:
getConfigureText in interface Configurable
Overrides:
getConfigureText in class State
Returns:
A configuration string, or null if no configuration has been used to configure this object, or null if no configuration string need be used to configure this object.

getConfigurer

public Configurer getConfigurer()
Get the Transform.EmbeddedConfigurer object for this entity.

Specified by:
getConfigurer in interface ConfigurableEntity
Overrides:
getConfigurer in class State
Returns:
the Configurer object for this entity.

getRefinement

public TypedActor[] getRefinement()
Get the refinement of this event, which is an instance of TransformationRule.

Overrides:
getRefinement in class State
Returns:
The refinement.

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Write a MoML description of the contents of this object, which in this class are the attributes plus the ports. This method is called by exportMoML(). Each description is indented according to the specified depth and terminated with a newline character.

Overrides:
_exportMoMLContents in class State
Parameters:
output - The output to write to.
depth - The depth in the hierarchy, to determine indenting.
Throws:
java.io.IOException - If an I/O error occurs.
See Also:
NamedObj.exportMoML(Writer, int)

_isActiveRefinement

protected boolean _isActiveRefinement(TypedActor refinement)
Return whether the given refinement is active. The result is false unless the refinement is not the TransformationRule instance.

Overrides:
_isActiveRefinement in class Event
Parameters:
refinement - The refinement.
Returns:
Whether the refinement is active.

_clearURI

private static void _clearURI(NamedObj object)
                       throws IllegalActionException
Clear the URI attribute of the given object.

Parameters:
object - The object.
Throws:
IllegalActionException - If the URI attribute of the object cannot be removed.