psengines
Class GraphicsMachine

java.lang.Object
  extended bypsengines.GraphicsMachine
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener

public class GraphicsMachine
extends java.lang.Object
implements java.awt.event.KeyListener

As the name of this class implies, it represents the Graphics Machine of the postscript interpreter.

The Graphics Machine is responsible for everything concerning drawing on screen, including the GUI. It has to be initialized with the Graphics Stack as its one parameter and a PipedWriter as its other. Then, using the method InitGUI(), two JFrame windows are created for the input-output and the drawing area, including JScrollPanes, a JTextField and a JTextArea. The drawing area window also uses the class DrawingArea. The Graphics Stack pointer is passed to the DrawingArea class upon its creation, which processes it and performs the drawing of the postscript graphics.


Constructor Summary
GraphicsMachine()
          Initializes some fields of the object.
 
Method Summary
static void appendToOutputText(java.lang.String str)
          Adds to the output text of the GUI the one given.
 PSPath getGraphicsStack()
          Returns the PSPath object used for input.
 java.io.PipedWriter getPipedWriter()
          Returns the PipedWriter object used for input.
 void InitGUI()
          Creates the GUI which consists of two windows: the console input-output and the drawing area.
 void keyPressed(java.awt.event.KeyEvent e)
          Implements the KeyListener interface and handles the event of pressing ENTER while typing on the input text field, so that the text is processed and cleared.
 void keyReleased(java.awt.event.KeyEvent e)
          Implements KeyListener -- NOT USED
 void keyTyped(java.awt.event.KeyEvent e)
          Implements KeyListener -- NOT USED
static void showPage()
          Static method used mainly by the showpage operator to show graphics frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsMachine

public GraphicsMachine()
Initializes some fields of the object.

Method Detail

InitGUI

public void InitGUI()
Creates the GUI which consists of two windows: the console input-output and the drawing area.

Postcondition : The GUI will be initialized and displayed on screen.


getPipedWriter

public java.io.PipedWriter getPipedWriter()
Returns the PipedWriter object used for input.

Postcondition : A valid PipedWriter is returned, responsible for input from Program Loader.

Returns:
a reference to the PipedWriter used by the Graphics Machine.

getGraphicsStack

public PSPath getGraphicsStack()
Returns the PSPath object used for input.

Postcondition : A valid PSPath is returned, problably used by an execution engine object.

Returns:
a reference to the PSPath

appendToOutputText

public static void appendToOutputText(java.lang.String str)
Adds to the output text of the GUI the one given.

Precondition : A valid String is given as parameter.
Postcondition : The text contained in the output text area is extended.

Parameters:
str - The string which represents the new text for the GUI output.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Implements the KeyListener interface and handles the event of pressing ENTER while typing on the input text field, so that the text is processed and cleared.

Postcondition : After pressing ENTER the text on the text field is taken as input.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - Holds the pressed key information.

showPage

public static void showPage()
Static method used mainly by the showpage operator to show graphics frame.

Precondition : A valid instance of GraphicsMachine.
Postcondition : The second frame becomes visible and focused.


keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Implements KeyListener -- NOT USED

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Implements KeyListener -- NOT USED

Specified by:
keyTyped in interface java.awt.event.KeyListener