Class Rectangle

public class Rectangle
implements Shape

A rectangle shape.

Version:
$Id: Rectangle.java,v 1.3 2001/04/16 05:15:50 administrator Exp $
Author:
Ben Dugan

Constructor Detail

Rectangle

public Rectangle()
Create a new, filled rectangle, colored red.

Rectangle

public Rectangle(int x,
                 int y,
                 int width,
                 int height)
Create a new rectangle of the given size.
Parameters:
x - the x coordinate of the upper left corner
y - the y coordinate of the upper left corner
width - the width of the rectangle
height - the height of the rectangle

Rectangle

public Rectangle(int x,
                 int y,
                 int width,
                 int height,
                 java.awt.Color c,
                 boolean fill)
Create a new rectangle of the given size.
Parameters:
x - the x coordinate of the upper left corner
y - the y coordinate of the upper left corner
width - the width of the rectangle
height - the height of the rectangle
c - the color to draw/fill the rectangle
fill - should it be filled
Method Detail

intersects

public boolean intersects(Rectangle r)
This rectangle intersects the given rectangle if at least one of the other rectangle's verteces is contained within the bounds of this rectangle.

paint

public void paint(java.awt.Graphics g)
Paint/draw this rectangle onto the given graphics context.
Specified by:
paint in interface Shape
Overrides:
paint in class ShapeImpl

move

public void move(int x,
                 int y)
Translate this rectangle by the given amount.
Specified by:
move in interface Shape
Overrides:
move in class ShapeImpl
Following copied from interface: Shape
Parameters:
deltaX - offset in the X direction.
deltaY - offset in the Y direction.

toString

public java.lang.String toString()
Description copied from class: ShapeImpl
Answer the printed representation of this shape.
Overrides:
toString in class ShapeImpl

setWindow

public void setWindow(GWindow gw)
Attach the shape to the given window.
Specified by:
setWindow in interface Shape

intersects

public boolean intersects(Shape s)
Does this shape intersect the other shape?
Specified by:
intersects in interface Shape

getBoundingBox

public Rectangle getBoundingBox()
Answer the Rectangle that bounds this shape.
Specified by:
getBoundingBox in interface Shape

getColor

public java.awt.Color getColor()
Answer the color of this shape.
Specified by:
getColor in interface Shape

setColor

public void setColor(java.awt.Color c)
Set the color of this shape.
Specified by:
setColor in interface Shape