|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--acm.graphics.GRectangle
public class GRectangle extends Object
This class is a double-precision version of the Rectangle class in java.awt.
Constructor Summary |
GRectangle() |
GRectangle(double width,
double height) |
GRectangle(double x,
double y,
double width,
double height) |
GRectangle(GDimension size) |
GRectangle(GPoint pt) |
GRectangle(GPoint pt,
GDimension size) |
GRectangle(GRectangle r) |
Method Summary | |
void | add(double x,
double y) |
void | add(GRectangle r) |
boolean | contains(double x,
double y) |
boolean | contains(GPoint pt) |
GRectangle | getBounds() |
double | getHeight() |
GPoint | getLocation() |
GDimension | getSize() |
double | getWidth() |
double | getX() |
double | getY() |
void | grow(double dx,
double dy) |
GRectangle | intersection(GRectangle r) |
boolean | intersects(GRectangle r) |
boolean | isEmpty() |
void | setBounds(double x,
double y,
double width,
double height) |
void | setBounds(GPoint pt,
GDimension size) |
void | setBounds(GRectangle bounds) |
void | setLocation(double x,
double y) |
void | setLocation(GPoint pt) |
void | setSize(double width,
double height) |
void | setSize(GDimension size) |
Rectangle | toRectangle() |
void | translate(double dx,
double dy) |
GRectangle | union(GRectangle r) |
Constructor Detail |
public GRectangle()
Usage: | rect = new GRectangle(); |
public GRectangle(double width,
double height)
Usage: | rect = new GRectangle(width, height); | ||||
Parameters: |
|
public GRectangle(double x,
double y,
double width,
double height)
Usage: | rect = new GRectangle(x, y, width, height); | ||||||||
Parameters: |
|
public GRectangle(GDimension size)
Usage: | rect = new GRectangle(size); | ||
Parameter: |
|
public GRectangle(GPoint pt)
Usage: | rect = new GRectangle(pt); | ||
Parameter: |
|
public GRectangle(GPoint pt,
GDimension size)
Usage: | rect = new GRectangle(pt, size); | ||||
Parameters: |
|
public GRectangle(GRectangle r)
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)
Usage: | rect.add(r); | ||
Parameter: |
|
public boolean contains(double x,
double y)
Usage: | if (rect.contains(x, y)) . . . | ||||
Parameters: |
| ||||
Returns: | true if the rectangle contains (x, y), and false otherwise |
public boolean contains(GPoint pt)
Usage: | if (rect.contains(pt)) . . . | ||
Parameter: |
| ||
Returns: | true if the rectangle contains pt, and false otherwise |
public GRectangle getBounds()
Usage: | r = rect.getBounds(); |
Returns: | A new rectangle with the same bounds |
public double getHeight()
Usage: | height = rect.getHeight(); |
Returns: | The height of this GDimension |
public GPoint getLocation()
Usage: | pt = rect.getLocation(); |
Returns: | The location of the rectangle as a GPoint |
public GDimension getSize()
Usage: | size = rect.getSize(); |
Returns: | The size of the rectangle as a GDimension |
public double getWidth()
Usage: | width = rect.getWidth(); |
Returns: | The width of this GDimension |
public double getX()
Usage: | x = rect.getX(); |
Returns: | The x coordinate of this GRectangle |
public double getY()
Usage: | y = rect.getY(); |
Returns: | The y coordinate of this GRectangle |
public void grow(double dx,
double dy)
Usage: | rect.grow(dx, dy); | ||||
Parameters: |
|
public GRectangle intersection(GRectangle r)
Usage: | r3 = r1.intersection(r2); | ||
Parameter: |
| ||
Returns: | The intersection of this rectangle and r2 |
public boolean intersects(GRectangle r)
Usage: | if (r1.intersects(r2)) . . . | ||
Parameter: |
| ||
Returns: | true if the two rectangles intersect, and false otherwise |
public boolean isEmpty()
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)
Usage: | rect.setBounds(x, y, width, height); | ||||||||
Parameters: |
|
public void setBounds(GPoint pt,
GDimension size)
Usage: | rect.setBounds(pt, size); | ||||
Parameters: |
|
public void setBounds(GRectangle bounds)
Usage: | rect.setBounds(bounds); | ||
Parameter: |
|
public void setLocation(double x,
double y)
Usage: | rect.setLocation(x, y); | ||||
Parameters: |
|
public void setLocation(GPoint pt)
Usage: | rect.setLocation(pt); | ||
Parameter: |
|
public void setSize(double width,
double height)
Usage: | rect.setSize(width, height); | ||||
Parameters: |
|
public void setSize(GDimension size)
Usage: | rect.setSize(size); | ||
Parameter: |
|
public Rectangle toRectangle()
Usage: | size = dim.toRectangle(); |
Returns: | The closest integer-based Rectangle |
public void translate(double dx,
double dy)
Usage: | rect.translate(dx, dy); | ||||
Parameters: |
|
public GRectangle union(GRectangle r)
Usage: | r3 = r1.union(r2); | ||
Parameter: |
| ||
Returns: | The union of this rectangle and r2 |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |