|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--graphics.Window
A Window that can be drawn onto. Various shapes can be drawn onto this window. Mouse events are also trapped and recorded. The following code shows how a Window might be used
Window win = new Window();
// Create a circle centred on (50, 100) with a radius of 50.
Circle c = new Circle(50, 100, 50);
// Now draw the circle on the window
win.draw(c);
| Constructor Summary | |
Window()
Construct a window of 500 by 400 pixels |
|
Window(int x,
int y)
Construct a window. |
|
| Method Summary | |
void |
clear(Shape shape)
Clears a shape. |
void |
draw(Point p)
Draw a point using the current foreground colour. |
void |
draw(Shape shape)
Draw any of the graphics shapes (for example a Circle) in the current foreground colour. |
void |
erase(Shape shape)
Erases a shape. |
void |
fill(Shape shape)
Fills a shape with the current foreground colour. |
Color |
getBackground()
Get the background colour |
Color |
getForeground()
Get the foreground colour |
Point |
getMouse()
Get the current mouse position |
Point |
getMousePress()
Get the last point where the mouse was pressed. |
boolean |
isPressed()
Determine if the mouse is pressed or not. |
void |
setAntiAliasing(boolean alias)
Turns anti-aliasing on or off. |
void |
setBackground(Color c)
Set the background colour Used by the erase and clear commands. |
void |
setForeground(Color c)
Set the foreground colour All draw and fill commands will now use this colour. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Window(int x,
int y)
x - The width of the window in pixelsy - The height of the window in pixelspublic Window()
| Method Detail |
public void draw(Shape shape)
shape - The shape to drawpublic void draw(Point p)
public void fill(Shape shape)
shape - Shape to be filledpublic void erase(Shape shape)
shape - The shape to erase.public void clear(Shape shape)
shape - The shape to clear.public void setForeground(Color c)
c - The new foreground colour.public Color getForeground()
public void setBackground(Color c)
c - The background colour.public Color getBackground()
public boolean isPressed()
public Point getMouse()
public Point getMousePress()
public void setAntiAliasing(boolean alias)
A disadvantage is that images can take longer to draw.
Look up google for a better explanation.
alias - true if we want anti-aliasing, false otherwise.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||