Class PlotterBase
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.gui.PlotterBase
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,PortablePlaceable
,TypedActor
,Changeable
,Configurable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
HistogramPlotter
,Plotter
public class PlotterBase extends TypedAtomicActor implements Configurable, PortablePlaceable
Base class for plotters. This class contains an instance of the PlotBox class from the Ptolemy plot package as a public member, although which subclass of PlotBox is created is left to derived classes. It provides a parameter that determines whether to fill the plot when wrapup is invoked. It also has a legend parameter, which gives a comma-separated list of labels to attach to each dataset. Normally, the number of elements in this list should equal the number of input channels, although this is not enforced.- Since:
- Ptolemy II 2.1
- Version:
- $Id$
- Author:
- Edward A. Lee
- See Also:
PlotBox
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.URL
_base
The base specified in configure().protected java.lang.String
_source
The source specified in configure().protected java.lang.String
_text
The text specified in configure().Parameter
automaticRescale
If true, the plot will automatically rescale if necessary.Parameter
fillOnWrapup
If true, fill the plot when wrapup is called.StringAttribute
legend
A comma-separated list of labels to attach to each data set.PlotBoxInterface
plot
The plot object.-
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 PlotterBase(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 void
_exportMoMLContents(java.io.Writer output, int depth)
Write a MoML description of the contents of this object, which in this class is the configuration information.protected PlotterBaseInterface
_getImplementation()
Get the right instance of the implementation depending upon the of the dependency specified through dependency injection.protected void
_implementDeferredConfigurations()
If configurations have been deferred, implement them now.protected boolean
_isMoMLSuppressed(int depth)
Override the base class to ensure that MoML is produced if there is configuration information to export.protected PlotBoxInterface
_newPlot()
Create a new plot.protected void
_propagateValue(NamedObj destination)
Propagate the value of this object to the specified object.void
attributeChanged(Attribute attribute)
If the attribute is legend, then parse the string and set the legend.void
cleanUp()
Free up memory when closing.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
configure(java.net.URL base, java.lang.String source, java.lang.String text)
Configure the object with data from the specified input source (a URL) and/or textual data, assumed to be in PlotML format.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.void
place(PortableContainer container)
Specify the container into which this plot should be placed.void
preinitialize()
Clear the plot, if there is one.void
setContainer(CompositeEntity container)
Override the base class to remove the plot from its graphical container if the argument is null.void
setDisplayName(java.lang.String name)
Set a name to present to the user.void
setFrame(java.lang.Object frame)
Specify the associated frame and set its properties (size, etc.) to match those stored in the _windowProperties attribute.void
setName(java.lang.String name)
Set or change the name.void
wrapup()
If the fillOnWrapup parameter is true, rescale the plot so that all the data is visible.-
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, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, 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
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName
-
-
-
-
Field Detail
-
automaticRescale
public Parameter automaticRescale
If true, the plot will automatically rescale if necessary. This parameter has type BooleanToken, and default value false.
-
plot
public transient PlotBoxInterface plot
The plot object.
-
fillOnWrapup
public Parameter fillOnWrapup
If true, fill the plot when wrapup is called. This parameter has type BooleanToken, and default value true.
-
legend
public StringAttribute legend
A comma-separated list of labels to attach to each data set. This is always a string, with no enclosing quotation marks.
-
_base
protected java.net.URL _base
The base specified in configure().
-
_source
protected java.lang.String _source
The source specified in configure().
-
_text
protected java.lang.String _text
The text specified in configure().
-
-
Constructor Detail
-
PlotterBase
public PlotterBase(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 attribute is legend, then parse the string and set the legend.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the superclass throws it.
-
cleanUp
public void cleanUp()
Free up memory when closing.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.- Overrides:
clone
in classTypedAtomicActor
- 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)
-
configure
public void configure(java.net.URL base, java.lang.String source, java.lang.String text) throws java.lang.Exception
Configure the object with data from the specified input source (a URL) and/or textual data, assumed to be in PlotML format. If this is called before the plotter has been created (by calling place() or initialize()), then the configuration is deferred until the plotter is created.- Specified by:
configure
in interfaceConfigurable
- 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.text
- Configuration information given as text.- Throws:
java.lang.Exception
- If the configuration source cannot be read or if the configuration information is incorrect.
-
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 interfaceConfigurable
- Returns:
- The string representation of the input URL.
-
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 returned here. This returns a null string if there is no associated plot.- Specified by:
getConfigureText
in interfaceConfigurable
- Returns:
- The text string that represent the current configuration.
-
place
public void place(PortableContainer container)
Specify the container into which this plot should be placed. This method needs to be called before the first call to initialize(). Otherwise, the plot will be placed in its own frame. The size of the plot, unfortunately, cannot be effectively determined from the size of the container because the container may not yet be laid out (its size will be zero). Thus, you will have to explicitly set the size of the plot by calling plot.setSize(). The background of the plot is set equal to that of the container (unless it is null).If configure() has been called (prior to the plot getting created), then the configurations that it specified have been deferred. Those configurations are performed at this time.
- Specified by:
place
in interfacePortablePlaceable
- Parameters:
container
- The container into which to place the plot, or null to specify that a new plot should be created.
-
preinitialize
public void preinitialize() throws IllegalActionException
Clear the plot, if there is one. Notice that unlike initialize(), this clears the entire plot.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.- See Also:
AtomicActor.initialize()
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Override the base class to remove the plot from its graphical container if the argument is null.- Overrides:
setContainer
in classAtomicActor<TypedIOPort>
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the base class throws it.NameDuplicationException
- If the base class throws it.- See Also:
ComponentEntity.getContainer()
-
setFrame
public void setFrame(java.lang.Object frame)
Specify the associated frame and set its properties (size, etc.) to match those stored in the _windowProperties attribute.- Parameters:
frame
- The associated frame.
-
setDisplayName
public void setDisplayName(java.lang.String name)
Set a name to present to the user.If the Plot window has been rendered, then the title of the Plot window will be updated to the value of the name parameter.
- Overrides:
setDisplayName
in classNamedObj
- Parameters:
name
- A name to present to the user.- See Also:
NamedObj.getDisplayName()
-
setName
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
Set or change the name. If a null argument is given the name is set to an empty string. Increment the version of the workspace. This method is write-synchronized on the workspace.If the Plot window has been rendered, then the title of the Plot window will be updated to the value of the name parameter.
- Specified by:
setName
in interfaceNameable
- Overrides:
setName
in classComponentEntity<TypedIOPort>
- Parameters:
name
- The new name.- Throws:
IllegalActionException
- If the name contains a period or if the object is a derived object and the name argument does not match the current name.NameDuplicationException
- Not thrown in this base class. May be thrown by derived classes if the container already contains an object with this name.- See Also:
NamedObj.getName()
,NamedObj.getName(NamedObj)
-
wrapup
public void wrapup() throws IllegalActionException
If the fillOnWrapup parameter is true, rescale the plot so that all the data is visible.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the superclass throws it.
-
_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 is the configuration information. This method is called by exportMoML(). Each description is indented according to the specified depth and terminated with a newline character.- Overrides:
_exportMoMLContents
in classEntity<TypedIOPort>
- Parameters:
output
- The output stream 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)
-
_getImplementation
protected PlotterBaseInterface _getImplementation()
Get the right instance of the implementation depending upon the of the dependency specified through dependency injection. If the instance has not been created, then it is created. If the instance already exists then return the same.This code is used as part of the dependency injection needed for the HandSimDroid project, see $PTII/ptserver. This code uses dependency inject to determine what implementation to use at runtime. This method eventually reads ptolemy/actor/ActorModule.properties.
ActorModuleInitializer.initializeInjector()
should be called before this method is called. If it is not called, then a message is printed and initializeInjector() is called.- Returns:
- the implementation.
-
_implementDeferredConfigurations
protected void _implementDeferredConfigurations()
If configurations have been deferred, implement them now. Also, configure the plot legends, if appropriate.
-
_isMoMLSuppressed
protected boolean _isMoMLSuppressed(int depth)
Override the base class to ensure that MoML is produced if there is configuration information to export.- Overrides:
_isMoMLSuppressed
in classNamedObj
- Parameters:
depth
- The depth.- Returns:
- True to export MoML.
-
_newPlot
protected PlotBoxInterface _newPlot()
Create a new plot. In this base class, it is an instance of Plot. In derived classes, it can be classes derived from Plot.- Returns:
- A new plot object.
-
_propagateValue
protected void _propagateValue(NamedObj destination) throws IllegalActionException
Propagate the value of this object to the specified object. The specified object is required to be an instance of the same class as this one, or a ClassCastException will be thrown.- Overrides:
_propagateValue
in classNamedObj
- Parameters:
destination
- Object to which to propagate the value.- Throws:
IllegalActionException
- If the value cannot be propagated.
-
-