public class Rectangle2D extends Object
Modifier and Type | Field and Description |
---|---|
static Rectangle2D |
EMPTY
An empty
Rectangle2D instance (with all coordinates equal to zero). |
Constructor and Description |
---|
Rectangle2D(double minX,
double minY,
double width,
double height)
Creates a new instance of
Rectangle2D . |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(double x,
double y)
Tests if the specified
(x, y) coordinates are inside the boundary
of Rectangle2D . |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the interior of this
Rectangle2D entirely contains the
specified rectangular area. |
boolean |
contains(Point2D p)
Tests if the specified point is inside the boundary of
Rectangle2D . |
boolean |
contains(Rectangle2D r)
Tests if the interior of this
Rectangle2D entirely contains the
specified Rectangle2D, r . |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
double |
getHeight()
The height of this
Rectangle2D . |
double |
getMaxX()
The x coordinate of the lower-right corner of this
Rectangle2D . |
double |
getMaxY()
The y coordinate of the lower-right corner of this
Rectangle2D . |
double |
getMinX()
The x coordinate of the upper-left corner of this
Rectangle2D . |
double |
getMinY()
The y coordinate of the upper-left corner of this
Rectangle2D . |
double |
getWidth()
The width of this
Rectangle2D . |
int |
hashCode()
Returns a hash code for this
Rectangle2D object. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the interior of this
Rectangle2D intersects the interior
of a specified rectangular area. |
boolean |
intersects(Rectangle2D r)
Tests if the interior of this
Rectangle2D intersects the interior
of a specified Rectangle2D, r . |
String |
toString()
Returns a string representation of this
Rectangle2D . |
public static final Rectangle2D EMPTY
Rectangle2D
instance (with all coordinates equal to zero).public Rectangle2D(double minX, double minY, double width, double height)
Rectangle2D
.minX
- The x coordinate of the upper-left corner of the Rectangle2D
minY
- The y coordinate of the upper-left corner of the Rectangle2D
width
- The width of the Rectangle2D
height
- The height of the Rectangle2D
public double getMinX()
Rectangle2D
.public double getMinY()
Rectangle2D
.public double getWidth()
Rectangle2D
.public double getHeight()
Rectangle2D
.public double getMaxX()
Rectangle2D
.minX + width
public double getMaxY()
Rectangle2D
.minY + height
public boolean contains(Point2D p)
Rectangle2D
.p
- the specified point to be testedRectangle2D
; false otherwise.public boolean contains(double x, double y)
(x, y)
coordinates are inside the boundary
of Rectangle2D
.x
- the specified x coordinate to be testedy
- the specified y coordinate to be tested(x, y)
coordinates are inside the
boundary of this Rectangle2D
; false otherwise.public boolean contains(Rectangle2D r)
Rectangle2D
entirely contains the
specified Rectangle2D, r
.r
- The specified Rectangle2Dr
, is inside the
boundary of this Rectangle2D
; false otherwise.public boolean contains(double x, double y, double w, double h)
Rectangle2D
entirely contains the
specified rectangular area.x
- the x coordinate of the upper-left corner of the specified
rectangular areay
- the y coordinate of the upper-left corner of the specified
rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areaRectangle2D
entirely contains
the specified rectangular area; false otherwise.public boolean intersects(Rectangle2D r)
Rectangle2D
intersects the interior
of a specified Rectangle2D, r
.r
- The specified Rectangle2DRectangle2D
and the interior
of the specified Rectangle2D, r
, intersect.public boolean intersects(double x, double y, double w, double h)
Rectangle2D
intersects the interior
of a specified rectangular area.x
- the x coordinate of the upper-left corner of the specified
rectangular areay
- the y coordinate of the upper-left corner of the specified
rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areaRectangle2D
and the interior
of the rectangular area intersect.public boolean equals(Object obj)
public int hashCode()
Rectangle2D
object.public String toString()
Rectangle2D
.
This method is intended to be used only for informational purposes.
The content and format of the returned string might vary between
implementations.
The returned string might be empty but cannot be null
.Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.