ptolemy.actor.lib.gui
Class PlotterBase

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.gui.PlotterBase
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Configurable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, ptolemy.actor.gui.Placeable, java.io.Serializable, ptolemy.actor.TypedActor
Direct Known Subclasses:
HistogramPlotter, Plotter

public class PlotterBase
extends ptolemy.actor.TypedAtomicActor
implements ptolemy.kernel.util.Configurable, ptolemy.actor.gui.Placeable

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: PlotterBase.java,v 1.22.2.1 2004/06/18 00:48:55 cxh Exp $
Author:
Edward A. Lee
See Also:
PlotBox, Serialized Form
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (eal)

Nested Class Summary
protected  class PlotterBase.PlotterPlotFrame
          Version of Plot class that removes its association with the plot upon closing, and also records the size of the plot window.
protected  class PlotterBase.PlotWindowTableau
          Tableau that creates a PlotterPlotFrame.
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
protected  java.net.URL _base
          The base specified in configure().
protected  java.awt.Container _container
          Container into which this plot should be placed
protected  ptolemy.actor.gui.PlotTableauFrame _frame
          Frame into which plot is placed, if any.
protected  ptolemy.actor.gui.SizeAttribute _plotSize
          A specification of the size of the plot if it's in its own window.
protected  java.lang.String _source
          The source specified in configure().
protected  java.lang.String _text
          The text specified in configure().
protected  ptolemy.actor.gui.WindowPropertiesAttribute _windowProperties
          A specification for the window properties of the frame.
 ptolemy.data.expr.Parameter fillOnWrapup
          If true, fill the plot when wrapup is called.
 ptolemy.kernel.util.StringAttribute legend
          A comma-separated list of labels to attach to each data set.
 ptolemy.plot.PlotBox plot
          The plot object.
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
PlotterBase(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
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  void _implementDeferredConfigurations()
          If configurations have been deferred, implement them now.
protected  ptolemy.plot.PlotBox _newPlot()
          Create a new plot.
protected  void _propagateValue(ptolemy.kernel.util.NamedObj destination)
          Propagate the value of this object to the specified object.
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          If the attribute is legend, then parse the string and set the legend.
 java.lang.Object clone(ptolemy.kernel.util.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(java.awt.Container container)
          Specify the container into which this plot should be placed.
 void preinitialize()
          Clear the plot, if there is one.
 void setContainer(ptolemy.kernel.CompositeEntity container)
          Override the base class to remove the plot from its graphical container if the argument is null.
 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
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, connectionsChanged, fire, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, pruneDependencies, removeDependency, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
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, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, 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.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, initialize, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

plot

public transient ptolemy.plot.PlotBox plot
The plot object.


fillOnWrapup

public ptolemy.data.expr.Parameter fillOnWrapup
If true, fill the plot when wrapup is called. This parameter has type BooleanToken, and default value true.


legend

public ptolemy.kernel.util.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().


_container

protected java.awt.Container _container
Container into which this plot should be placed


_frame

protected transient ptolemy.actor.gui.PlotTableauFrame _frame
Frame into which plot is placed, if any.


_plotSize

protected ptolemy.actor.gui.SizeAttribute _plotSize
A specification of the size of the plot if it's in its own window.


_source

protected java.lang.String _source
The source specified in configure().


_text

protected java.lang.String _text
The text specified in configure().


_windowProperties

protected ptolemy.actor.gui.WindowPropertiesAttribute _windowProperties
A specification for the window properties of the frame.

Constructor Detail

PlotterBase

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

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

attributeChanged

public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
                      throws ptolemy.kernel.util.IllegalActionException
If the attribute is legend, then parse the string and set the legend.

Throws:
ptolemy.kernel.util.IllegalActionException - If the superclass throws it.

clone

public java.lang.Object clone(ptolemy.kernel.util.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.

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.

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 interface ptolemy.kernel.util.Configurable
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 interface ptolemy.kernel.util.Configurable
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 interface ptolemy.kernel.util.Configurable

place

public void place(java.awt.Container 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 interface ptolemy.actor.gui.Placeable
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 ptolemy.kernel.util.IllegalActionException
Clear the plot, if there is one. Notice that unlike initialize(), this clears the entire plot.

Specified by:
preinitialize in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If the parent class throws it.
See Also:
AtomicActor.initialize()

setContainer

public void setContainer(ptolemy.kernel.CompositeEntity container)
                  throws ptolemy.kernel.util.IllegalActionException,
                         ptolemy.kernel.util.NameDuplicationException
Override the base class to remove the plot from its graphical container if the argument is null.

Parameters:
container - The proposed container.
Throws:
ptolemy.kernel.util.IllegalActionException - If the base class throws it.
ptolemy.kernel.util.NameDuplicationException - If the base class throws it.

wrapup

public void wrapup()
            throws ptolemy.kernel.util.IllegalActionException
If the fillOnWrapup parameter is true, rescale the plot so that all the data is visible.

Specified by:
wrapup in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.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.

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.

_implementDeferredConfigurations

protected void _implementDeferredConfigurations()
If configurations have been deferred, implement them now. Also, configure the plot legends, if appropriate.


_newPlot

protected ptolemy.plot.PlotBox _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(ptolemy.kernel.util.NamedObj destination)
                        throws ptolemy.kernel.util.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.

Parameters:
destination - Object to which to propagate the value.
Throws:
ptolemy.kernel.util.IllegalActionException - If the value cannot be propagated.