|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectacm.graphics.GRectangle
public class GRectangle
This class is a double-precision version of the Rectangle
class
in java.awt
.
Constructor Summary | |
---|---|
GRectangle()
GRectangle . |
|
GRectangle(double width,
double height)
GRectangle at the origin with the specified width and height. |
|
GRectangle(double x,
double y,
double width,
double height)
GRectangle with the specified coordinates and size. |
|
GRectangle(GDimension size)
GRectangle at the origin with the specified size. |
|
GRectangle(GPoint pt)
GRectangle at the specified location. |
|
GRectangle(GPoint pt,
GDimension size)
GRectangle with the specified location and size. |
|
GRectangle(GRectangle r)
GRectangle from an existing one. |
Method Summary | |
---|---|
void |
add(double x,
double y)
|
void |
add(GRectangle r)
GRectangle so that it contains
the rectangle represented by the argument. |
boolean |
contains(double x,
double y)
true if the GRectangle contains the specified point. |
boolean |
contains(GPoint pt)
true if the GRectangle contains the specified point. |
GRectangle |
getBounds()
GRectangle whose bounds are the same as this one. |
double |
getHeight()
GDimension . |
GPoint |
getLocation()
GPoint with the location of the rectangle. |
GDimension |
getSize()
GDimension object with the size of the GRectangle . |
double |
getWidth()
GDimension . |
double |
getX()
GRectangle . |
double |
getY()
GRectangle . |
void |
grow(double dx,
double dy)
dx and dy
offsets along each of its borders. |
GRectangle |
intersection(GRectangle r2)
r1 and r2 . |
boolean |
intersects(GRectangle r2)
true if r1 and r2 have a nonempty
intersection. |
boolean |
isEmpty()
true if the rectangle is empty. |
void |
setBounds(double x,
double y,
double width,
double height)
GRectangle from the specified values. |
void |
setBounds(GPoint pt,
GDimension size)
GRectangle from the specified location and size. |
void |
setBounds(GRectangle bounds)
GRectangle equal to that of another. |
void |
setLocation(double x,
double y)
GRectangle to the specified x
and y values. |
void |
setLocation(GPoint pt)
GRectangle to the specified point. |
void |
setSize(double width,
double height)
GRectangle to the specified values. |
void |
setSize(GDimension size)
GRectangle to the specified dimension. |
Rectangle |
toRectangle()
GRectangle to the nearest integer-based Rectangle . |
void |
translate(double dx,
double dy)
dx and
dy offsets. |
GRectangle |
union(GRectangle r2)
r1 and r2 . |
Constructor Detail |
---|
public GRectangle()
GRectangle
.
Usage: | rect = new GRectangle(); |
public GRectangle(double width,
double height)
GRectangle
at the origin with the specified width and height.
Usage: | rect = new GRectangle(width, height); | ||||
Parameters: |
|
public GRectangle(double x,
double y,
double width,
double height)
GRectangle
with the specified coordinates and size.
Usage: | rect = new GRectangle(x, y, width, height); | ||||||||
Parameters: |
|
public GRectangle(GDimension size)
GRectangle
at the origin with the specified size.
Usage: | rect = new GRectangle(size); | ||
Parameter: |
|
public GRectangle(GPoint pt)
GRectangle
at the specified location.
Usage: | rect = new GRectangle(pt); | ||
Parameter: |
|
public GRectangle(GPoint pt,
GDimension size)
GRectangle
with the specified location and size.
Usage: | rect = new GRectangle(pt, size); | ||||
Parameters: |
|
public GRectangle(GRectangle r)
GRectangle
from an existing one.
Usage: | rect = new GRectangle(r); | ||
Parameter: |
|
Method Detail |
---|
public void add(double x,
double y)
Usage: | rect.add(x, y); | ||||
Parameters: |
|
public void add(GRectangle r)
GRectangle
so that it contains
the rectangle represented by the argument.
Usage: | rect.add(r); | ||
Parameter: |
|
public boolean contains(double x,
double y)
true
if the GRectangle
contains the specified point.
Usage: | if (rect.contains(x, y)) . . . | ||||
Parameters: |
| ||||
Returns: | true if the rectangle contains (x , y ),
and false otherwise
|
public boolean contains(GPoint pt)
true
if the GRectangle
contains the specified point.
Usage: | if (rect.contains(pt)) . . . | ||
Parameter: |
| ||
Returns: | true if the rectangle contains pt ,
and false otherwise
|
public GRectangle getBounds()
GRectangle
whose bounds are the same as this one.
Usage: | r = rect.getBounds(); |
Returns: | A new rectangle with the same bounds |
public double getHeight()
GDimension
.
Usage: | height = rect.getHeight(); |
Returns: | The height of this GDimension
|
public GPoint getLocation()
GPoint
with the location of the rectangle.
Usage: | pt = rect.getLocation(); |
Returns: | The location of the rectangle as a GPoint
|
public GDimension getSize()
GDimension
object with the size of the GRectangle
.
Usage: | size = rect.getSize(); |
Returns: | The size of the rectangle as a GDimension
|
public double getWidth()
GDimension
.
Usage: | width = rect.getWidth(); |
Returns: | The width of this GDimension
|
public double getX()
GRectangle
.
Usage: | x = rect.getX(); |
Returns: | The x coordinate of this GRectangle
|
public double getY()
GRectangle
.
Usage: | y = rect.getY(); |
Returns: | The y coordinate of this GRectangle
|
public void grow(double dx,
double dy)
dx
and dy
offsets along each of its borders.
Usage: | rect.grow(dx, dy); | ||||
Parameters: |
|
public GRectangle intersection(GRectangle r2)
r1
and r2
.
Usage: | r3 = r1.intersection(r2); | ||
Parameter: |
| ||
Returns: | The intersection of this rectangle and r2
|
public boolean intersects(GRectangle r2)
true
if r1
and r2
have a nonempty
intersection.
Usage: | if (r1.intersects(r2)) . . . | ||
Parameter: |
| ||
Returns: | true if the two rectangles intersect, and false otherwise
|
public boolean isEmpty()
true
if the rectangle is empty.
Usage: | if (rect.isEmpty()) . . . |
Returns: | true if the rectangle is empty, and false otherwise
|
public void setBounds(double x,
double y,
double width,
double height)
GRectangle
from the specified values.
Usage: | rect.setBounds(x, y, width, height); | ||||||||
Parameters: |
|
public void setBounds(GPoint pt,
GDimension size)
GRectangle
from the specified location and size.
Usage: | rect.setBounds(pt, size); | ||||
Parameters: |
|
public void setBounds(GRectangle bounds)
GRectangle
equal to that of another.
Usage: | rect.setBounds(bounds); | ||
Parameter: |
|
public void setLocation(double x,
double y)
GRectangle
to the specified x
and y
values.
Usage: | rect.setLocation(x, y); | ||||
Parameters: |
|
public void setLocation(GPoint pt)
GRectangle
to the specified point.
Usage: | rect.setLocation(pt); | ||
Parameter: |
|
public void setSize(double width,
double height)
GRectangle
to the specified values.
Usage: | rect.setSize(width, height); | ||||
Parameters: |
|
public void setSize(GDimension size)
GRectangle
to the specified dimension.
Usage: | rect.setSize(size); | ||
Parameter: |
|
public Rectangle toRectangle()
GRectangle
to the nearest integer-based Rectangle
.
Usage: | size = dim.toRectangle(); |
Returns: | The closest integer-based Rectangle
|
public void translate(double dx,
double dy)
dx
and
dy
offsets.
Usage: | rect.translate(dx, dy); | ||||
Parameters: |
|
public GRectangle union(GRectangle r2)
r1
and r2
.
Usage: | r3 = r1.union(r2); | ||
Parameter: |
| ||
Returns: | The union of this rectangle and r2
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |