public class ProjectionRect extends Object implements Serializable
Constructor and Description |
---|
ProjectionRect()
default constructor, initialized to center (0,0) and width (10000, 10000)
|
ProjectionRect(double x1,
double y1,
double x2,
double y2)
construct a MapArea from any two opposite corner points
|
ProjectionRect(ProjectionPoint minimum,
double width,
double height)
Construct a ProjectionRect from any two opposite corner points.
|
ProjectionRect(ProjectionPoint corner1,
ProjectionPoint corner2)
Construct a ProjectionRect from any two opposite corner points.
|
ProjectionRect(ProjectionRect r)
Copy Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(double newx,
double newy)
Deprecated.
use builder
|
void |
add(ProjectionPoint pt)
Deprecated.
use builder
|
void |
add(ProjectionRect r)
Deprecated.
use builder
|
boolean |
contains(ProjectionPoint point)
Returns
true if this bounding box contains point . |
boolean |
contains(ProjectionRect rect)
Returns
true if this bounding box contains rect . |
boolean |
equals(Object o) |
double |
getCenterX()
Returns the X coordinate of the center of the framing
rectangle of the
Shape in double
precision. |
double |
getCenterY()
Returns the Y coordinate of the center of the framing
rectangle of the
Shape in double
precision. |
double |
getHeight() |
ProjectionPoint |
getLowerLeftPoint()
Get the Lower Right Point (same as getMinPoint)
|
ProjectionPoint |
getLowerRightPoint()
Get the Lower Right Point
|
ProjectionPoint |
getMaxPoint()
Get the maximum corner of the bounding box.
|
double |
getMaxX()
Returns the largest X coordinate of the framing
rectangle of the
Shape in double
precision. |
double |
getMaxY()
Returns the largest Y coordinate of the framing
rectangle of the
Shape in double
precision. |
ProjectionPoint |
getMinPoint()
Get the minimum corner of the bounding box.
|
double |
getMinX()
Returns the smallest X coordinate of the framing
rectangle of the
Shape in double
precision. |
double |
getMinY()
Returns the smallest Y coordinate of the framing
rectangle of the
Shape in double
precision. |
ProjectionPoint |
getUpperLeftPoint()
Get the Upper Left Point
|
ProjectionPoint |
getUpperRightPoint()
Get the Upper Left Point (same as getMaxPoint)
|
double |
getWidth() |
double |
getX() |
double |
getY() |
int |
hashCode() |
static void |
intersect(ProjectionRect src1,
ProjectionRect src2,
ProjectionRect dest)
Intersects the pair of specified source
Rectangle2D
objects and puts the result into the specified destination
Rectangle2D object. |
boolean |
intersects(double x,
double y,
double w,
double h) |
boolean |
intersects(ProjectionRect r) |
boolean |
isEmpty() |
boolean |
nearlyEquals(ProjectionRect other)
Returns the result of
nearlyEquals(ProjectionRect, double) , with Misc.defaultMaxRelativeDiffFloat . |
boolean |
nearlyEquals(ProjectionRect other,
double maxRelDiff)
Returns
true if this rectangle is nearly equal to other . |
void |
setHeight(double h)
Deprecated.
use builder
|
void |
setRect(double x,
double y,
double w,
double h)
Deprecated.
use builder
|
void |
setRect(ProjectionRect r)
Deprecated.
use builder
|
void |
setWidth(double w)
Deprecated.
use builder
|
void |
setX(double x)
Deprecated.
use builder
|
void |
setY(double y)
Deprecated.
use builder
|
String |
toString()
Get a String representation of this object.
|
String |
toString2(int ndec) |
public ProjectionRect()
public ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2)
corner1
- a corner.corner2
- the opposite corner.public ProjectionRect(ProjectionPoint minimum, double width, double height)
minimum
- lower left corner, ie the minimum x and ywidth
- x width.height
- y heightpublic ProjectionRect(ProjectionRect r)
r
- rectangle to copypublic ProjectionRect(double x1, double y1, double x2, double y2)
x1
- x coord of any corner of the bounding boxy1
- y coord of the same corner as x1x2
- x coord of opposite corner from x1,y1y2
- y coord of same corner as x2public double getX()
public double getY()
public double getWidth()
public double getHeight()
public double getMinX()
Shape
in double
precision.Shape
.public double getMinY()
Shape
in double
precision.Shape
.public double getMaxX()
Shape
in double
precision.Shape
.public double getMaxY()
Shape
in double
precision.Shape
.public double getCenterX()
Shape
in double
precision.Shape
.public double getCenterY()
Shape
in double
precision.Shape
.@Deprecated public void add(ProjectionRect r)
Rectangle2D
object to this
Rectangle2D
. The resulting Rectangle2D
is the union of the two Rectangle2D
objects.r
- the Rectangle2D
to add to this
Rectangle2D
.@Deprecated public void add(double newx, double newy)
newx
and newy
, to this
Rectangle2D
. The resulting Rectangle2D
is the smallest Rectangle2D
that
contains both the original Rectangle2D
and the
specified point.
After adding a point, a call to contains
with the
added point as an argument does not necessarily return
true
. The contains
method does not
return true
for points on the right or bottom
edges of a rectangle. Therefore, if the added point falls on
the left or bottom edge of the enlarged rectangle,
contains
returns false
for that point.
newx
- the X coordinate of the new pointnewy
- the Y coordinate of the new point@Deprecated public void add(ProjectionPoint pt)
Point2D
object pt
to this
Rectangle2D
.
The resulting Rectangle2D
is the smallest
Rectangle2D
that contains both the original
Rectangle2D
and the specified Point2D
.
After adding a point, a call to contains
with the
added point as an argument does not necessarily return
true
. The contains
method does not return true
for points on the right
or bottom edges of a rectangle. Therefore, if the added point falls
on the left or bottom edge of the enlarged rectangle,
contains
returns false
for that point.
pt
- the new Point2D
to add to this
Rectangle2D
.public boolean isEmpty()
public boolean intersects(ProjectionRect r)
public boolean intersects(double x, double y, double w, double h)
public static void intersect(ProjectionRect src1, ProjectionRect src2, ProjectionRect dest)
Rectangle2D
objects and puts the result into the specified destination
Rectangle2D
object. One of the source rectangles
can also be the destination to avoid creating a third Rectangle2D
object, but in this case the original points of this source
rectangle will be overwritten by this method.src1
- the first of a pair of Rectangle2D
objects to be intersected with each othersrc2
- the second of a pair of Rectangle2D
objects to be intersected with each otherdest
- the Rectangle2D
that holds the
results of the intersection of src1
and
src2
public boolean contains(ProjectionPoint point)
true
if this bounding box contains point
.point
- a point in projection coordinates.true
if this bounding box contains point
.public boolean contains(ProjectionRect rect)
true
if this bounding box contains rect
.rect
- a bounding box in projection coordinatestrue
if this bounding box contains rect
.public ProjectionPoint getLowerRightPoint()
public ProjectionPoint getUpperRightPoint()
public ProjectionPoint getLowerLeftPoint()
public ProjectionPoint getUpperLeftPoint()
public ProjectionPoint getMinPoint()
public ProjectionPoint getMaxPoint()
public String toString()
public String toString2(int ndec)
@Deprecated public void setX(double x)
@Deprecated public void setY(double y)
y
- minimum y@Deprecated public void setWidth(double w)
w
- x width@Deprecated public void setHeight(double h)
h
- Y height@Deprecated public void setRect(ProjectionRect r)
@Deprecated public void setRect(double x, double y, double w, double h)
public boolean nearlyEquals(ProjectionRect other)
nearlyEquals(ProjectionRect, double)
, with Misc.defaultMaxRelativeDiffFloat
.public boolean nearlyEquals(ProjectionRect other, double maxRelDiff)
true
if this rectangle is nearly equal to other
. The "near equality" of corners is
determined using ProjectionPoint.nearlyEquals(ProjectionPoint, double)
, with the specified maxRelDiff.other
- the other rectangle to check.maxRelDiff
- the maximum relative difference
that two corners may have.true
if this rectangle is nearly equal to other
.