APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt.geom

public abstract Class Rectangle2D

extends RectangularShape
Class Inheritance
Known Direct Subclasses
java.awt.geom.Rectangle2D.Float, java.awt.geom.Rectangle2D.Double, java.awt.Rectangle
Imports
java.io.Serial, .Serializable

The Rectangle2D class describes a rectangle defined by a location (x,y) and dimension (w x h).

This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.

Author
Jim Graham
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Rectangle2D.Double

The Double class defines a rectangle specified in double coordinates.

public static class
Rectangle2D.Float

The Float class defines a rectangle specified in float coordinates.

Field Summary

Modifier and TypeField and Description
public static final int
OUT_BOTTOM

The bitmask that indicates that a point lies below this Rectangle2D.

public static final int
OUT_LEFT

The bitmask that indicates that a point lies to the left of this Rectangle2D.

public static final int
OUT_RIGHT

The bitmask that indicates that a point lies to the right of this Rectangle2D.

public static final int
OUT_TOP

The bitmask that indicates that a point lies above this Rectangle2D.

Constructor Summary

AccessConstructor and Description
protected
Rectangle2D()

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
public void
add(double
the X coordinate of the new point
newx
,
double
the Y coordinate of the new point
newy
)

Adds a point, specified by the double precision arguments newx and newy, to this Rectangle2D.

public void
add(Point2D
the new Point2D to add to this Rectangle2D.
pt
)

Adds the Point2D object pt to this Rectangle2D.

public void
add(Rectangle2D
the Rectangle2D to add to this Rectangle2D.
r
)

Adds a Rectangle2D object to this Rectangle2D.

public boolean
contains(double x, double y)

Implements java.awt.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness.

public boolean
contains(double x, double y, double w, double h)

Implements java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area.

public abstract Rectangle2D

Returns:

the largest Rectangle2D contained in both the specified Rectangle2D and in this Rectangle2D.
createIntersection
(Rectangle2D
the Rectangle2D to be intersected with this Rectangle2D
r
)

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

public abstract Rectangle2D

Returns:

the smallest Rectangle2D containing both the specified Rectangle2D and this Rectangle2D.
createUnion
(Rectangle2D
the Rectangle2D to be combined with this Rectangle2D
r
)

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

public boolean

Returns:

true if obj is an instance of Rectangle2D and has the same values; false otherwise.
equals
(Object
an Object to be compared with this Rectangle2D.
obj
)

Overrides java.lang.Object.equals.

Determines whether or not the specified Object is equal to this Rectangle2D.

public Rectangle2D
getBounds2D()

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this Rectangle2D, one segment at a time.
getPathIterator
(AffineTransform
an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
at
)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this Rectangle2D.

public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this Rectangle2D, one segment at a time.
getPathIterator
(AffineTransform
an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
at
,
double
the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve. Since rectangles are already flat, the flatness parameter is ignored.
flatness
)

Overrides java.awt.geom.RectangularShape.getPathIterator.

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the flattened Rectangle2D.

public int

Returns:

the hashcode for this Rectangle2D.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this Rectangle2D.

public static void
intersect(Rectangle2D
the first of a pair of Rectangle2D objects to be intersected with each other
src1
,
Rectangle2D
the second of a pair of Rectangle2D objects to be intersected with each other
src2
,
Rectangle2D
the Rectangle2D that holds the results of the intersection of src1 and src2
dest
)

Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.

public boolean
intersects(double x, double y, double w, double h)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.

public boolean

Returns:

true if the specified line segment intersects the interior of this Rectangle2D; false otherwise.
intersectsLine
(double
the X coordinate of the start point of the specified line segment
x1
,
double
the Y coordinate of the start point of the specified line segment
y1
,
double
the X coordinate of the end point of the specified line segment
x2
,
double
the Y coordinate of the end point of the specified line segment
y2
)

Tests if the specified line segment intersects the interior of this Rectangle2D.

public boolean

Returns:

true if the specified Line2D intersects the interior of this Rectangle2D; false otherwise.
intersectsLine
(Line2D
the specified Line2D to test for intersection with the interior of this Rectangle2D
l
)

Tests if the specified line segment intersects the interior of this Rectangle2D.

public abstract int

Returns:

the logical OR of all appropriate out codes.
outcode
(double
the specified X coordinate
x
,
double
the specified Y coordinate
y
)

Determines where the specified coordinates lie with respect to this Rectangle2D.

public int

Returns:

the logical OR of all appropriate out codes.
outcode
(Point2D
the specified Point2D
p
)

Determines where the specified Point2D lies with respect to this Rectangle2D.

public void
setFrame(double
the X coordinate of the upper-left corner of this Rectangle2D
x
,
double
the Y coordinate of the upper-left corner of this Rectangle2D
y
,
double
the width of this Rectangle2D
w
,
double
the height of this Rectangle2D
h
)

Implements abstract java.awt.geom.RectangularShape.setFrame.

Sets the location and size of the outer bounds of this Rectangle2D to the specified rectangular values.

public abstract void
setRect(double
the X coordinate of the upper-left corner of this Rectangle2D
x
,
double
the Y coordinate of the upper-left corner of this Rectangle2D
y
,
double
the width of this Rectangle2D
w
,
double
the height of this Rectangle2D
h
)

Sets the location and size of this Rectangle2D to the specified double values.

public void
setRect(Rectangle2D
the specified Rectangle2D
r
)

Sets this Rectangle2D to be the same as the specified Rectangle2D.

public static void
union(Rectangle2D
the first of a pair of Rectangle2D objects to be combined with each other
src1
,
Rectangle2D
the second of a pair of Rectangle2D objects to be combined with each other
src2
,
Rectangle2D
the Rectangle2D that holds the results of the union of src1 and src2
dest
)

Unions the pair of source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.

Inherited from java.awt.geom.RectangularShape:
clonecontainscontainsgetBoundsgetCenterXgetCenterYgetFramegetHeightgetMaxXgetMaxYgetMinXgetMinYgetWidthgetXgetYintersectsisEmptysetFramesetFramesetFrameFromCentersetFrameFromCentersetFrameFromDiagonalsetFrameFromDiagonal

Field Detail

OUT_BOTTOMback to summary
public static final int OUT_BOTTOM

The bitmask that indicates that a point lies below this Rectangle2D.

Since
1.2
OUT_LEFTback to summary
public static final int OUT_LEFT

The bitmask that indicates that a point lies to the left of this Rectangle2D.

Since
1.2
OUT_RIGHTback to summary
public static final int OUT_RIGHT

The bitmask that indicates that a point lies to the right of this Rectangle2D.

Since
1.2
OUT_TOPback to summary
public static final int OUT_TOP

The bitmask that indicates that a point lies above this Rectangle2D.

Since
1.2

Constructor Detail

Rectangle2Dback to summary
protected Rectangle2D()

This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.

Since
1.2
See Also
java.awt.geom.Rectangle2D.Float, java.awt.geom.Rectangle2D.Double, java.awt.Rectangle

Method Detail

addback to summary
public void add(double newx, double newy)

Adds a point, specified by the double precision arguments 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 right or bottom edge of the enlarged rectangle, contains returns false for that point.

Parameters
newx:double

the X coordinate of the new point

newy:double

the Y coordinate of the new point

Since
1.2
addback to summary
public void add(Point2D pt)

Adds the 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 right or bottom edge of the enlarged rectangle, contains returns false for that point.

Parameters
pt:Point2D

the new Point2D to add to this Rectangle2D.

Since
1.2
addback to summary
public void add(Rectangle2D r)

Adds a Rectangle2D object to this Rectangle2D. The resulting Rectangle2D is the union of the two Rectangle2D objects.

Parameters
r:Rectangle2D

the Rectangle2D to add to this Rectangle2D.

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

Implements java.awt.Shape.contains.

Doc from java.awt.Shape.contains.

Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness.

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

Implements java.awt.Shape.contains.

Doc from java.awt.Shape.contains.

Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectangular area to be considered contained within the Shape.

The Shape.contains() method allows a Shape implementation to conservatively return false when:

  • the intersect method returns true and
  • the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive.
This means that for some Shapes this method might return false even though the Shape contains the rectangular area. The Area class performs more accurate geometric computations than most Shape objects and therefore can be used if a more precise answer is required.
Since
1.2
createIntersectionback to summary
public abstract Rectangle2D createIntersection(Rectangle2D r)

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

Parameters
r:Rectangle2D

the Rectangle2D to be intersected with this Rectangle2D

Returns:Rectangle2D

the largest Rectangle2D contained in both the specified Rectangle2D and in this Rectangle2D.

Since
1.2
createUnionback to summary
public abstract Rectangle2D createUnion(Rectangle2D r)

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

Parameters
r:Rectangle2D

the Rectangle2D to be combined with this Rectangle2D

Returns:Rectangle2D

the smallest Rectangle2D containing both the specified Rectangle2D and this Rectangle2D.

Since
1.2
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Determines whether or not the specified Object is equal to this Rectangle2D. The specified Object is equal to this Rectangle2D if it is an instance of Rectangle2D and if its location and size are the same as this Rectangle2D.

Parameters
obj:Object

an Object to be compared with this Rectangle2D.

Returns:boolean

true if obj is an instance of Rectangle2D and has the same values; false otherwise.

Since
1.2
getBounds2Dback to summary
public Rectangle2D getBounds2D()

Implements java.awt.Shape.getBounds2D.

Doc from java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no guarantee that the returned Rectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that uses double precision values to store the dimensions.

Note that the definition of insideness can lead to situations where points on the defining outline of the shape may not be considered contained in the returned bounds object, but only in cases where those points are also not considered contained in the original shape.

If a point is inside the shape according to the contains(point) method, then it must be inside the returned Rectangle2D bounds object according to the contains(point) method of the bounds. Specifically:

shape.contains(p) requires bounds.contains(p)

If a point is not inside the shape, then it might still be contained in the bounds object:

bounds.contains(p) does not imply shape.contains(p)

Since
1.2
getPathIteratorback to summary
public PathIterator getPathIterator(AffineTransform at)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this Rectangle2D. The iterator for this class is multi-threaded safe, which means that this Rectangle2D class guarantees that modifications to the geometry of this Rectangle2D object do not affect any iterations of that geometry that are already in process.

Parameters
at:AffineTransform

an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired

Returns:PathIterator

the PathIterator object that returns the geometry of the outline of this Rectangle2D, one segment at a time.

Since
1.2
getPathIteratorback to summary
public PathIterator getPathIterator(AffineTransform at, double flatness)

Overrides java.awt.geom.RectangularShape.getPathIterator.

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the flattened Rectangle2D. Since rectangles are already flat, the flatness parameter is ignored. The iterator for this class is multi-threaded safe, which means that this Rectangle2D class guarantees that modifications to the geometry of this Rectangle2D object do not affect any iterations of that geometry that are already in process.

Parameters
at:AffineTransform

an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired

flatness:double

the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve. Since rectangles are already flat, the flatness parameter is ignored.

Returns:PathIterator

the PathIterator object that returns the geometry of the outline of this Rectangle2D, one segment at a time.

Since
1.2
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this Rectangle2D.

Returns:int

the hashcode for this Rectangle2D.

Since
1.2
intersectback to summary
public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)

Intersects the pair of specified source 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.

Parameters
src1:Rectangle2D

the first of a pair of Rectangle2D objects to be intersected with each other

src2:Rectangle2D

the second of a pair of Rectangle2D objects to be intersected with each other

dest:Rectangle2D

the Rectangle2D that holds the results of the intersection of src1 and src2

Since
1.2
intersectsback to summary
public boolean intersects(double x, double y, double w, double h)

Implements java.awt.Shape.intersects.

Doc from java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.

The Shape.intersects() method allows a Shape implementation to conservatively return true when:

  • there is a high probability that the rectangular area and the Shape intersect, but
  • the calculations to accurately determine this intersection are prohibitively expensive.
This means that for some Shapes this method might return true even though the rectangular area does not intersect the Shape. The Area class performs more accurate computations of geometric intersection than most Shape objects and therefore can be used if a more precise answer is required.
Since
1.2
intersectsLineback to summary
public boolean intersectsLine(double x1, double y1, double x2, double y2)

Tests if the specified line segment intersects the interior of this Rectangle2D.

Parameters
x1:double

the X coordinate of the start point of the specified line segment

y1:double

the Y coordinate of the start point of the specified line segment

x2:double

the X coordinate of the end point of the specified line segment

y2:double

the Y coordinate of the end point of the specified line segment

Returns:boolean

true if the specified line segment intersects the interior of this Rectangle2D; false otherwise.

Since
1.2
intersectsLineback to summary
public boolean intersectsLine(Line2D l)

Tests if the specified line segment intersects the interior of this Rectangle2D.

Parameters
l:Line2D

the specified Line2D to test for intersection with the interior of this Rectangle2D

Returns:boolean

true if the specified Line2D intersects the interior of this Rectangle2D; false otherwise.

Since
1.2
outcodeback to summary
public abstract int outcode(double x, double y)

Determines where the specified coordinates lie with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified coordinates are on the same side of the edge as the rest of this Rectangle2D.

Parameters
x:double

the specified X coordinate

y:double

the specified Y coordinate

Returns:int

the logical OR of all appropriate out codes.

Since
1.2
See Also
OUT_LEFT, OUT_TOP, OUT_RIGHT, OUT_BOTTOM
outcodeback to summary
public int outcode(Point2D p)

Determines where the specified Point2D lies with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified Point2D is on the same side of the edge as the rest of this Rectangle2D.

Parameters
p:Point2D

the specified Point2D

Returns:int

the logical OR of all appropriate out codes.

Since
1.2
See Also
OUT_LEFT, OUT_TOP, OUT_RIGHT, OUT_BOTTOM
setFrameback to summary
public void setFrame(double x, double y, double w, double h)

Implements abstract java.awt.geom.RectangularShape.setFrame.

Sets the location and size of the outer bounds of this Rectangle2D to the specified rectangular values.

Parameters
x:double

the X coordinate of the upper-left corner of this Rectangle2D

y:double

the Y coordinate of the upper-left corner of this Rectangle2D

w:double

the width of this Rectangle2D

h:double

the height of this Rectangle2D

Since
1.2
setRectback to summary
public abstract void setRect(double x, double y, double w, double h)

Sets the location and size of this Rectangle2D to the specified double values.

Parameters
x:double

the X coordinate of the upper-left corner of this Rectangle2D

y:double

the Y coordinate of the upper-left corner of this Rectangle2D

w:double

the width of this Rectangle2D

h:double

the height of this Rectangle2D

Since
1.2
setRectback to summary
public void setRect(Rectangle2D r)

Sets this Rectangle2D to be the same as the specified Rectangle2D.

Parameters
r:Rectangle2D

the specified Rectangle2D

Since
1.2
unionback to summary
public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)

Unions the pair of source 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.

Parameters
src1:Rectangle2D

the first of a pair of Rectangle2D objects to be combined with each other

src2:Rectangle2D

the second of a pair of Rectangle2D objects to be combined with each other

dest:Rectangle2D

the Rectangle2D that holds the results of the union of src1 and src2

Since
1.2
java.awt.geom back to summary

public Class Rectangle2D.Double

extends Rectangle2D
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

The Double class defines a rectangle specified in double coordinates.
Since
1.2

Field Summary

Modifier and TypeField and Description
public double
height

The height of this Rectangle2D.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

public double
width

The width of this Rectangle2D.

public double
x

The X coordinate of this Rectangle2D.

public double
y

The Y coordinate of this Rectangle2D.

Inherited from java.awt.geom.Rectangle2D:
OUT_BOTTOMOUT_LEFTOUT_RIGHTOUT_TOP

Constructor Summary

AccessConstructor and Description
public
Double()

Constructs a new Rectangle2D, initialized to location (0, 0) and size (0, 0).

public
Double(double
the X coordinate of the upper-left corner of the newly constructed Rectangle2D
x
,
double
the Y coordinate of the upper-left corner of the newly constructed Rectangle2D
y
,
double
the width of the newly constructed Rectangle2D
w
,
double
the height of the newly constructed Rectangle2D
h
)

Constructs and initializes a Rectangle2D from the specified double coordinates.

Method Summary

Modifier and TypeMethod and Description
public Rectangle2D
createIntersection(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createIntersection.

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

public Rectangle2D
createUnion(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createUnion.

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

public Rectangle2D
getBounds2D()

Overrides java.awt.geom.Rectangle2D.getBounds2D.

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.

public double
getHeight()

Implements abstract java.awt.geom.RectangularShape.getHeight.

Returns the height of the framing rectangle in double precision.

public double
getWidth()

Implements abstract java.awt.geom.RectangularShape.getWidth.

Returns the width of the framing rectangle in double precision.

public double
getX()

Implements abstract java.awt.geom.RectangularShape.getX.

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

public double
getY()

Implements abstract java.awt.geom.RectangularShape.getY.

Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.

public boolean
isEmpty()

Implements abstract java.awt.geom.RectangularShape.isEmpty.

Determines whether the RectangularShape is empty.

public int
outcode(double x, double y)

Implements abstract java.awt.geom.Rectangle2D.outcode.

Determines where the specified coordinates lie with respect to this Rectangle2D.

public void
setRect(double x, double y, double w, double h)

Implements abstract java.awt.geom.Rectangle2D.setRect.

Sets the location and size of this Rectangle2D to the specified double values.

public void
setRect(Rectangle2D r)

Overrides java.awt.geom.Rectangle2D.setRect.

Sets this Rectangle2D to be the same as the specified Rectangle2D.

public String

Returns:

a String representing this Rectangle2D.
toString
()

Overrides java.lang.Object.toString.

Returns the String representation of this Rectangle2D.

Inherited from java.awt.geom.Rectangle2D:
addaddaddcontainscontainsequalsgetPathIteratorgetPathIteratorhashCodeintersectintersectsintersectsLineintersectsLineoutcodesetFrameunion

Field Detail

heightback to summary
public double height

The height of this Rectangle2D.

Since
1.2
serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

Annotations
@Serial
widthback to summary
public double width

The width of this Rectangle2D.

Since
1.2
xback to summary
public double x

The X coordinate of this Rectangle2D.

Since
1.2
yback to summary
public double y

The Y coordinate of this Rectangle2D.

Since
1.2

Constructor Detail

Doubleback to summary
public Double()

Constructs a new Rectangle2D, initialized to location (0, 0) and size (0, 0).

Since
1.2
Doubleback to summary
public Double(double x, double y, double w, double h)

Constructs and initializes a Rectangle2D from the specified double coordinates.

Parameters
x:double

the X coordinate of the upper-left corner of the newly constructed Rectangle2D

y:double

the Y coordinate of the upper-left corner of the newly constructed Rectangle2D

w:double

the width of the newly constructed Rectangle2D

h:double

the height of the newly constructed Rectangle2D

Since
1.2

Method Detail

createIntersectionback to summary
public Rectangle2D createIntersection(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createIntersection.

Doc from java.awt.geom.Rectangle2D.createIntersection.

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

Since
1.2
createUnionback to summary
public Rectangle2D createUnion(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createUnion.

Doc from java.awt.geom.Rectangle2D.createUnion.

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

Since
1.2
getBounds2Dback to summary
public Rectangle2D getBounds2D()

Overrides java.awt.geom.Rectangle2D.getBounds2D.

Implements java.awt.Shape.getBounds2D.

Doc from java.awt.geom.Rectangle2D.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no guarantee that the returned Rectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that uses double precision values to store the dimensions.

Note that the definition of insideness can lead to situations where points on the defining outline of the shape may not be considered contained in the returned bounds object, but only in cases where those points are also not considered contained in the original shape.

If a point is inside the shape according to the contains(point) method, then it must be inside the returned Rectangle2D bounds object according to the contains(point) method of the bounds. Specifically:

shape.contains(p) requires bounds.contains(p)

If a point is not inside the shape, then it might still be contained in the bounds object:

bounds.contains(p) does not imply shape.contains(p)

Since
1.2
getHeightback to summary
public double getHeight()

Implements abstract java.awt.geom.RectangularShape.getHeight.

Doc from java.awt.geom.RectangularShape.getHeight.

Returns the height of the framing rectangle in double precision.

Since
1.2
getWidthback to summary
public double getWidth()

Implements abstract java.awt.geom.RectangularShape.getWidth.

Doc from java.awt.geom.RectangularShape.getWidth.

Returns the width of the framing rectangle in double precision.

Since
1.2
getXback to summary
public double getX()

Implements abstract java.awt.geom.RectangularShape.getX.

Doc from java.awt.geom.RectangularShape.getX.

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Since
1.2
getYback to summary
public double getY()

Implements abstract java.awt.geom.RectangularShape.getY.

Doc from java.awt.geom.RectangularShape.getY.

Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.

Since
1.2
isEmptyback to summary
public boolean isEmpty()

Implements abstract java.awt.geom.RectangularShape.isEmpty.

Doc from java.awt.geom.RectangularShape.isEmpty.

Determines whether the RectangularShape is empty. When the RectangularShape is empty, it encloses no area.

Since
1.2
outcodeback to summary
public int outcode(double x, double y)

Implements abstract java.awt.geom.Rectangle2D.outcode.

Doc from java.awt.geom.Rectangle2D.outcode.

Determines where the specified coordinates lie with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified coordinates are on the same side of the edge as the rest of this Rectangle2D.

Since
1.2
setRectback to summary
public void setRect(double x, double y, double w, double h)

Implements abstract java.awt.geom.Rectangle2D.setRect.

Doc from java.awt.geom.Rectangle2D.setRect.

Sets the location and size of this Rectangle2D to the specified double values.

Since
1.2
setRectback to summary
public void setRect(Rectangle2D r)

Overrides java.awt.geom.Rectangle2D.setRect.

Doc from java.awt.geom.Rectangle2D.setRect.

Sets this Rectangle2D to be the same as the specified Rectangle2D.

Since
1.2
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the String representation of this Rectangle2D.

Returns:String

a String representing this Rectangle2D.

Since
1.2
java.awt.geom back to summary

public Class Rectangle2D.Float

extends Rectangle2D
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

The Float class defines a rectangle specified in float coordinates.
Since
1.2

Field Summary

Modifier and TypeField and Description
public float
height

The height of this Rectangle2D.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

public float
width

The width of this Rectangle2D.

public float
x

The X coordinate of this Rectangle2D.

public float
y

The Y coordinate of this Rectangle2D.

Inherited from java.awt.geom.Rectangle2D:
OUT_BOTTOMOUT_LEFTOUT_RIGHTOUT_TOP

Constructor Summary

AccessConstructor and Description
public
Float()

Constructs a new Rectangle2D, initialized to location (0.0, 0.0) and size (0.0, 0.0).

public
Float(float
the X coordinate of the upper-left corner of the newly constructed Rectangle2D
x
,
float
the Y coordinate of the upper-left corner of the newly constructed Rectangle2D
y
,
float
the width of the newly constructed Rectangle2D
w
,
float
the height of the newly constructed Rectangle2D
h
)

Constructs and initializes a Rectangle2D from the specified float coordinates.

Method Summary

Modifier and TypeMethod and Description
public Rectangle2D
createIntersection(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createIntersection.

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

public Rectangle2D
createUnion(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createUnion.

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

public Rectangle2D
getBounds2D()

Overrides java.awt.geom.Rectangle2D.getBounds2D.

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.

public double
getHeight()

Implements abstract java.awt.geom.RectangularShape.getHeight.

Returns the height of the framing rectangle in double precision.

public double
getWidth()

Implements abstract java.awt.geom.RectangularShape.getWidth.

Returns the width of the framing rectangle in double precision.

public double
getX()

Implements abstract java.awt.geom.RectangularShape.getX.

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

public double
getY()

Implements abstract java.awt.geom.RectangularShape.getY.

Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.

public boolean
isEmpty()

Implements abstract java.awt.geom.RectangularShape.isEmpty.

Determines whether the RectangularShape is empty.

public int
outcode(double x, double y)

Implements abstract java.awt.geom.Rectangle2D.outcode.

Determines where the specified coordinates lie with respect to this Rectangle2D.

public void
setRect(float
the X coordinate of the upper-left corner of this Rectangle2D
x
,
float
the Y coordinate of the upper-left corner of this Rectangle2D
y
,
float
the width of this Rectangle2D
w
,
float
the height of this Rectangle2D
h
)

Sets the location and size of this Rectangle2D to the specified float values.

public void
setRect(double x, double y, double w, double h)

Implements abstract java.awt.geom.Rectangle2D.setRect.

Sets the location and size of this Rectangle2D to the specified double values.

public void
setRect(Rectangle2D r)

Overrides java.awt.geom.Rectangle2D.setRect.

Sets this Rectangle2D to be the same as the specified Rectangle2D.

public String

Returns:

a String representing this Rectangle2D.
toString
()

Overrides java.lang.Object.toString.

Returns the String representation of this Rectangle2D.

Inherited from java.awt.geom.Rectangle2D:
addaddaddcontainscontainsequalsgetPathIteratorgetPathIteratorhashCodeintersectintersectsintersectsLineintersectsLineoutcodesetFrameunion

Field Detail

heightback to summary
public float height

The height of this Rectangle2D.

Since
1.2
serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

Annotations
@Serial
widthback to summary
public float width

The width of this Rectangle2D.

Since
1.2
xback to summary
public float x

The X coordinate of this Rectangle2D.

Since
1.2
yback to summary
public float y

The Y coordinate of this Rectangle2D.

Since
1.2

Constructor Detail

Floatback to summary
public Float()

Constructs a new Rectangle2D, initialized to location (0.0, 0.0) and size (0.0, 0.0).

Since
1.2
Floatback to summary
public Float(float x, float y, float w, float h)

Constructs and initializes a Rectangle2D from the specified float coordinates.

Parameters
x:float

the X coordinate of the upper-left corner of the newly constructed Rectangle2D

y:float

the Y coordinate of the upper-left corner of the newly constructed Rectangle2D

w:float

the width of the newly constructed Rectangle2D

h:float

the height of the newly constructed Rectangle2D

Since
1.2

Method Detail

createIntersectionback to summary
public Rectangle2D createIntersection(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createIntersection.

Doc from java.awt.geom.Rectangle2D.createIntersection.

Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.

Since
1.2
createUnionback to summary
public Rectangle2D createUnion(Rectangle2D r)

Implements abstract java.awt.geom.Rectangle2D.createUnion.

Doc from java.awt.geom.Rectangle2D.createUnion.

Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.

Since
1.2
getBounds2Dback to summary
public Rectangle2D getBounds2D()

Overrides java.awt.geom.Rectangle2D.getBounds2D.

Implements java.awt.Shape.getBounds2D.

Doc from java.awt.geom.Rectangle2D.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no guarantee that the returned Rectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that uses double precision values to store the dimensions.

Note that the definition of insideness can lead to situations where points on the defining outline of the shape may not be considered contained in the returned bounds object, but only in cases where those points are also not considered contained in the original shape.

If a point is inside the shape according to the contains(point) method, then it must be inside the returned Rectangle2D bounds object according to the contains(point) method of the bounds. Specifically:

shape.contains(p) requires bounds.contains(p)

If a point is not inside the shape, then it might still be contained in the bounds object:

bounds.contains(p) does not imply shape.contains(p)

Since
1.2
getHeightback to summary
public double getHeight()

Implements abstract java.awt.geom.RectangularShape.getHeight.

Doc from java.awt.geom.RectangularShape.getHeight.

Returns the height of the framing rectangle in double precision.

Since
1.2
getWidthback to summary
public double getWidth()

Implements abstract java.awt.geom.RectangularShape.getWidth.

Doc from java.awt.geom.RectangularShape.getWidth.

Returns the width of the framing rectangle in double precision.

Since
1.2
getXback to summary
public double getX()

Implements abstract java.awt.geom.RectangularShape.getX.

Doc from java.awt.geom.RectangularShape.getX.

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Since
1.2
getYback to summary
public double getY()

Implements abstract java.awt.geom.RectangularShape.getY.

Doc from java.awt.geom.RectangularShape.getY.

Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.

Since
1.2
isEmptyback to summary
public boolean isEmpty()

Implements abstract java.awt.geom.RectangularShape.isEmpty.

Doc from java.awt.geom.RectangularShape.isEmpty.

Determines whether the RectangularShape is empty. When the RectangularShape is empty, it encloses no area.

Since
1.2
outcodeback to summary
public int outcode(double x, double y)

Implements abstract java.awt.geom.Rectangle2D.outcode.

Doc from java.awt.geom.Rectangle2D.outcode.

Determines where the specified coordinates lie with respect to this Rectangle2D. This method computes a binary OR of the appropriate mask values indicating, for each side of this Rectangle2D, whether or not the specified coordinates are on the same side of the edge as the rest of this Rectangle2D.

Since
1.2
setRectback to summary
public void setRect(float x, float y, float w, float h)

Sets the location and size of this Rectangle2D to the specified float values.

Parameters
x:float

the X coordinate of the upper-left corner of this Rectangle2D

y:float

the Y coordinate of the upper-left corner of this Rectangle2D

w:float

the width of this Rectangle2D

h:float

the height of this Rectangle2D

Since
1.2
setRectback to summary
public void setRect(double x, double y, double w, double h)

Implements abstract java.awt.geom.Rectangle2D.setRect.

Doc from java.awt.geom.Rectangle2D.setRect.

Sets the location and size of this Rectangle2D to the specified double values.

Since
1.2
setRectback to summary
public void setRect(Rectangle2D r)

Overrides java.awt.geom.Rectangle2D.setRect.

Doc from java.awt.geom.Rectangle2D.setRect.

Sets this Rectangle2D to be the same as the specified Rectangle2D.

Since
1.2
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the String representation of this Rectangle2D.

Returns:String

a String representing this Rectangle2D.

Since
1.2