Class GraphicsMachine

java.lang.Object
  extended byGraphicsMachine
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(PSPath gStack, java.io.PipedWriter pw)
          Creates a new GraphicsMachine, "connects" it with a Graphics Stack and establishes a stream connection.
 
Method Summary
 void appendToOutputText(java.lang.String str)
          Adds to the output text of the GUI the one given.
 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 main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsMachine

public GraphicsMachine(PSPath gStack,
                       java.io.PipedWriter pw)
                throws java.io.IOException
Creates a new GraphicsMachine, "connects" it with a Graphics Stack and establishes a stream connection.

Parameters:
gStack - The Graphics Stack.
pw - The PipedWriter which initializes the PipedReader.
Throws:
java.io.IOException
Method Detail

main

public static void main(java.lang.String[] args)

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 the GUI.

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

appendToOutputText

public 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.

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