APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.geometry

public Class Rectangle2D

extends Object
Class Inheritance
Imports
javafx.beans.NamedArg

A 2D rectangle used to describe the bounds of an object. It is defined by a location (minX, minY) and dimension (width x height).
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
public static final Rectangle2D
EMPTY

An empty Rectangle2D instance (with all coordinates equal to zero).

private int
hash

Cache the hash code to make computing hashes faster.

private double
private double
private double
private double
private double
private double

Constructor Summary

AccessConstructor and Description
public
Rectangle2D(double
The x coordinate of the upper-left corner of the Rectangle2D
minX
,
double
The y coordinate of the upper-left corner of the Rectangle2D
minY
,
double
The width of the Rectangle2D
width
,
double
The height of the Rectangle2D
height
)

Creates a new instance of Rectangle2D.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the specified point is inside the boundary of this Rectangle2D; false otherwise
contains
(Point2D
the specified point to be tested
p
)

Tests if the specified point is inside the boundary of Rectangle2D.

public boolean

Returns:

true if the specified (x, y) coordinates are inside the boundary of this Rectangle2D; false otherwise
contains
(double
the specified x coordinate to be tested
x
,
double
the specified y coordinate to be tested
y
)

Tests if the specified (x, y) coordinates are inside the boundary of Rectangle2D.

public boolean

Returns:

true if the specified Rectangle2D, r, is inside the boundary of this Rectangle2D; false otherwise
contains
(Rectangle2D
The specified Rectangle2D
r
)

Tests if the interior of this Rectangle2D entirely contains the specified Rectangle2D, r.

public boolean

Returns:

true if the interior of this Rectangle2D entirely contains the specified rectangular area; false otherwise
contains
(double
the x coordinate of the upper-left corner of the specified rectangular area
x
,
double
the y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Tests if the interior of this Rectangle2D entirely contains the specified rectangular area.

public boolean

Returns:

true if this object is equal to the obj argument; false otherwise
equals
(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public double

Returns:

the height
getHeight
()

The height of this Rectangle2D.

public double

Returns:

the x coordinate of the lower-right corner
getMaxX
()

The x coordinate of the lower-right corner of this Rectangle2D.

public double

Returns:

the y coordinate of the lower-right corner
getMaxY
()

The y coordinate of the lower-right corner of this Rectangle2D.

public double

Returns:

the x coordinate of the upper-left corner
getMinX
()

The x coordinate of the upper-left corner of this Rectangle2D.

public double

Returns:

the y coordinate of the upper-left corner
getMinY
()

The y coordinate of the upper-left corner of this Rectangle2D.

public double

Returns:

the width
getWidth
()

The width of this Rectangle2D.

public int

Returns:

a hash code for this Rectangle2D object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this Rectangle2D object.

public boolean

Returns:

true if the interior of this Rectangle2D and the interior of the specified Rectangle2D, r, intersect
intersects
(Rectangle2D
The specified Rectangle2D
r
)

Tests if the interior of this Rectangle2D intersects the interior of a specified Rectangle2D, r.

public boolean

Returns:

true if the interior of this Rectangle2D and the interior of the rectangular area intersect
intersects
(double
the x coordinate of the upper-left corner of the specified rectangular area
x
,
double
the y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Tests if the interior of this Rectangle2D intersects the interior of a specified rectangular area.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of this Rectangle2D.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

EMPTYback to summary
public static final Rectangle2D EMPTY

An empty Rectangle2D instance (with all coordinates equal to zero).

hashback to summary
private int hash

Cache the hash code to make computing hashes faster.

heightback to summary
private double height
maxXback to summary
private double maxX
maxYback to summary
private double maxY
minXback to summary
private double minX
minYback to summary
private double minY
widthback to summary
private double width

Constructor Detail

Rectangle2Dback to summary
public Rectangle2D(double minX, double minY, double width, double height)

Creates a new instance of Rectangle2D.

Parameters
minX:double

The x coordinate of the upper-left corner of the Rectangle2D

minY:double

The y coordinate of the upper-left corner of the Rectangle2D

width:double

The width of the Rectangle2D

height:double

The height of the Rectangle2D

Method Detail

containsback to summary
public boolean contains(Point2D p)

Tests if the specified point is inside the boundary of Rectangle2D.

Parameters
p:Point2D

the specified point to be tested

Returns:boolean

true if the specified point is inside the boundary of this Rectangle2D; false otherwise

containsback to summary
public boolean contains(double x, double y)

Tests if the specified (x, y) coordinates are inside the boundary of Rectangle2D.

Parameters
x:double

the specified x coordinate to be tested

y:double

the specified y coordinate to be tested

Returns:boolean

true if the specified (x, y) coordinates are inside the boundary of this Rectangle2D; false otherwise

containsback to summary
public boolean contains(Rectangle2D r)

Tests if the interior of this Rectangle2D entirely contains the specified Rectangle2D, r.

Parameters
r:Rectangle2D

The specified Rectangle2D

Returns:boolean

true if the specified Rectangle2D, r, is inside the boundary of this Rectangle2D; false otherwise

containsback to summary
public boolean contains(double x, double y, double w, double h)

Tests if the interior of this Rectangle2D entirely contains the specified rectangular area.

Parameters
x:double

the x coordinate of the upper-left corner of the specified rectangular area

y:double

the y coordinate of the upper-left corner of the specified rectangular area

w:double

the width of the specified rectangular area

h:double

the height of the specified rectangular area

Returns:boolean

true if the interior of this Rectangle2D entirely contains the specified rectangular area; false otherwise

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is equal to the obj argument; false otherwise

Annotations
@Override
getHeightback to summary
public double getHeight()

The height of this Rectangle2D.

Returns:double

the height

Default Value
0.0
getMaxXback to summary
public double getMaxX()

The x coordinate of the lower-right corner of this Rectangle2D.

Returns:double

the x coordinate of the lower-right corner

Default Value
minX + width
getMaxYback to summary
public double getMaxY()

The y coordinate of the lower-right corner of this Rectangle2D.

Returns:double

the y coordinate of the lower-right corner

Default Value
minY + height
getMinXback to summary
public double getMinX()

The x coordinate of the upper-left corner of this Rectangle2D.

Returns:double

the x coordinate of the upper-left corner

Default Value
0.0
getMinYback to summary
public double getMinY()

The y coordinate of the upper-left corner of this Rectangle2D.

Returns:double

the y coordinate of the upper-left corner

Default Value
0.0
getWidthback to summary
public double getWidth()

The width of this Rectangle2D.

Returns:double

the width

Default Value
0.0
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this Rectangle2D object.

Returns:int

a hash code for this Rectangle2D object.

Annotations
@Override
intersectsback to summary
public boolean intersects(Rectangle2D r)

Tests if the interior of this Rectangle2D intersects the interior of a specified Rectangle2D, r.

Parameters
r:Rectangle2D

The specified Rectangle2D

Returns:boolean

true if the interior of this Rectangle2D and the interior of the specified Rectangle2D, r, intersect

intersectsback to summary
public 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.

Parameters
x:double

the x coordinate of the upper-left corner of the specified rectangular area

y:double

the y coordinate of the upper-left corner of the specified rectangular area

w:double

the width of the specified rectangular area

h:double

the height of the specified rectangular area

Returns:boolean

true if the interior of this Rectangle2D and the interior of the rectangular area intersect

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this 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.

Annotations
@Override