|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uwcse.graphics.ShapeImpl | +--uwcse.graphics.Rectangle
A rectangle shape. The main operations are to read the x and y coordinates of the upper-left corner of the rectangle (getX() and getY()), to change the position of the rectangle (moveBy(...) and moveTo(...)), to rotate the position of the rectangle around some point (rotateAround(...)), to read and change the color of the rectangle (getColor() and setColor(...)), to read and change the width and height of the rectangle (getWidth(), getHeight(), and resize(...)), and add to and remove from a GWindow (addTo(...) and removeFromWindow()). Other operations are mainly for internal use, and should not be called by regular client programs.
Constructor Summary | |
Rectangle()
Create a new, filled rectangle, colored red, with a default location and size. |
|
Rectangle(int x,
int y,
int width,
int height)
Create a new unfilled, black rectangle with the given position and size. |
|
Rectangle(int x,
int y,
int width,
int height,
java.awt.Color c,
boolean fill)
Create a new rectangle of the given position, size, color, and filledness. |
Method Summary | |
int |
getHeight()
Return the height of the rectangle |
int |
getWidth()
Return the width of the rectangle |
int |
getX()
Return the X coordinate of the rectangle's upper-left corner |
int |
getY()
Return the Y coordinate of the rectangle's upper-left corner |
boolean |
intersects(Rectangle r)
Return whether the argument rectangle intersects this rectangle |
void |
moveTo(int x,
int y)
Move the upper-left corner of the rectangle to the given coordinates. |
void |
paint(java.awt.Graphics g)
Paint this shape onto the given graphics context. |
void |
resize(int newWidth,
int newHeight)
Change the width and height of the rectangle |
java.lang.String |
toString()
Answer the printed representation of this shape. |
Methods inherited from class uwcse.graphics.ShapeImpl |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, intersects, moveBy, recordWindow, removeFromWindow, rotateAround, setColor |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uwcse.graphics.Shape |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, intersects, moveBy, recordWindow, removeFromWindow, rotateAround, setColor |
Constructor Detail |
public Rectangle()
public Rectangle(int x, int y, int width, int height)
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 rectanglepublic Rectangle(int x, int y, int width, int height, java.awt.Color c, boolean fill)
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 of the rectanglefill
- should it be filled?Method Detail |
public int getHeight()
getHeight
in interface Shape
getHeight
in class ShapeImpl
public int getWidth()
getWidth
in interface Shape
getWidth
in class ShapeImpl
public int getX()
getX
in interface Shape
getX
in class ShapeImpl
public int getY()
getY
in interface Shape
getY
in class ShapeImpl
public boolean intersects(Rectangle r)
public void moveTo(int x, int y)
moveTo
in interface Shape
moveTo
in class ShapeImpl
x
- new X coordinatey
- new Y coordinatepublic void paint(java.awt.Graphics g)
Shape
paint
in interface Shape
public void resize(int newWidth, int newHeight)
newWidth
- the new widthnewHeight
- the new heightpublic java.lang.String toString()
ShapeImpl
toString
in class ShapeImpl
|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |