|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.geom.RectangularShape java.awt.geom.Rectangle2D org.geotools.resources.geometry.XRectangle2D
Serializable, high-performance double-precision rectangle. Instead of using
, , and ,
this class store rectangle's coordinates into the following fields:
xmin
, xmax
, ymin
et ymax
. Methods likes
and are faster, which make this
class more appropriate for using intensively inside a loop. Furthermore, this
class work correctly with infinites and
NaN values.
Nested Class Summary |
Nested classes inherited from class java.awt.geom.Rectangle2D |
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float |
Field Summary | |
static java.awt.geom.Rectangle2D |
INFINITY
An immutable instance of a Rectangle2D with bounds extending toward
infinities. |
protected double |
xmax
Maximal x coordinate. |
protected double |
xmin
Minimal x coordinate. |
protected double |
ymax
Maximal y coordinate. |
protected double |
ymin
Minimal y coordinate. |
Fields inherited from class java.awt.geom.Rectangle2D |
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
Constructor Summary | |
XRectangle2D()
Construct a default rectangle. |
|
XRectangle2D(double x,
double y,
double width,
double height)
Construct a rectangle with the specified location and dimension. |
|
XRectangle2D(java.awt.geom.Rectangle2D rect)
Construct a rectangle with the same coordinates than the supplied rectangle. |
Method Summary | |
void |
add(double x,
double y)
Adds a point, specified by the double precision arguments and , to this . |
void |
add(java.awt.geom.Rectangle2D rect)
Adds a object to this . |
boolean |
contains(double x,
double y)
Tests if a specified coordinate is inside the boundary of this . |
boolean |
contains(double x,
double y,
double width,
double height)
Tests if the interior of this entirely contains the specified set of rectangular coordinates. |
boolean |
contains(java.awt.geom.Rectangle2D rect)
Tests if the interior of this shape entirely contains the specified rectangle. |
static boolean |
containsInclusive(java.awt.geom.Rectangle2D outter,
java.awt.geom.Rectangle2D inner)
Tests if the interior of the rectangle is contained in the interior and/or the edge of the rectangle. |
static XRectangle2D |
createFromExtremums(double xmin,
double ymin,
double xmax,
double ymax)
Create a rectangle using maximal x and y values rather than width and height. |
java.awt.geom.Rectangle2D |
createIntersection(java.awt.geom.Rectangle2D rect)
Returns a new object representing the intersection of this with the specified . |
java.awt.geom.Rectangle2D |
createUnion(java.awt.geom.Rectangle2D rect)
Returns a new object representing the union of this with the specified . |
double |
getCenterX()
Returns the X coordinate of the center of the rectangle. |
double |
getCenterY()
Returns the Y coordinate of the center of the rectangle. |
double |
getHeight()
Returns the height of the framing rectangle in precision. |
double |
getMaxX()
Returns the largest X coordinate of the rectangle. |
double |
getMaxY()
Returns the largest Y coordinate of the rectangle. |
double |
getMinX()
Returns the smallest X coordinate of the rectangle. |
double |
getMinY()
Returns the smallest Y coordinate of the rectangle. |
double |
getWidth()
Returns the width of the framing rectangle in precision. |
double |
getX()
Returns the X coordinate of the upper left corner of the framing rectangle in precision. |
double |
getY()
Returns the Y coordinate of the upper left corner of the framing rectangle in precision. |
static boolean |
intersectInclusive(java.awt.geom.Rectangle2D rect1,
java.awt.geom.Rectangle2D rect2)
Tests if the interior and/or the edge of two rectangles intersect. |
static boolean |
intersectInclusive(java.awt.Shape shape,
java.awt.geom.Rectangle2D rect)
Tests if the interior of the intersects the interior of a specified rectangle. |
boolean |
intersects(double x,
double y,
double width,
double height)
Tests if the interior of this intersects the interior of a specified set of rectangular coordinates. |
boolean |
intersects(java.awt.geom.Rectangle2D rect)
Tests if the interior of this shape intersects the interior of a specified rectangle. |
boolean |
isEmpty()
Determines whether the is empty. |
int |
outcode(double x,
double y)
Determines where the specified coordinates lie with respect to this . |
void |
setRect(double x,
double y,
double width,
double height)
Sets the location and size of this to the specified double values. |
void |
setRect(java.awt.geom.Rectangle2D r)
Sets this to be the same as the specified . |
java.lang.String |
toString()
Returns the representation of this . |
Methods inherited from class java.awt.geom.Rectangle2D |
add, equals, getBounds2D, getPathIterator, getPathIterator, hashCode, intersect, intersectsLine, intersectsLine, outcode, setFrame, union |
Methods inherited from class java.awt.geom.RectangularShape |
clone, contains, getBounds, getFrame, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.awt.geom.Rectangle2D INFINITY
Rectangle2D
with bounds extending toward
infinities. The getMinX()
and getMinY()
methods return always
Double.NEGATIVE_INFINITY
, while the getMaxX()
and
getMaxY()
methods return always Double.POSITIVE_INFINITY
.
This rectangle can be used as argument in the XRectangle2D
constructor for
initializing a new to infinite bounds.
protected double xmin
protected double ymin
protected double xmax
protected double ymax
Constructor Detail |
public XRectangle2D()
public XRectangle2D(double x, double y, double width, double height)
Rectangle2D
for consistency.
public XRectangle2D(java.awt.geom.Rectangle2D rect)
rect
- The rectangle, or in none (in which case this constructor
is equivalents to the no-argument constructor). Use INFINITY
for
initializing this with infinite bounds.Method Detail |
public static XRectangle2D createFromExtremums(double xmin, double ymin, double xmax, double ymax)
public boolean isEmpty()
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public double getMinX()
public double getMinY()
public double getMaxX()
public double getMaxY()
public double getCenterX()
public double getCenterY()
public void setRect(double x, double y, double width, double height)
x
- the x coordinates to which to set the
location of the upper left corner of this y
- the y coordinates to which to set the
location of the upper left corner of this width
- the value to use to set the width of this height
- the value to use to set the height of this public void setRect(java.awt.geom.Rectangle2D r)
r
- the specified public boolean intersects(double x, double y, double width, double height)
intersects
in interface java.awt.Shape
x
- the x coordinates of the upper left corner
of the specified set of rectangular coordinatesy
- the y coordinates of the upper left corner
of the specified set of rectangular coordinateswidth
- the width of the specified set of rectangular coordinatesheight
- the height of the specified set of rectangular coordinates
public boolean intersects(java.awt.geom.Rectangle2D rect)
Rectangle2D
implementation in order to work correctly with
infinites and NaN values.
intersects
in interface java.awt.Shape
rect
- the specified rectangle.
intersectInclusive(Rectangle2D, Rectangle2D)
public static boolean intersectInclusive(java.awt.geom.Rectangle2D rect1, java.awt.geom.Rectangle2D rect2)
intersects(Rectangle2D)
except for the following points:
Shape
contract). However, rectangle with negative width or
height are still considered as empty.
rect1
- The first rectangle to test.rect2
- The second rectangle to test.
public static boolean intersectInclusive(java.awt.Shape shape, java.awt.geom.Rectangle2D rect)
Shape.intersects(Rectangle2D)
, except that this method tests also rectangle with
zero width or height
(which are empty according Shape
contract). However,
rectangle with negative width or height are still considered as empty.
intersectInclusive(Rectangle2D, Rectangle2D)
behavior, at
least for rectangle with zero width or height.
shape
- The shape.rect
- The rectangle to test for inclusion.
public boolean contains(double x, double y, double width, double height)
contains
in interface java.awt.Shape
x
- the x coordinates of the upper left corner
of the specified set of rectangular coordinatesy
- the y coordinates of the upper left corner
of the specified set of rectangular coordinateswidth
- the width of the specified set of rectangular coordinatesheight
- the height of the specified set of rectangular coordinates
public boolean contains(java.awt.geom.Rectangle2D rect)
Rectangle2D
implementation in order
to work correctly with infinites and
NaN values.
contains
in interface java.awt.Shape
rect
- the specified rectangle.
public boolean contains(double x, double y)
contains
in interface java.awt.Shape
x
- the x coordinates to test.y
- the y coordinates to test.
public static boolean containsInclusive(java.awt.geom.Rectangle2D outter, java.awt.geom.Rectangle2D inner)
contains(Rectangle2D)
except for the following points:
Shape
contract).
outter
- The first rectangle to test.inner
- The second rectangle to test.
public int outcode(double x, double y)
Rectangle2D.OUT_LEFT
,
Rectangle2D.OUT_TOP
,
Rectangle2D.OUT_RIGHT
,
Rectangle2D.OUT_BOTTOM
public java.awt.geom.Rectangle2D createIntersection(java.awt.geom.Rectangle2D rect)
rect
- the to be intersected with this
public java.awt.geom.Rectangle2D createUnion(java.awt.geom.Rectangle2D rect)
rect
- the to be combined with
this
public void add(double x, double y)
After adding a point, a call to with the added point as an argument does not necessarily return . The method does not return 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, returns for that point.
public void add(java.awt.geom.Rectangle2D rect)
rect
- the to add to this .public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |