ptolemy.actor.lib.gui
Class Display

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.Sink
                              extended byptolemy.actor.lib.gui.Display
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, 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

public class Display
extends Sink
implements ptolemy.actor.gui.Placeable

Display the values of the tokens arriving on the input channels in a text area on the screen. Each input token is written on a separate line. The input type can be of any type. If the input happens to be a StringToken, then the surrounding quotation marks are stripped before printing the value of the token. Thus, string-valued tokens can be used to generate arbitrary textual output, at one token per line. Tokens are read from the input only in the postfire() method, to allow them to settle in domains where they converge to a fixed point.

Note that because of complexities in Swing, if you resize the display window, then, unlike the plotters, the new size will not be persistent. That is, if you save the model and then re-open it, the new size is forgotten. To control the size, you should set the rowsDisplayed and columnsDisplayed parameters.

Note that this actor internally uses JTextArea, a Java Swing object that is known to consume large amounts of memory. It is not advisable to use this actor to log large output streams.

Since:
Ptolemy II 1.0
Version:
$Id: Display.java,v 1.57 2004/04/13 05:12:32 cxh Exp $
Author:
Yuhong Xiong, Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Yellow (vogel)
Proposed Rating:
Yellow (yuhong)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.data.expr.Parameter columnsDisplayed
          The horizontal size of the display, in columns.
 ptolemy.data.expr.Parameter rowsDisplayed
          The vertical size of the display, in rows.
 javax.swing.JTextArea textArea
          The text area in which the data will be displayed.
 ptolemy.kernel.util.StringAttribute title
          The title to put on top.
 
Fields inherited from class ptolemy.actor.lib.Sink
input
 
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
Display(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with an input multiport of type GENERAL.
 
Method Summary
protected  void _exportMoMLContents(java.io.Writer output, int depth)
          Write a MoML description of the contents of this object.
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          If the specified attribute is rowsDisplayed, then set the desired number of rows of the textArea, if there is one.
 java.lang.Object clone(ptolemy.kernel.util.Workspace workspace)
          Clone the actor into the specified workspace.
 java.awt.Color getBackground()
          Get the background color.
 void initialize()
          Initialize this display.
 void place(java.awt.Container container)
          Specify the container in which the data should be displayed.
 boolean postfire()
          Read at most one token from each input channel and display its string value on the screen.
 void setBackground(java.awt.Color background)
          Set the background
 void setContainer(ptolemy.kernel.CompositeEntity container)
          Override the base class to remove the display from its graphical container if the argument is null.
 
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, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, stop, stopFire, terminate, wrapup
 
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, _propagateValue, _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, iterate, prefire, preinitialize, stop, stopFire, terminate, wrapup
 
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

columnsDisplayed

public ptolemy.data.expr.Parameter columnsDisplayed
The horizontal size of the display, in columns. This contains an integer, and defaults to 40.


rowsDisplayed

public ptolemy.data.expr.Parameter rowsDisplayed
The vertical size of the display, in rows. This contains an integer, and defaults to 10.


textArea

public transient javax.swing.JTextArea textArea
The text area in which the data will be displayed.


title

public ptolemy.kernel.util.StringAttribute title
The title to put on top.

Constructor Detail

Display

public Display(ptolemy.kernel.CompositeEntity container,
               java.lang.String name)
        throws ptolemy.kernel.util.IllegalActionException,
               ptolemy.kernel.util.NameDuplicationException
Construct an actor with an input multiport of type GENERAL.

Parameters:
container - The container.
name - The name of this actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If the entity 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 specified attribute is rowsDisplayed, then set the desired number of rows of the textArea, if there is one.

Parameters:
attribute - The attribute that has changed.
Throws:
ptolemy.kernel.util.IllegalActionException - If the specified attribute is rowsDisplayed and its value is not positive.

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 sets the textArea public variable to null.

Parameters:
workspace - The workspace for the new object.
Returns:
A new actor.
Throws:
java.lang.CloneNotSupportedException - If a derived class contains an attribute that cannot be cloned.

getBackground

public java.awt.Color getBackground()
Get the background color.

Returns:
The background color of the text area.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Initialize this display. If place() has not been called with a container into which to place the display, then create a new frame into which to put it.

Specified by:
initialize in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If the parent class throws it, or if the numRows or numColumns parameters are incorrect, or if there is no effigy for the top level container, or if a problem occurs creating the effigy and tableau.

place

public void place(java.awt.Container container)
Specify the container in which the data should be displayed. An instance of JTextArea will be added to that container. This method needs to be called before the first call to initialize(). Otherwise, an instance of JTextArea will be placed in its own frame. The text area is also placed in its own frame if this method is called with a null argument. The background of the text area is set equal to that of the container (unless it is null).

Specified by:
place in interface ptolemy.actor.gui.Placeable
Parameters:
container - The container into which to place the text area, or null to specify that there is no current container.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Read at most one token from each input channel and display its string value on the screen. Each value is terminated with a newline character.

Specified by:
postfire in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.

setBackground

public void setBackground(java.awt.Color background)
Set the background


setContainer

public void setContainer(ptolemy.kernel.CompositeEntity container)
                  throws ptolemy.kernel.util.IllegalActionException,
                         ptolemy.kernel.util.NameDuplicationException
Override the base class to remove the display 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.

_exportMoMLContents

protected void _exportMoMLContents(java.io.Writer output,
                                   int depth)
                            throws java.io.IOException
Write a MoML description of the contents of this object. This overrides the base class to make sure that the current frame properties, if there is a frame, are recorded.

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.