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.
-
cols
- The number of columns on the drawing canvas.
-
grid
- A two dimensional array that is used as the drawing canvas or tablet.
-
rows
- The number of rows on the drawing canvas.
-
Graphics()
- Default constructor that constructs a 50 x 50 canvas.
-
Graphics(int, int)
- Two-parameter constructor.
-
clearRect(int, int, int, int)
-
Clear rectangle on grid by filling with spaces ' '.
-
drawBorder()
- Draws border around canvas.
-
drawLine(int, int, int, int)
-
Draw a line on the grid from point (x1,y1) to (x2,y2)
-
show()
-
Display the grid on the standard output.
grid
protected char grid[][]
- A two dimensional array that is used as the drawing canvas or tablet.
rows
protected int rows
- The number of rows on the drawing canvas.
cols
protected int cols
- The number of columns on the drawing canvas.
Graphics
public Graphics()
- Default constructor that constructs a 50 x 50 canvas.
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
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
show
public void show()
- Display the grid on the standard output.
- Returns:
- void
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
drawBorder
public void drawBorder()
- Draws border around canvas.
- Returns:
- void
All Packages Class Hierarchy This Package Previous Next Index