public class Display extends TypedAtomicActor implements PortablePlaceable
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.
This actor accepts any type of data on its input port, therefore it
doesn't declare a type, but lets the type resolution algorithm find
the least fixed point. If backward type inference is enabled, and
no input type has been declared, the input is constrained to be
equal to BaseType.GENERAL
. This will result in upstream
ports resolving to the most general type rather than the most specific.
This actor has a suppressBlankLines parameter, whose default value is false. If this parameter is configured to be true, this actor does not put a blank line in the display.
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.
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_initialized
Indicator that the display window has been opened.
|
protected boolean |
_isSuppressBlankLines
The flag indicating whether the blank lines will be suppressed.
|
Parameter |
columnsDisplayed
The horizontal size of the display, in columns.
|
TypedIOPort |
input
The input port, which is a multiport.
|
Parameter |
rowsDisplayed
The vertical size of the display, in rows.
|
Parameter |
suppressBlankLines
The flag indicating whether this display actor suppress
blank lines.
|
StringParameter |
title
The title to put on top.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
Display(CompositeEntity container,
java.lang.String name)
Construct an actor with an input multiport of type GENERAL.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Set<Inequality> |
_customTypeConstraints()
Set the input port greater than or equal to
BaseType.GENERAL in case backward type inference is
enabled and the input port has no type declared. |
protected DisplayInterface |
_getImplementation()
Get the right instance of the implementation depending upon the
of the dependency specified through dependency injection.
|
protected java.lang.String |
_getInputString(int i)
Return a string describing the input on channel i.
|
protected void |
_openWindow()
Open the display window if it has not been opened.
|
void |
attributeChanged(Attribute attribute)
If the specified attribute is rowsDisplayed, then set
the desired number of rows of the textArea, if there is one.
|
void |
cleanUp()
Free up memory when closing.
|
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace.
|
void |
initialize()
Initialize this display.
|
void |
place(PortableContainer container)
Specify the container into which this object should be placed.
|
boolean |
postfire()
Read at most one token from each input channel and display its
string value on the screen.
|
void |
setContainer(CompositeEntity container)
Override the base class to remove the display from its graphical
container if the argument is null.
|
void |
setDisplayName(java.lang.String name)
Set a name to present to the user.
|
void |
setName(java.lang.String name)
Set or change the name.
|
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
fire, isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
addInitializable, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName
getDerivedLevel, getDerivedList, propagateValue
public Parameter columnsDisplayed
public TypedIOPort input
public Parameter rowsDisplayed
public Parameter suppressBlankLines
public StringParameter title
protected boolean _initialized
protected boolean _isSuppressBlankLines
public Display(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this actor.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class NamedObj
attribute
- The attribute that has changed.IllegalActionException
- If the specified attribute
is rowsDisplayed and its value is not positive.public void cleanUp()
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class TypedAtomicActor
workspace
- The workspace for the new object.java.lang.CloneNotSupportedException
- If a derived class contains
an attribute that cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class AtomicActor<TypedIOPort>
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.public void place(PortableContainer container)
place
in interface PortablePlaceable
container
- The container in which to place the object, or
null to specify that there is no current container.public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class AtomicActor<TypedIOPort>
IllegalActionException
- If there is no director.public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
setContainer
in class AtomicActor<TypedIOPort>
container
- The proposed container.IllegalActionException
- If the base class throws it.NameDuplicationException
- If the base class throws it.ComponentEntity.getContainer()
public void setDisplayName(java.lang.String name)
If the title parameter is set to the empty string, and the Display window has been rendered, then the title of the Display window will be updated to the value of the name parameter.
setDisplayName
in class NamedObj
name
- A name to present to the user.NamedObj.getDisplayName()
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
If the title parameter is set to the empty string, and the Display window has been rendered, then the title of the Display window will be updated to the value of the name parameter.
setName
in interface Nameable
setName
in class ComponentEntity<TypedIOPort>
name
- The new name.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.NamedObj.getName()
,
NamedObj.getName(NamedObj)
,
title
protected java.util.Set<Inequality> _customTypeConstraints()
BaseType.GENERAL
in case backward type inference is
enabled and the input port has no type declared._customTypeConstraints
in class TypedAtomicActor
protected DisplayInterface _getImplementation()
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.
protected java.lang.String _getInputString(int i) throws IllegalActionException
i
- The channelIllegalActionException
- If reading the input fails.protected void _openWindow() throws IllegalActionException
IllegalActionException
- If there is a problem creating
the effigy.