|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Canvas
public class Canvas
Class Canvas - a class to allow for simple graphical drawing on a canvas.
Nested Class Summary | |
---|---|
protected class |
Canvas.CanvasPane
Nested class CanvasPane - the actual canvas component contained in the Canvas frame. |
Field Summary | |
---|---|
protected Canvas.CanvasPane |
canvas
|
Constructor Summary | |
---|---|
Canvas()
Create a Canvas with default title, height, width and background color ("Canvas", 300, 300, white). |
|
Canvas(java.lang.String title)
Create a Canvas with default height, width and background color (300, 300, white). |
Method Summary | |
---|---|
void |
drawFilledOval(int x1,
int y1,
int x2,
int y2)
Draws a filled oval on the Canvas. |
void |
drawFilledPolygon(int[] x,
int[] y,
int size)
Draws a filled polygon on the Canvas. |
void |
drawFilledRectangle(int x1,
int y1,
int x2,
int y2)
Draws a filled rectangle on the Canvas. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line on the Canvas. |
void |
drawOval(int x1,
int y1,
int x2,
int y2)
Draws an oval on the Canvas. |
void |
drawPolygon(int[] x,
int[] y,
int size)
Draws a polygon on the Canvas. |
void |
drawRectangle(int x1,
int y1,
int x2,
int y2)
Draws a rectangle on the Canvas. |
void |
drawString(java.lang.String text,
int x,
int y)
Draws a String on the Canvas. |
void |
erase()
Erase the whole canvas. |
void |
eraseOval(int x1,
int y1,
int x2,
int y2)
Erases an oval on the Canvas. |
void |
eraseRectangle(int x1,
int y1,
int x2,
int y2)
Erases a rectangle on the Canvas. |
void |
eraseString(java.lang.String text,
int x,
int y)
Erases a String on the Canvas. |
void |
fillBackground(java.awt.Color newColor)
Fills in the Canvas (background) with the specified color. |
java.awt.Font |
getFont()
Returns the current font of the canvas. |
java.awt.Color |
getInkColor()
Returns the current pen color. |
boolean |
isVisible()
Provide information on visibility of the Canvas. |
void |
setFont(java.awt.Font newFont)
changes the current Font used on the Canvas |
void |
setFontSize(int newSize)
Sets the point size of the current font to the specified value. |
void |
setInkColor(java.awt.Color newColor)
Sets the "pen" (outline) color for the Canvas. |
void |
setSize(int width,
int height)
Sets the size of the canvas. |
void |
setVisible(boolean visible)
Set the canvas visibility and brings canvas to the front of screen when made visible. |
void |
wait(int milliseconds)
Waits for a specified number of milliseconds before finishing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Canvas.CanvasPane canvas
Constructor Detail |
---|
public Canvas(java.lang.String title)
title
- title to appear in Canvas Framepublic Canvas()
Method Detail |
---|
public void setInkColor(java.awt.Color newColor)
newColor
- The color to which to set the pen/drawing tool.public java.awt.Color getInkColor()
public void setVisible(boolean visible)
visible
- boolean value representing the desired visibility of
the canvas (true or false)public boolean isVisible()
public void erase()
public void drawString(java.lang.String text, int x, int y)
text
- the String to be displayedx
- x co-ordinate for text placementy
- y co-ordinate for text placementpublic void eraseString(java.lang.String text, int x, int y)
text
- the String to be displayedx
- x co-ordinate for text placementy
- y co-ordinate for text placementpublic void drawLine(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of start of liney1
- y co-ordinate of start of linex2
- x co-ordinate of end of liney2
- y co-ordinate of end of linepublic void drawRectangle(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void drawFilledRectangle(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void drawPolygon(int[] x, int[] y, int size)
x
- array of x co-ordinates of polygon pointsy
- array of y co-ordinates of polygon pointssize
- the number of points (vertices) in the polygonpublic void drawFilledPolygon(int[] x, int[] y, int size)
x
- array of x co-ordinates of polygon pointsy
- array of y co-ordinates of polygon pointssize
- the number of points (vertices) in the polygonpublic void eraseRectangle(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void drawOval(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void drawFilledOval(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void eraseOval(int x1, int y1, int x2, int y2)
x1
- x co-ordinate of top left cornery1
- y co-ordinate of top left cornerx2
- widthy2
- heightpublic void fillBackground(java.awt.Color newColor)
newColor
- the new color for the background of the Canvaspublic void setFont(java.awt.Font newFont)
newFont
- new font to be used for String outputpublic java.awt.Font getFont()
public void setFontSize(int newSize)
newSize
- the new point sizepublic void setSize(int width, int height)
width
- new widthheight
- new heightpublic void wait(int milliseconds)
milliseconds
- the number
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |