Class DisplayJavaSE
- java.lang.Object
-
- ptolemy.actor.gui.AbstractPlaceableJavaSE
-
- ptolemy.actor.lib.gui.DisplayJavaSE
-
- All Implemented Interfaces:
DisplayInterface
public class DisplayJavaSE extends AbstractPlaceableJavaSE implements DisplayInterface
DisplayJavaSE is the implementation of the DisplayInterface that uses AWT and Swing classes. 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. Thus, string-valued tokens can be used to generate arbitrary textual output, at one token per line.
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 10.0
- Version:
- $Id$
- Author:
- Yuhong Xiong, Edward A. Lee Contributors: Ishwinder Singh
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.actor.gui.AbstractPlaceableJavaSE
AbstractPlaceableJavaSE.WindowClosingAdapter
-
-
Field Summary
Fields Modifier and Type Field Description javax.swing.JTextArea
textArea
The text area in which the data will be displayed.-
Fields inherited from class ptolemy.actor.gui.AbstractPlaceableJavaSE
_frame, _paneSize, _windowClosingAdapter, _windowProperties
-
-
Constructor Summary
Constructors Constructor Description DisplayJavaSE()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Free up memory when closing.void
display(java.lang.String value)
Append the string value of the token to the text area on the screen.java.lang.Object
getTextArea()
Return the object of the containing text area.void
init(Display displayActor)
Set the number of rows for the text area.void
openWindow()
Open the display window if it has not been opened.void
place(PortableContainer portableContainer)
Specify the container in which the data should be displayed.void
remove()
Remove the display from the current container, if there is one.void
setColumns(int numberOfColumns)
Set the desired number of columns of the textArea, if there is one.void
setRows(int numberOfRows)
Set the desired number of rows of the textArea, if there is one.void
setTitle(java.lang.String stringValue)
Set the title of the window.-
Methods inherited from class ptolemy.actor.gui.AbstractPlaceableJavaSE
_exportMoMLContents, init, setFrame
-
-
-
-
Method Detail
-
cleanUp
public void cleanUp()
Free up memory when closing. This is executed in the Swing event thread.- Specified by:
cleanUp
in interfaceDisplayInterface
- Overrides:
cleanUp
in classAbstractPlaceableJavaSE
-
display
public void display(java.lang.String value)
Append the string value of the token to the text area on the screen. Each value is terminated with a newline character. This is executed in the Swing event thread.- Specified by:
display
in interfaceDisplayInterface
- Parameters:
value
- The string to be displayed
-
getTextArea
public java.lang.Object getTextArea()
Return the object of the containing text area.- Specified by:
getTextArea
in interfaceDisplayInterface
- Returns:
- the text area.
-
init
public void init(Display displayActor) throws IllegalActionException, NameDuplicationException
Set the number of rows for the text area.- Specified by:
init
in interfaceDisplayInterface
- Parameters:
displayActor
- The display actor to be initialized.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
openWindow
public void openWindow() throws IllegalActionException
Open the display window if it has not been opened.- Specified by:
openWindow
in interfaceDisplayInterface
- Throws:
IllegalActionException
- If there is a problem creating the effigy and tableau. This is executed in the Swing event thread.
-
place
public void place(PortableContainer portableContainer)
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). This is executed in the Swing event thread.- Specified by:
place
in interfaceDisplayInterface
- Parameters:
portableContainer
- The container into which to place the text area, or null to specify that there is no current container.
-
remove
public void remove()
Remove the display from the current container, if there is one. This is executed in the Swing thread later.- Specified by:
remove
in interfaceDisplayInterface
-
setColumns
public void setColumns(int numberOfColumns) throws IllegalActionException
Set the desired number of columns of the textArea, if there is one. This is executed in the Swing event thread.- Specified by:
setColumns
in interfaceDisplayInterface
- Parameters:
numberOfColumns
- The new value of the attribute.- Throws:
IllegalActionException
- If the specified attribute is rowsDisplayed and its value is not positive.
-
setRows
public void setRows(int numberOfRows) throws IllegalActionException
Set the desired number of rows of the textArea, if there is one. This is executed in the Swing event thread.- Specified by:
setRows
in interfaceDisplayInterface
- Parameters:
numberOfRows
- The new value of the attribute.- Throws:
IllegalActionException
- If the specified attribute is rowsDisplayed and its value is not positive.
-
setTitle
public void setTitle(java.lang.String stringValue) throws IllegalActionException
Set the title of the window.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.
This is executed in the Swing event thread.- Specified by:
setTitle
in interfaceDisplayInterface
- Parameters:
stringValue
- The title to be set.- Throws:
IllegalActionException
- If the title cannot be set.
-
-