Methods Summary |
---|
public java.lang.Object | clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
|
public boolean | contains(java.awt.geom.Point2D point)
return contains(point.getX(), point.getY());
|
public boolean | contains(java.awt.geom.Rectangle2D rect)
return contains(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
public java.awt.Rectangle | getBounds()
int x1 = (int)Math.floor(getMinX());
int y1 = (int)Math.floor(getMinY());
int x2 = (int)Math.ceil(getMaxX());
int y2 = (int)Math.ceil(getMaxY());
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
public double | getCenterX()Gets the x coordinate of the center of the rectangle.
return getX() + getWidth() / 2.0;
|
public double | getCenterY()Gets the y coordinate of the center of the rectangle.
return getY() + getHeight() / 2.0;
|
public java.awt.geom.Rectangle2D | getFrame()Places the rectangle's size and location data in a new Rectangle2D object
and returns it.
return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight());
|
public abstract double | getHeight()Gets the height of the rectangle.
|
public double | getMaxX()Gets the maximum x value of the bounding rectangle (the x coordinate of
the upper left corner of the rectangle plus the rectangle's width).
return getX() + getWidth();
|
public double | getMaxY()Gets the maximum y value of the bounding rectangle (the y coordinate of
the upper left corner of the rectangle plus the rectangle's height).
return getY() + getHeight();
|
public double | getMinX()Gets the minimum x value of the bounding rectangle (the x coordinate of
the upper left corner of the rectangle).
return getX();
|
public double | getMinY()Gets the minimum y value of the bounding rectangle (the y coordinate of
the upper left corner of the rectangle).
return getY();
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform t, double flatness)
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
public abstract double | getWidth()Gets the width of the rectangle.
|
public abstract double | getX()Gets the x coordinate of the upper left corner of the rectangle.
|
public abstract double | getY()Gets the y coordinate of the upper left corner of the rectangle.
|
public boolean | intersects(java.awt.geom.Rectangle2D rect)
return intersects(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
public abstract boolean | isEmpty()Checks if this is an empty rectangle: one with zero as its width or
height.
|
public void | setFrame(java.awt.geom.Point2D loc, java.awt.geom.Dimension2D size)Sets the bounding rectangle in terms of a Point2D which gives its upper
left corner and a Dimension2D object giving its width and height.
setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
|
public void | setFrame(java.awt.geom.Rectangle2D r)Sets the bounding rectangle to match the data contained in the specified
Rectangle2D.
setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
public abstract void | setFrame(double x, double y, double w, double h)Sets the data for the bounding rectangle in terms of double values.
|
public void | setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)Sets the framing rectangle given the center point and one corner. Any
corner may be used.
double width = Math.abs(cornerX - centerX);
double height = Math.abs(cornerY - centerY);
setFrame(centerX - width, centerY - height, width * 2.0, height * 2.0);
|
public void | setFrameFromCenter(java.awt.geom.Point2D center, java.awt.geom.Point2D corner)Sets the framing rectangle given the center point and one corner. Any
corner may be used.
setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY());
|
public void | setFrameFromDiagonal(double x1, double y1, double x2, double y2)Sets the framing rectangle given two opposite corners. Any two corners
may be used in any order as long as they are diagonally opposite one
another.
double rx, ry, rw, rh;
if (x1 < x2) {
rx = x1;
rw = x2 - x1;
} else {
rx = x2;
rw = x1 - x2;
}
if (y1 < y2) {
ry = y1;
rh = y2 - y1;
} else {
ry = y2;
rh = y1 - y2;
}
setFrame(rx, ry, rw, rh);
|
public void | setFrameFromDiagonal(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)Sets the framing rectangle given two opposite corners. Any two corners
may be used in any order as long as they are diagonally opposite one
another.
setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|