|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.geom.RectangularShape | +--java.awt.geom.Rectangle2D | +--java.awt.Rectangle | +--gishur.gui2.RectangleShape
A RectangleShape specifies an area in a coordinate space that is
defined by the rectangle's top-left point (x,y)
in
the coordinate space, its width
, and its
height
. RectangleShape extends the Java AWT's Rectangle
class in order to implement Shape
.
Inner classes inherited from class java.awt.geom.Rectangle2D |
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float |
Fields inherited from class java.awt.Rectangle |
height, width, x, y |
Fields inherited from class java.awt.geom.Rectangle2D |
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
Constructor Summary | |
RectangleShape()
Constructs a new RectangleShape whose top-left corner is at (0,0) in the coordinate space, and whose
width and height are zero. |
|
RectangleShape(int width,
int height)
Constructs a new RectangleShape whose top-left corner is at (0,0) and whose width and height
are specified by the arguments of the same name. |
|
RectangleShape(int x,
int y,
int width,
int height)
Constructs a new RectangleShape whose top-left corner is specified as (x,y) and whose width and height
are specified by the arguments of the same name. |
|
RectangleShape(java.awt.Rectangle r)
Constructs a new RectangleShape, initialized to match the values of the specificed rectangle. |
Method Summary | |
void |
clear()
|
java.lang.Object |
clone()
Creates a new object of the same class as this object. |
boolean |
contains(int x,
int y,
int w,
int h)
Tests if the interior of the RectangleShape entirely contains the specified rectangular area. |
void |
draw(java.awt.Graphics g)
Strokes the outline of the RectangleShape using the settings of the Graphics context. |
void |
fill(java.awt.Graphics g)
Fills the interior of the RectangleShape using the settings of the Graphics context. |
RectangleShape |
getBoundShape()
Return the bounding box of the RectangleShape. |
java.awt.Point |
getCenter()
Returns the center point of the framing rectangle of the RectangleShape. |
int |
getCenterX()
Returns the X coordinate of the center of the framing rectangle of the RectangleShape. |
int |
getCenterY()
Returns the Y coordinate of the center of the framing rectangle of the RectangleShape. |
boolean |
intersects(int x,
int y,
int w,
int h)
Tests if the interior of the RectangleShape intersects the interior of a specified rectangular area. |
void |
set(int x,
int y,
int width,
int height)
Sets the RectangleShape to the specified values. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
translate(int dx,
int dy)
Translates this RectangleShape by the vector (x,y) . |
RectangleShape |
uniteWith(int x,
int y,
int width,
int height)
Computes the union of this RectangleShape with the
specified rectangular area. |
RectangleShape |
uniteWith(java.awt.Rectangle r)
Computes the union of this RectangleShape with the
specified Rectangle . |
Methods inherited from class java.awt.Rectangle |
add, add, add, contains, contains, contains, createIntersection, createUnion, equals, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, union |
Methods inherited from class java.awt.geom.Rectangle2D |
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union |
Methods inherited from class java.awt.geom.RectangularShape |
contains, contains, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gishur.gui2.Shape |
contains, contains, setLocation |
Methods inherited from interface java.awt.Shape |
contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, intersects, intersects |
Constructor Detail |
public RectangleShape()
(0,0)
in the coordinate space, and whose
width
and height
are zero.public RectangleShape(int width, int height)
(0,0)
and whose width
and height
are specified by the arguments of the same name.width
- the width.height
- the height.public RectangleShape(int x, int y, int width, int height)
(x,y)
and whose width
and height
are specified by the arguments of the same name.x
- the x coordinate.y
- the y coordinate.width
- the width.height
- the height.public RectangleShape(java.awt.Rectangle r)
r
- a rectangle from which to copy initial values.Method Detail |
public java.lang.String toString()
toString
in class java.awt.Rectangle
public java.lang.Object clone()
clone
in interface Cloneable
clone
in class java.awt.geom.RectangularShape
OutOfMemoryError
- if there is not enough memory.Cloneable
public void clear()
public final RectangleShape uniteWith(int x, int y, int width, int height)
this
RectangleShape with the
specified rectangular area. If the given rectangle has zero (or less) width
or height, the whole rectangle will be ignored. If this RectangleShape
has zero (or less) width or height, it will be set to the coordinates of the
given Rectangle.x,y
- upper left point of the other rectanglewidth
- the width of the other rectangleheight
- the height of the other rectanglethis
modified RectangleShapepublic RectangleShape uniteWith(java.awt.Rectangle r)
this
RectangleShape with the
specified Rectangle
. If the given Rectangle
has zero (or less) width or height, the whole rectangle will be
ignored. If this
RectangleShape
has zero
(or less) width or height, it will be set to the coordinates of the
given Rectangle
.r
- the specified RectangleShapethis
modified RectangleShapepublic void set(int x, int y, int width, int height)
RectangleShape
to the specified values.x,y
- new position of the upper left cornerwidth
- new widthheight
- new heightpublic boolean intersects(int x, int y, int w, int h)
intersects
in interface Shape
x, y
- the coordinates of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the Shape
and
the interior of the rectangular area intersect;
false
otherwise.public boolean contains(int x, int y, int w, int h)
Shape
.contains
in interface Shape
contains
in class java.awt.Rectangle
x, y
- the coordinates of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the Shape
entirely contains the specified rectangular area;
false
otherwise.intersects(int, int, int, int)
public RectangleShape getBoundShape()
getBoundShape
in interface Shape
public int getCenterX()
getCenterX
in interface Shape
getCenterX
in class java.awt.geom.RectangularShape
public int getCenterY()
getCenterY
in interface Shape
getCenterY
in class java.awt.geom.RectangularShape
public java.awt.Point getCenter()
getCenter
in interface Shape
public void translate(int dx, int dy)
this
RectangleShape by the vector (x,y)
.translate
in interface Shape
translate
in class java.awt.Rectangle
dx
- x coordinate of the translation vectordy
- y coordinate of the translation vectorpublic void draw(java.awt.Graphics g)
Graphics
context.draw
in interface Shape
g
- Graphics contextpublic void fill(java.awt.Graphics g)
Graphics
context.fill
in interface Shape
g
- Graphics context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |