Class 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
    • Field Detail

      • textArea

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

      • DisplayJavaSE

        public DisplayJavaSE()
    • Method Detail

      • 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 interface DisplayInterface
        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 interface DisplayInterface
        Returns:
        the text area.
      • 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 interface DisplayInterface
        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 interface DisplayInterface
      • 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 interface DisplayInterface
        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 interface DisplayInterface
        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 interface DisplayInterface
        Parameters:
        stringValue - The title to be set.
        Throws:
        IllegalActionException - If the title cannot be set.