All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sg.Graphics

java.lang.Object
   |
   +----sg.Graphics

public class Graphics
extends Object
The class Graphics defines a simple character-oriented graphics device.


Variable Index

 o cols
The number of columns on the drawing canvas.
 o grid
A two dimensional array that is used as the drawing canvas or tablet.
 o rows
The number of rows on the drawing canvas.

Constructor Index

 o Graphics()
Default constructor that constructs a 50 x 50 canvas.
 o Graphics(int, int)
Two-parameter constructor.

Method Index

 o clearRect(int, int, int, int)
Clear rectangle on grid by filling with spaces ' '.
 o drawBorder()
Draws border around canvas.
 o drawLine(int, int, int, int)
Draw a line on the grid from point (x1,y1) to (x2,y2)
 o show()
Display the grid on the standard output.

Variables

 o grid
 protected char grid[][]
A two dimensional array that is used as the drawing canvas or tablet.

 o rows
 protected int rows
The number of rows on the drawing canvas.

 o cols
 protected int cols
The number of columns on the drawing canvas.

Constructors

 o Graphics
 public Graphics()
Default constructor that constructs a 50 x 50 canvas.

 o Graphics
 public Graphics(int rows,
                 int cols)
Two-parameter constructor.

Parameters:
rows - the number of rows for the newly constructed canvas
cols - the number of columns for the newly constructed canvas

Methods

 o clearRect
 public void clearRect(int x,
                       int y,
                       int width,
                       int height)
Clear rectangle on grid by filling with spaces ' '. Part (or all) of the rectangle can be off the canvas.

Parameters:
x - x-coordinate of the upper left-hand corner of rectangle to be cleared.
y - y-coordinate of the upper left-hand corner of rectangle to be cleared.
width - width of rectangle to be cleared.
height - height of rectangle to be cleared.
Returns:
void
 o show
 public void show()
Display the grid on the standard output.

Returns:
void
 o drawLine
 public void drawLine(int x1,
                      int y1,
                      int x2,
                      int y2)
Draw a line on the grid from point (x1,y1) to (x2,y2)

Parameters:
x1 - the x-coordinate of the starting point
y1 - the pixel (x1,y1) is the starting point for the line. It is permissable for this point to be off the canvas, in which case only the part that is actually on the canvas will be drawn.
x2 - the x-coordinate of the ending point
y2 - the pixel (x2,y2) is the ending point for the line. It does not have to be on the canvas either.
Returns:
void
 o drawBorder
 public void drawBorder()
Draws border around canvas.

Returns:
void

All Packages  Class Hierarchy  This Package  Previous  Next  Index