psgraphics
Class Figure

java.lang.Object
  extended bypsgraphics.Figure
Direct Known Subclasses:
DrawableArc, DrawableLine, DrawableString

public abstract class Figure
extends java.lang.Object

Abstract class which defines a new type of drawable figures.

The Figure class is the base abstract class for all drawable figures that can be displayed on the drawing area of the postscript interpreter.

A Figure object encapsulates state information needed for drawing it on screen, such as beginning and ending coordintes for lines, center coordinates, radius size, beginning and ending angles for arcs and so on. Every such object has a constructor which initializes these values upon the creation of the figure. The constructor has to be given every required parameter from the Runtime Stack. The responsibility for this operation is taken by the action() method defined for each path operator concerning drawable objects. Once the action() method is executed successfully, a Figure object is pushed in the Graphics Stack.

Every Figure object must implement a draw method which holds the actual rendering commands. Every time the frame with the drawing area is displayed on screen it calls a paint method. This method is overrided in order to read the Graphics Stack and call the draw method of every Figure object it finds.

Since the draw method uses java.awt.Graphics, the coordinate system uses the upper left corner of the drawing area as (0,0). Postscript uses the lower left corner for this purpose, so every y coordinate has to be substracted from the standard height of the drawing area before passed to the drawing methods of java.awt.Graphics.


Constructor Summary
Figure()
           
 
Method Summary
abstract  void draw(java.awt.Graphics g)
          Draws the Figure object on the drawing area of the postscript interpreter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Figure

public Figure()
Method Detail

draw

public abstract void draw(java.awt.Graphics g)
Draws the Figure object on the drawing area of the postscript interpreter.

Precondition : Must be called by the paint method of the component it draws on and given the same Graphics parameter.
Postcondition : The figure will be drawn on the drawing area.

Parameters:
g - The same Graphics parameter passed to the paint method of the drawing area.