Package ptolemy.actor.lib.gui
Class SketchedSource
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,PortablePlaceable
,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$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (vogel)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description 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
_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, _source, _text, automaticRescale, fillOnWrapup, legend, plot
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description SketchedSource(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PlotBox
_newPlot()
Create a new plot.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(PortableContainer 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, _getImplementation, _implementDeferredConfigurations, _isMoMLSuppressed, _propagateValue, cleanUp, configure, getConfigureSource, getConfigureText, setContainer, setDisplayName, setFrame, setName, wrapup
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, 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
_addPort, _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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
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
-
-
-
-
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.
-
-
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 classSequencePlotter
- 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 classPlotterBase
- 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 interfaceEditListener
- 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 interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- 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 interfaceInitializable
- Overrides:
initialize
in classSequencePlotter
- Throws:
IllegalActionException
- If the parent class throws it.
-
place
public void place(PortableContainer container)
Override the base class to create an initial trace.- Specified by:
place
in interfacePortablePlaceable
- Overrides:
place
in classPlotterBase
- 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 interfaceInitializable
- Overrides:
preinitialize
in classPlotterBase
- 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 classPlotterBase
- Returns:
- A new editable plot object.
-
-