Uses of Class java.awt.geom.Rectangle2D (Java Platform SE 8 )
Date: 2026-03-16

## Uses of Class
java.awt.geom.Rectangle2D

- Packages that use Rectangle2D
  Package | Description
  --- | ---
  java.awt | Contains all of the classes for creating user interfaces and for painting graphics and images.
  java.awt.font | Provides classes and interface relating to fonts.
  java.awt.geom | Provides the Java 2D classes for defining and performing operations on objects related to two-dimensional geometry.
  java.awt.image | Provides classes for creating and modifying images.
  java.awt.image.renderable | Provides classes and interfaces for producing rendering-independent images.
  javax.swing.plaf.basic | Provides user interface objects built according to the Basic look and feel.
  javax.swing.text | Provides classes and interfaces that deal with editable and noneditable text components.

- - ### Uses of Rectangle2D in java.awt

    Subclasses of Rectangle2D in java.awt
    Modifier and Type | Class and Description
    --- | ---
    `class` | `Rectangle` A `Rectangle` specifies an area in a coordinate space that is enclosed by the `Rectangle` object's upper-left point `(x,y)` in the coordinate space, its width, and its height.

    Methods in java.awt that return Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `Rectangle2D` | Rectangle.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | TexturePaint.`getAnchorRect()` Returns a copy of the anchor rectangle which positions and sizes the textured image.
    `Rectangle2D` | Rectangle.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Polygon.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Shape.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Font.`getMaxCharBounds(FontRenderContext frc)` Returns the bounds for the character with the maximum bounds as defined in the specified `FontRenderContext`.
    `Rectangle2D` | FontMetrics.`getMaxCharBounds(Graphics context)` Returns the bounds for the character with the maximum bounds in the specified `Graphics` context.
    `Rectangle2D` | Font.`getStringBounds(char[] chars, int beginIndex, int limit, FontRenderContext frc)` Returns the logical bounds of the specified array of characters in the specified `FontRenderContext`.
    `Rectangle2D` | FontMetrics.`getStringBounds(char[] chars, int beginIndex, int limit, Graphics context)` Returns the bounds of the specified array of characters in the specified `Graphics` context.
    `Rectangle2D` | Font.`getStringBounds(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc)` Returns the logical bounds of the characters indexed in the specified `CharacterIterator` in the specified `FontRenderContext`.
    `Rectangle2D` | FontMetrics.`getStringBounds(CharacterIterator ci, int beginIndex, int limit, Graphics context)` Returns the bounds of the characters indexed in the specified `CharacterIterator` in the specified `Graphics` context.
    `Rectangle2D` | Font.`getStringBounds(String str, FontRenderContext frc)` Returns the logical bounds of the specified `String` in the specified `FontRenderContext`.
    `Rectangle2D` | FontMetrics.`getStringBounds(String str, Graphics context)` Returns the bounds of the specified `String` in the specified `Graphics` context.
    `Rectangle2D` | Font.`getStringBounds(String str, int beginIndex, int limit, FontRenderContext frc)` Returns the logical bounds of the specified `String` in the specified `FontRenderContext`.
    `Rectangle2D` | FontMetrics.`getStringBounds(String str, int beginIndex, int limit, Graphics context)` Returns the bounds of the specified `String` in the specified `Graphics` context.

    Methods in java.awt with parameters of type Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | Polygon.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | Shape.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `PaintContext` | TexturePaint.`createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate a tiled image pattern.
    `PaintContext` | GradientPaint.`createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate a linear color gradient pattern.
    `PaintContext` | Paint.`createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate the color pattern.
    `PaintContext` | LinearGradientPaint.`createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate a linear color gradient pattern.
    `PaintContext` | Color.`createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate a solid color field pattern.
    `PaintContext` | RadialGradientPaint.`createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform transform, RenderingHints hints)` Creates and returns a `PaintContext` used to generate a circular radial color gradient pattern.
    `Rectangle2D` | Rectangle.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `boolean` | Polygon.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | Shape.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.

    Constructors in java.awt with parameters of type Rectangle2D
    Constructor and Description
    `RadialGradientPaint(Rectangle2D gradientBounds, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod)` Constructs a `RadialGradientPaint` with a default `SRGB` color space.
    `TexturePaint(BufferedImage txtr, Rectangle2D anchor)` Constructs a `TexturePaint` object.

  - ### Uses of Rectangle2D in java.awt.font

    Methods in java.awt.font that return Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `Rectangle2D` | ImageGraphicAttribute.`getBounds()` Returns a `Rectangle2D` that encloses all of the bits rendered by this `ImageGraphicAttribute`, relative to the rendering position.
    `Rectangle2D` | GraphicAttribute.`getBounds()` Returns a `Rectangle2D` that encloses all of the bits drawn by this `GraphicAttribute` relative to the rendering position.
    `Rectangle2D` | TextLayout.`getBounds()` Returns the bounds of this `TextLayout`.
    `Rectangle2D` | ShapeGraphicAttribute.`getBounds()` Returns a `Rectangle2D` that encloses all of the bits drawn by this `ShapeGraphicAttribute` relative to the rendering position.
    `Rectangle2D` | GlyphMetrics.`getBounds2D()` Returns the bounds of the glyph.
    `abstract Rectangle2D` | GlyphVector.`getLogicalBounds()` Returns the logical bounds of this `GlyphVector`.
    `abstract Rectangle2D` | GlyphVector.`getVisualBounds()` Returns the visual bounds of this `GlyphVector` The visual bounds is the bounding box of the outline of this `GlyphVector`.

    Methods in java.awt.font with parameters of type Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `float[]` | TextLayout.`getCaretInfo(TextHitInfo hit, Rectangle2D bounds)` Returns information about the caret corresponding to `hit`.
    `Shape` | TextLayout.`getCaretShape(TextHitInfo hit, Rectangle2D bounds)` Returns a `Shape` representing the caret at the specified hit inside the specified bounds.
    `Shape[]` | TextLayout.`getCaretShapes(int offset, Rectangle2D bounds)` Returns two paths corresponding to the strong and weak caret.
    `Shape[]` | TextLayout.`getCaretShapes(int offset, Rectangle2D bounds, TextLayout.CaretPolicy policy)` Returns two paths corresponding to the strong and weak caret.
    `Shape` | TextLayout.`getLogicalHighlightShape(int firstEndpoint, int secondEndpoint, Rectangle2D bounds)` Returns a `Shape` enclosing the logical selection in the specified range, extended to the specified `bounds`.
    `Shape` | TextLayout.`getVisualHighlightShape(TextHitInfo firstEndpoint, TextHitInfo secondEndpoint, Rectangle2D bounds)` Returns a path enclosing the visual selection in the specified range, extended to `bounds`.
    `TextHitInfo` | TextLayout.`hitTestChar(float x, float y, Rectangle2D bounds)` Returns a `TextHitInfo` corresponding to the specified point.

    Constructors in java.awt.font with parameters of type Rectangle2D
    Constructor and Description
    `GlyphMetrics(boolean horizontal, float advanceX, float advanceY, Rectangle2D bounds, byte glyphType)` Constructs a `GlyphMetrics` object.
    `GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType)` Constructs a `GlyphMetrics` object.

  - ### Uses of Rectangle2D in java.awt.geom

    Subclasses of Rectangle2D in java.awt.geom
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Rectangle2D.Double` The `Double` class defines a rectangle specified in double coordinates.
    `static class` | `Rectangle2D.Float` The `Float` class defines a rectangle specified in float coordinates.

    Methods in java.awt.geom that return Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `abstract Rectangle2D` | Rectangle2D.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Float.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Double.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `abstract Rectangle2D` | Rectangle2D.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Float.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Double.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | RoundRectangle2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | RoundRectangle2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Area.`getBounds2D()` Returns a high precision bounding `Rectangle2D` that completely encloses this `Area`.
    `Rectangle2D` | Line2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Line2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Ellipse2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Ellipse2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | QuadCurve2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | QuadCurve2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | CubicCurve2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | CubicCurve2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Path2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Path2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Rectangle2D.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Rectangle2D.Float.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Rectangle2D.Double.`getBounds2D()` Returns a high precision and more accurate bounding box of the `Shape` than the `getBounds` method.
    `Rectangle2D` | Arc2D.`getBounds2D()` Returns the high-precision framing rectangle of the arc.
    `Rectangle2D` | RectangularShape.`getFrame()` Returns the framing `Rectangle2D` that defines the overall shape of this object.
    `protected abstract Rectangle2D` | Arc2D.`makeBounds(double x, double y, double w, double h)` Constructs a `Rectangle2D` of the appropriate precision to hold the parameters calculated to be the framing rectangle of this arc.
    `protected Rectangle2D` | Arc2D.Float.`makeBounds(double x, double y, double w, double h)` Constructs a `Rectangle2D` of the appropriate precision to hold the parameters calculated to be the framing rectangle of this arc.
    `protected Rectangle2D` | Arc2D.Double.`makeBounds(double x, double y, double w, double h)` Constructs a `Rectangle2D` of the appropriate precision to hold the parameters calculated to be the framing rectangle of this arc.

    Methods in java.awt.geom with parameters of type Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `void` | Rectangle2D.`add(Rectangle2D r)` Adds a `Rectangle2D` object to this `Rectangle2D`.
    `static boolean` | Path2D.`contains(PathIterator pi, Rectangle2D r)` Tests if the specified `Rectangle2D` is entirely inside the closed boundary of the specified `PathIterator`.
    `boolean` | Area.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | Line2D.`contains(Rectangle2D r)` Tests if the interior of this `Line2D` entirely contains the specified `Rectangle2D`.
    `boolean` | QuadCurve2D.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | CubicCurve2D.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | Path2D.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | RectangularShape.`contains(Rectangle2D r)` Tests if the interior of the `Shape` entirely contains the specified `Rectangle2D`.
    `boolean` | Arc2D.`contains(Rectangle2D r)` Determines whether or not the interior of the arc entirely contains the specified rectangle.
    `abstract Rectangle2D` | Rectangle2D.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Float.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Double.`createIntersection(Rectangle2D r)` Returns a new `Rectangle2D` object representing the intersection of this `Rectangle2D` with the specified `Rectangle2D`.
    `abstract Rectangle2D` | Rectangle2D.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Float.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `Rectangle2D` | Rectangle2D.Double.`createUnion(Rectangle2D r)` Returns a new `Rectangle2D` object representing the union of this `Rectangle2D` with the specified `Rectangle2D`.
    `static void` | Rectangle2D.`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.
    `static boolean` | Path2D.`intersects(PathIterator pi, Rectangle2D r)` Tests if the interior of the specified `PathIterator` intersects the interior of a specified `Rectangle2D`.
    `boolean` | Area.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | Line2D.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | QuadCurve2D.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | CubicCurve2D.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | Path2D.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `boolean` | RectangularShape.`intersects(Rectangle2D r)` Tests if the interior of the `Shape` intersects the interior of a specified `Rectangle2D`.
    `void` | Arc2D.`setArc(Rectangle2D rect, double angSt, double angExt, int closure)` Sets the location, size, angular extents, and closure type of this arc to the specified values.
    `void` | RectangularShape.`setFrame(Rectangle2D r)` Sets the framing rectangle of this `Shape` to be the specified `Rectangle2D`.
    `void` | Rectangle2D.`setRect(Rectangle2D r)` Sets this `Rectangle2D` to be the same as the specified `Rectangle2D`.
    `void` | Rectangle2D.Float.`setRect(Rectangle2D r)` Sets this `Rectangle2D` to be the same as the specified `Rectangle2D`.
    `void` | Rectangle2D.Double.`setRect(Rectangle2D r)` Sets this `Rectangle2D` to be the same as the specified `Rectangle2D`.
    `static void` | Rectangle2D.`union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)` Unions the pair of source `Rectangle2D` objects and puts the result into the specified destination `Rectangle2D` object.

    Constructors in java.awt.geom with parameters of type Rectangle2D
    Constructor and Description
    `Double(Rectangle2D ellipseBounds, double start, double extent, int type)` Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.
    `Float(Rectangle2D ellipseBounds, float start, float extent, int type)` Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.

  - ### Uses of Rectangle2D in java.awt.image

    Methods in java.awt.image that return Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `Rectangle2D` | ColorConvertOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the destination, given this source.
    `Rectangle2D` | LookupOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the filtered destination image.
    `Rectangle2D` | BufferedImageOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the filtered destination image.
    `Rectangle2D` | ConvolveOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the filtered destination image.
    `Rectangle2D` | RescaleOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the rescaled destination image.
    `Rectangle2D` | AffineTransformOp.`getBounds2D(BufferedImage src)` Returns the bounding box of the transformed destination.
    `Rectangle2D` | ColorConvertOp.`getBounds2D(Raster src)` Returns the bounding box of the destination, given this source.
    `Rectangle2D` | LookupOp.`getBounds2D(Raster src)` Returns the bounding box of the filtered destination Raster.
    `Rectangle2D` | RasterOp.`getBounds2D(Raster src)` Returns the bounding box of the filtered destination Raster.
    `Rectangle2D` | ConvolveOp.`getBounds2D(Raster src)` Returns the bounding box of the filtered destination Raster.
    `Rectangle2D` | RescaleOp.`getBounds2D(Raster src)` Returns the bounding box of the rescaled destination Raster.
    `Rectangle2D` | AffineTransformOp.`getBounds2D(Raster src)` Returns the bounding box of the transformed destination.
    `Rectangle2D` | BandCombineOp.`getBounds2D(Raster src)` Returns the bounding box of the transformed destination.

  - ### Uses of Rectangle2D in java.awt.image.renderable

    Methods in java.awt.image.renderable that return Rectangle2D
    Modifier and Type | Method and Description
    --- | ---
    `Rectangle2D` | ContextualRenderedImageFactory.`getBounds2D(ParameterBlock paramBlock)` Returns the bounding box for the output of the operation, performed on a given set of sources, in rendering-independent space.

  - ### Uses of Rectangle2D in javax.swing.plaf.basic

    Subclasses of Rectangle2D in javax.swing.plaf.basic
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BasicTextUI.BasicCaret`

  - ### Uses of Rectangle2D in javax.swing.text

    Subclasses of Rectangle2D in javax.swing.text
    Modifier and Type | Class and Description
    --- | ---
    `class` | `DefaultCaret` A default implementation of Caret.

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 © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.