ptolemy.actor.lib.gui
Class HistogramPlotter

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.HistogramPlotter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Placeable, Initializable, TypedActor, Changeable, Configurable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class HistogramPlotter
extends PlotterBase

A histogram plotter. This plotter contains an instance of the Histogram class from the Ptolemy plot package as a public member. A histogram of data at the input port, which can consist of any number of channels, is plotted on this instance. The input data type is double.

The output plot consists of a set of vertical bars, each representing a histogram bin. The height of the bar is the count of the number of inputs that have been observed that fall within that bin. The n-th bin represents values in the range (x - w/2 + o, x + w/2 + o), where w is the value of the binWidth parameter, and o is the value of the binOffset parameter. So for example, if o = w/2, then each bin represents values from nw to (n + 1)w for some integer n. The default offset is 0.5, half the default bin width, which is 1.0.

This actor 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 1.0
Version:
$Id: HistogramPlotter.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Edward A. Lee
See Also:
Histogram, Serialized Form
Accepted Rating:
Green (cxh)
Proposed Rating:
Green (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
 Parameter binOffset
          The offset for bins of the histogram.
 Parameter binWidth
          The width of the bin of the histogram.
 TypedIOPort input
          The input port, which is a multiport.
 
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
HistogramPlotter(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  void _implementDeferredConfigurations()
          If configurations have been deferred, implement them now.
protected  PlotBox _newPlot()
          Create a new Histogram plot.
 void attributeChanged(Attribute attribute)
          If the parameter is binWidth or binOffset, then configure the histogram with the specified bin width or offset.
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Configure the plot with data from the specified input source (a URL) and/or textual data, assumed to be in PlotML format.
 java.lang.String getSource()
          Return the input source that was specified the last time the configure method was called.
 void initialize()
          If the histogram has not already been created, create it using place().
 boolean postfire()
          Read at most one input token from each input channel and update the histogram.
 
Methods inherited from class ptolemy.actor.lib.gui.PlotterBase
_exportMoMLContents, _propagateValue, clone, getConfigureSource, getConfigureText, place, preinitialize, 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, fire, 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, 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
fire, 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

binWidth

public Parameter binWidth
The width of the bin of the histogram. This parameter has type double, with default value 1.0.


binOffset

public Parameter binOffset
The offset for bins of the histogram. This parameter has type double, with default value 0.5.


input

public TypedIOPort input
The input port, which is a multiport.

Constructor Detail

HistogramPlotter

public HistogramPlotter(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 parameter is binWidth or binOffset, then configure the histogram with the specified bin width or offset.

Overrides:
attributeChanged in class PlotterBase
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the bin width is not positive.

configure

public void configure(java.net.URL base,
                      java.lang.String source,
                      java.lang.String text)
               throws java.lang.Exception
Configure the plot 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 histogram has been created (by calling place() or initialize()), then reading of the input stream is deferred until the histogram is created.

Specified by:
configure in interface Configurable
Overrides:
configure in class PlotterBase
Parameters:
base - The base relative to which references within the input stream are found, or null if this is not known.
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.

getSource

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

Specified by:
getSource in interface MoMLExportable
Overrides:
getSource in class NamedObj
Returns:
The string representation of the input URL.
See Also:
NamedObj.setSource(String), MoMLExportable

initialize

public void initialize()
                throws IllegalActionException
If the histogram has not already been created, create it using place(). If configurations specified by a call to configure() have not yet been processed, process them.

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

postfire

public boolean postfire()
                 throws IllegalActionException
Read at most one input token from each input channel and update the histogram. This is done in postfire to ensure that data has settled.

Specified by:
postfire in interface Executable
Overrides:
postfire in class AtomicActor
Returns:
True if execution can continue into the next iteration.
Throws:
IllegalActionException - If there is no director.

_implementDeferredConfigurations

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

Overrides:
_implementDeferredConfigurations in class PlotterBase

_newPlot

protected PlotBox _newPlot()
Create a new Histogram plot.

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