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
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 cornery
- the y coordinate of the upper left cornerwidth
- the width of the rectangleheight
- 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 cornery
- the y coordinate of the upper left cornerwidth
- the width of the rectangleheight
- the height of the rectanglec
- the color to draw/fill the rectanglefill
- should it be filled
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