ptolemy.actor.lib.gui
Class SketchedSource

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.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.actor.lib.gui.PlotterBase
                              extended by ptolemy.actor.lib.gui.Plotter
                                  extended by ptolemy.actor.lib.gui.SequencePlotter
                                      extended by ptolemy.actor.lib.gui.SketchedSource
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Placeable, Initializable, SequenceActor, TypedActor, Changeable, Configurable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, EditListener

public class SketchedSource
extends SequencePlotter
implements EditListener

This actor is a plotter that also produces as its output a signal that has been sketched by the user on the screen. The length parameter specifies the number of samples in the sketched signal. The periodic parameter, if true, specifies that the signal should be repeated. If this parameter is false, then the sketched signal is produced exactly once, at the beginning of the execution of the model. If periodic is true and the sketch is modified during execution of the model, then the modification appears in the next cycle after the modification has been completed. In other words, the change does not appear mid-cycle.

This actor is also a plotter, and will plot the input signals on the same plot as the sketched signal. It can be used in a feedback loop where the output affects the input. The first batch of outputs is produced in the initialize() method, so it can be put in a feedback loop in a dataflow model.

Since:
Ptolemy II 1.0
Version:
$Id: SketchedSource.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (vogel)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.actor.lib.gui.PlotterBase
PlotterBase.PlotWindowTableau
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  int _count
          Current position in the signal.
private  double[][] _data
          Sketched data.
private  boolean _dataModified
          Indicator that the user has modified the data.
private  boolean _initialTraceIsSet
          Indicator that initial trace has been supplied.
private static IntToken _one
           
private  int _previousLengthValue
           
private  boolean _settingInitialTrace
           
private static DoubleToken _zero
          Zero token.
 Parameter initialTrace
          The default signal to generate, prior to any user sketch.
 Parameter length
          The length of the output signal that will be generated.
 TypedIOPort output
          The output port.
 Parameter periodic
          An indicator of whether the signal should be periodically repeated.
 Parameter runOnModification
          If true, then when the user edits the plot, if the manager is currently idle, then run the model.
 Parameter yBottom
          The bottom of the Y range.
 Parameter yTop
          The top of the Y range.
 
Fields inherited from class ptolemy.actor.lib.gui.SequencePlotter
_connected, _xInit, _xUnit, _xValue, input, xInit, xUnit
 
Fields inherited from class ptolemy.actor.lib.gui.Plotter
startingDataset
 
Fields inherited from class ptolemy.actor.lib.gui.PlotterBase
_base, _container, _frame, _plotSize, _source, _tableau, _text, _windowProperties, automaticRescale, fillOnWrapup, legend, plot
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
SketchedSource(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  PlotBox _newPlot()
          Create a new plot.
private  void _setRanges()
           
private  void _showInitialTrace()
           
private  void _updateInitialTrace()
           
 void attributeChanged(Attribute attribute)
          If the specified attribute is length, then set the trace to its initial value.
 java.lang.Object clone(Workspace workspace)
          Clone the actor into the specified workspace.
 void editDataModified(EditablePlot source, int dataset)
          React to the fact that data in the specified plot has been modified by a user edit action by recording the data.
 void fire()
          Produce one data sample from the sketched signal on the output port.
 void initialize()
          Override the base class to read data from the plot and to produce all the data on the output.
 void place(java.awt.Container container)
          Override the base class to create an initial trace.
 void preinitialize()
          Override the base class to not clear the plot.
 
Methods inherited from class ptolemy.actor.lib.gui.SequencePlotter
postfire
 
Methods inherited from class ptolemy.actor.lib.gui.PlotterBase
_exportMoMLContents, _implementDeferredConfigurations, _propagateValue, configure, getConfigureSource, getConfigureText, setContainer, setDisplayName, setName, wrapup
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence
 
Methods inherited from class ptolemy.kernel.Entity
_description, _removePort, _validateSettables, connectedPortList, connectedPorts, 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, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, 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, 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.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

initialTrace

public Parameter initialTrace
The default signal to generate, prior to any user sketch. By default, this contains an array of zeros with the length given by the length parameter.


length

public Parameter length
The length of the output signal that will be generated. This parameter must contain an IntToken. By default, it has value 100.


output

public TypedIOPort output
The output port. The type of this port is double.


periodic

public Parameter periodic
An indicator of whether the signal should be periodically repeated. This parameter must contain a boolean token. By default, it has value true.


runOnModification

public Parameter runOnModification
If true, then when the user edits the plot, if the manager is currently idle, then run the model. This is a boolean that defaults to false.


yBottom

public Parameter yBottom
The bottom of the Y range. This is a double, with default value -1.0.


yTop

public Parameter yTop
The top of the Y range. This is a double, with default value 1.0.


_count

private int _count
Current position in the signal.


_data

private double[][] _data
Sketched data.


_dataModified

private boolean _dataModified
Indicator that the user has modified the data.


_initialTraceIsSet

private boolean _initialTraceIsSet
Indicator that initial trace has been supplied.


_one

private static IntToken _one

_previousLengthValue

private int _previousLengthValue

_settingInitialTrace

private boolean _settingInitialTrace

_zero

private static DoubleToken _zero
Zero token.

Constructor Detail

SketchedSource

public SketchedSource(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
Construct an actor with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
IllegalActionException - If the actor cannot be contained by the proposed container.
NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the specified attribute is length, then set the trace to its initial value.

Overrides:
attributeChanged in class SequencePlotter
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the specified attribute is length and its value is not positive.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.

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

editDataModified

public void editDataModified(EditablePlot source,
                             int dataset)
React to the fact that data in the specified plot has been modified by a user edit action by recording the data. Note that this is typically called in the UI thread, and it is synchronized.

Specified by:
editDataModified in interface EditListener
Parameters:
source - The plot containing the modified data.
dataset - The data set that has been modified.

fire

public void fire()
          throws IllegalActionException
Produce one data sample from the sketched signal on the output port.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If there is no director, or if the base class throws it.

initialize

public void initialize()
                throws IllegalActionException
Override the base class to read data from the plot and to produce all the data on the output.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class SequencePlotter
Throws:
IllegalActionException - If the parent class throws it.

place

public void place(java.awt.Container container)
Override the base class to create an initial trace.

Specified by:
place in interface Placeable
Overrides:
place in class PlotterBase
Parameters:
container - The container into which to place the plot.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Override the base class to not clear the plot. The PlotterBase class clears the entire plot, which will erase sketched data.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class PlotterBase
Throws:
IllegalActionException - If triggered by creating receivers.
See Also:
AtomicActor.initialize()

_newPlot

protected PlotBox _newPlot()
Create a new plot. In this class, it is an instance of EditablePlot.

Overrides:
_newPlot in class PlotterBase
Returns:
A new editable plot object.

_setRanges

private void _setRanges()
                 throws IllegalActionException
Throws:
IllegalActionException

_showInitialTrace

private void _showInitialTrace()
                        throws IllegalActionException
Throws:
IllegalActionException

_updateInitialTrace

private void _updateInitialTrace()
                          throws IllegalActionException
Throws:
IllegalActionException