Package ptolemy.actor.lib.gui
Class MatrixViewer
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Placeable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class MatrixViewer extends AbstractPlaceableActor
An actor that displays the contents of a matrix input. This actor has a single input port, which only accepts MatrixTokens. One token is consumed per firing (in postfire()). The data in the MatrixToken is displayed in a table format with scrollbars, using the swing JTable class.- Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Bart Kienhuis and Edward A. Lee
- Pt.AcceptedRating:
- Red (kienhuis)
- Pt.ProposedRating:
- Red (kienhuis)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
height
The height of the table in pixels.TypedIOPort
input
The input port.Parameter
width
The width of the table in pixels.-
Fields inherited from class ptolemy.actor.gui.AbstractPlaceableActor
_frame, _paneSize, _windowClosingAdapter, _windowProperties
-
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 MatrixViewer(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 void
attributeChanged(Attribute attribute)
Notification that an attribute has changed.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
initialize()
Initialize this matrix viewer.void
place(java.awt.Container container)
Specify the container in which the data should be displayed.boolean
postfire()
Consume a matrix token from the input port and display the token in a table.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
setFrame(javax.swing.JFrame 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.-
Methods inherited from class ptolemy.actor.gui.AbstractPlaceableActor
_exportMoMLContents, cleanUp
-
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, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate, wrapup
-
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, _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
-
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, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName
-
-
-
-
Field Detail
-
input
public TypedIOPort input
The input port.
-
width
public Parameter width
The width of the table in pixels. This must contain an integer. If the table is larger than this specified width, then scrollbars will appear, or the column width is adjusted. The default value is 500.
-
height
public Parameter height
The height of the table in pixels. This must contain an integer. If the table is larger than this specified width, then scrollbars will appear. The default value is 300.
-
-
Constructor Detail
-
MatrixViewer
public MatrixViewer(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
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
Notification that an attribute has changed. If the attribute is width or height then read the value of the attribute.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the expression of the attribute cannot be parsed or cannot be evaluated.
-
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 removes association with graphical objects belonging to the original class.- Overrides:
clone
in classAbstractPlaceableActor
- 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.- See Also:
Object.clone()
-
initialize
public void initialize() throws IllegalActionException
Initialize this matrix viewer. 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 interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
place
public void place(java.awt.Container container)
Specify the container in which the data should be displayed. An instance of JTable will be added to that container. The table is configured such that a user cannot reorder the columns of the table. Also, the table maintains a fixed preferred size, and will employ scrollbars if the table is larger than the preferred size. If this method is not called, the JTable will be placed in its own frame. The table is also placed in its own frame if this method is called with a null argument. The background of the table is set equal to that of the container (unless it is null).- Specified by:
place
in interfacePlaceable
- Specified by:
place
in classAbstractPlaceableActor
- Parameters:
container
- The container into which to place the table.
-
postfire
public boolean postfire() throws IllegalActionException
Consume a matrix token from the input port and display the token in a table. If a token is not available, do nothing.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If there is no director, or if the base class throws it.
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Override the base class to remove the display 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()
-
setDisplayName
public void setDisplayName(java.lang.String name)
Set a name to present to the user.If the MatrixViewer window has been rendered, then the title of the MatrixViewer 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()
-
setFrame
public void setFrame(javax.swing.JFrame frame)
Specify the associated frame and set its properties (size, etc.) to match those stored in the _windowProperties attribute. In this class, if the frame is null, close the tableau and set it to null. Once closed, the matrix window will not reopen unless _tableau is null.- Overrides:
setFrame
in classAbstractPlaceableActor
- Parameters:
frame
- The associated frame.
-
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 MatrixViewer window has been rendered, then the title of the MatrixViewer 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)
-
-