|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.epseelon.mobimap.geom.RectangularShape
org.epseelon.mobimap.geom.Rectangle2D
public abstract class Rectangle2D
This class describes a rectangle by a point (x,y) and dimension (w x h). The actual storage is left up to subclasses.
It is valid for a rectangle to have negative width or height; but it
is considered to have no area or internal points. Therefore, the behavior
in methods like contains or intersects is
undefined unless the rectangle has positive width and height.
| Nested Class Summary | |
|---|---|
static class |
Rectangle2D.Double
This class defines a rectangle in double precision. |
static class |
Rectangle2D.Float
This class defines a rectangle in float precision. |
| Field Summary | |
|---|---|
static int |
OUT_BOTTOM
The point lies below of the rectangle (p.y > r.maxY). |
static int |
OUT_LEFT
The point lies left of the rectangle (p.x < r.x). |
static int |
OUT_RIGHT
The point lies right of the rectangle (p.x > r.maxX). |
static int |
OUT_TOP
The point lies above the rectangle (p.y < r.y). |
| Constructor Summary | |
|---|---|
protected |
Rectangle2D()
Default constructor. |
| Method Summary | |
|---|---|
void |
add(double newx,
double newy)
Modifies this rectangle so that it represents the smallest rectangle that contains both the existing rectangle and the specified point. |
void |
add(Point2D p)
Modifies this rectangle so that it represents the smallest rectangle that contains both the existing rectangle and the specified point. |
void |
add(Rectangle2D r)
Modifies this rectangle so that it represents the smallest rectangle that contains both the existing rectangle and the specified rectangle. |
boolean |
contains(double x,
double y)
Test if the given point is contained in the rectangle. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if this rectangle contains the given one. |
abstract Rectangle2D |
createIntersection(Rectangle2D r)
Return a new rectangle which is the intersection of this and the given one. |
abstract Rectangle2D |
createUnion(Rectangle2D r)
Return a new rectangle which is the union of this and the given one. |
boolean |
equals(java.lang.Object obj)
Tests this rectangle for equality against the specified object. |
int |
hashCode()
Return the hashcode for this rectangle. |
static void |
intersect(Rectangle2D src1,
Rectangle2D src2,
Rectangle2D dest)
Intersects a pair of rectangles, and places the result in the destination; this can be used to avoid object creation. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the given rectangle intersects this one. |
boolean |
intersectsLine(double x1,
double y1,
double x2,
double y2)
Tests if the specified line intersects the interior of this rectangle. |
boolean |
intersectsLine(Line2D l)
Tests if the specified line intersects the interior of this rectangle. |
abstract int |
outcode(double x,
double y)
Determine where the point lies with respect to this rectangle. |
int |
outcode(Point2D p)
Determine where the point lies with respect to this rectangle. |
void |
setFrame(double x,
double y,
double w,
double h)
Set the bounding box of this rectangle. |
abstract void |
setRect(double x,
double y,
double w,
double h)
Set the bounding box of this rectangle. |
void |
setRect(Rectangle2D r)
Set the bounding box of this rectangle from the given one. |
static void |
union(Rectangle2D src1,
Rectangle2D src2,
Rectangle2D dest)
Joins a pair of rectangles, and places the result in the destination; this can be used to avoid object creation. |
| Methods inherited from class org.epseelon.mobimap.geom.RectangularShape |
|---|
contains, contains, getBounds, getCenterX, getCenterY, getFrame, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, getX, getY, intersects, isEmpty, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.epseelon.mobimap.geom.Shape |
|---|
getBounds2D |
| Field Detail |
|---|
public static final int OUT_LEFT
outcode(double, double),
Constant Field Valuespublic static final int OUT_TOP
outcode(double, double),
Constant Field Valuespublic static final int OUT_RIGHT
outcode(double, double),
Constant Field Valuespublic static final int OUT_BOTTOM
outcode(double, double),
Constant Field Values| Constructor Detail |
|---|
protected Rectangle2D()
| Method Detail |
|---|
public abstract void setRect(double x,
double y,
double w,
double h)
x - the new X coordinatey - the new Y coordinatew - the new widthh - the new heightpublic void setRect(Rectangle2D r)
r - rectangle to copy
java.lang.NullPointerException - if r is null
public boolean intersectsLine(double x1,
double y1,
double x2,
double y2)
x1 - the first x coordinate of line segmenty1 - the first y coordinate of line segmentx2 - the second x coordinate of line segmenty2 - the second y coordinate of line segment
public boolean intersectsLine(Line2D l)
l - the line segment
java.lang.NullPointerException - if l is null
public abstract int outcode(double x,
double y)
x - the x coordinate to checky - the y coordinate to check
OUT_LEFT,
OUT_TOP,
OUT_RIGHT,
OUT_BOTTOMpublic int outcode(Point2D p)
p - the point to check
java.lang.NullPointerException - if p is nullOUT_LEFT,
OUT_TOP,
OUT_RIGHT,
OUT_BOTTOM
public void setFrame(double x,
double y,
double w,
double h)
setFrame in class RectangularShapex - the new X coordinatey - the new Y coordinatew - the new widthh - the new heightRectangularShape.getFrame()
public boolean contains(double x,
double y)
x - the x coordinate of the pointy - the y coordinate of the point
public boolean intersects(double x,
double y,
double w,
double h)
x - the x coordinate of the other rectangley - the y coordinate of the other rectanglew - the width of the other rectangleh - the height of the other rectangle
public boolean contains(double x,
double y,
double w,
double h)
x - the x coordinate of the other rectangley - the y coordinate of the other rectanglew - the width of the other rectangleh - the height of the other rectangle
public abstract Rectangle2D createIntersection(Rectangle2D r)
r - the rectangle to be intersected
java.lang.NullPointerException - if r is null
public static void intersect(Rectangle2D src1,
Rectangle2D src2,
Rectangle2D dest)
src1 - the first sourcesrc2 - the second sourcedest - the destination for the intersection
java.lang.NullPointerException - if any rectangle is nullpublic abstract Rectangle2D createUnion(Rectangle2D r)
r - the rectangle to be merged
java.lang.NullPointerException - if r is null
public static void union(Rectangle2D src1,
Rectangle2D src2,
Rectangle2D dest)
src1 - the first sourcesrc2 - the second sourcedest - the destination for the union
java.lang.NullPointerException - if any rectangle is null
public void add(double newx,
double newy)
contains may
return false.
newx - the X coordinate of the point to add to this rectanglenewy - the Y coordinate of the point to add to this rectanglepublic void add(Point2D p)
contains may
return false.
p - the point to add to this rectangle
java.lang.NullPointerException - if p is nullpublic void add(Rectangle2D r)
r - the rectangle to add to this rectangle
java.lang.NullPointerException - if r is nullunion(Rectangle2D, Rectangle2D, Rectangle2D)public int hashCode()
long l = Double.doubleToLongBits(getX()) + 37 * Double.doubleToLongBits(getY()) + 43 * Double.doubleToLongBits(getWidth()) + 47 * Double.doubleToLongBits(getHeight()); return (int) ((l >> 32) ^ l);
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to test against for equality
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||