|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCanvas
public class Canvas
Class Canvas - a class to allow for simple graphical drawing on a canvas.
Constructor Summary | |
---|---|
Canvas(String title)
Create a Canvas with default height, width and background color (300, 300, white). |
|
Canvas(String title,
int width,
int height)
Create a Canvas with default background color (white). |
|
Canvas(String title,
int width,
int height,
Color bgColor,
int locX,
int locY)
Create a Canvas. |
Method Summary | |
---|---|
void |
closeCanvas()
close the window This method sets the Canvas to invisible, then disposes of it. |
void |
draw(Shape shape)
Draws the given shape with the current foreground color of the canvas. |
void |
drawCircle(int xPos,
int yPos,
int diameter)
Draws a circle with the current foreground color of the canvas. |
boolean |
drawImage(Image image,
int x,
int y)
Draws an image onto the canvas. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line on the Canvas. |
void |
drawRectangle(int xPos,
int yPos,
int width,
int height)
Draws a rectangle with the current foreground color of the canvas. |
void |
drawString(String text,
int x,
int y)
Draws a String on the Canvas. |
void |
erase()
Erase the whole canvas. |
void |
erase(Shape shape)
Erase a portion of the canvas with the given shape. |
void |
eraseCircle(int xPos,
int yPos,
int diameter)
Erases a portion of the canvas in the shape of a circle. |
void |
eraseOutline(Shape shape)
Erases a given shape's outline on the screen. |
void |
eraseRectangle(int xPos,
int yPos,
int width,
int height)
Erase a portion of the canvas in the shape of a rectangle. |
void |
fill(Shape shape)
Fill the internal dimensions of a given shape with the current foreground color of the canvas. |
void |
fillCircle(int xPos,
int yPos,
int diameter)
Fill the internal dimensions of the given circle with the current foreground color of the canvas. |
void |
fillRectangle(int xPos,
int yPos,
int width,
int height)
Fill the internal dimensions of the given rectangle with the current foreground color of the canvas. |
Color |
getBackgroundColor()
Returns the current color of the background |
Font |
getFont()
Returns the current font of the canvas. |
Color |
getForegroundColor()
Returns the current color of the foreground. |
Dimension |
getSize()
Returns the size of the canvas. |
boolean |
isVisible()
Provide information on visibility of the Canvas. |
void |
refresh()
Refreshes the drawing the the canvas, to help with things that aren't showing up. |
void |
setBackgroundColor(Color newColor)
Sets the background color of the Canvas. |
void |
setFont(Font newFont)
changes the current Font used on the Canvas |
void |
setForegroundColor(Color newColor)
Sets the foreground color of 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 |
Constructor Detail |
---|
public Canvas(String title)
title
- title to appear in Canvas Framepublic Canvas(String title, int width, int height)
title
- title to appear in Canvas Framewidth
- the desired width for the canvasheight
- the desired height for the canvaspublic Canvas(String title, int width, int height, Color bgColor, int locX, int locY)
title
- title to appear in Canvas Framewidth
- the desired width for the canvasheight
- the desired height for the canvasbgClour
- the desired background color of the canvaslocX
- x-coordinate of upper left corner of windowlocY
- y-coordinate of upper left corner of windowMethod Detail |
---|
public void closeCanvas()
public void draw(Shape shape)
shape
- the shape object to be drawnpublic void drawCircle(int xPos, int yPos, int diameter)
public boolean drawImage(Image image, int x, int y)
image
- the Image object to be displayedx
- x co-ordinate for Image placementy
- y co-ordinate for Image placement
public 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 xPos, int yPos, int width, int height)
public void drawString(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 erase()
public void erase(Shape shape)
shape
- the shape object to be erasedpublic void eraseCircle(int xPos, int yPos, int diameter)
public void eraseOutline(Shape shape)
shape
- the shape object to be erasedpublic void eraseRectangle(int xPos, int yPos, int width, int height)
public void fill(Shape shape)
shape
- the shape object to be filledpublic void fillCircle(int xPos, int yPos, int diameter)
public void fillRectangle(int xPos, int yPos, int width, int height)
public Color getBackgroundColor()
public Font getFont()
public Color getForegroundColor()
public Dimension getSize()
public boolean isVisible()
public void refresh()
public void setBackgroundColor(Color newColor)
newColor
- the new color for the background of the Canvaspublic void setFont(Font newFont)
newFont
- new font to be used for String outputpublic void setForegroundColor(Color newColor)
newColor
- the new color for the foreground of the Canvaspublic void setSize(int width, int height)
width
- new widthheight
- new heightpublic void setVisible(boolean visible)
visible
- boolean value representing the desired visibility of
the canvas (true or false)public void wait(int milliseconds)
milliseconds
- the number
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |