public static class

Rectangle2D.Float

extends Rectangle2D
implements Serializable
java.lang.Object
   ↳ java.awt.geom.RectangularShape
     ↳ java.awt.geom.Rectangle2D
       ↳ java.awt.geom.Rectangle2D.Float

Class Overview

The Float class defines a rectangle specified in float coordinates.

Summary

[Expand]
Inherited Constants
From class java.awt.geom.Rectangle2D
Fields
public float height The height of this Rectangle2D.
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.
Public Constructors
Rectangle2D.Float()
Constructs a new Rectangle2D, initialized to location (0.0, 0.0) and size (0.0, 0.0).
Rectangle2D.Float(float x, float y, float w, float h)
Constructs and initializes a Rectangle2D from the specified float coordinates.
Public Methods
Rectangle2D createIntersection(Rectangle2D r)
Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.
Rectangle2D createUnion(Rectangle2D r)
Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.
Rectangle2D getBounds2D()
double getHeight()
Returns the height of the framing rectangle in double precision.
double getWidth()
Returns the width of the framing rectangle in double precision.
double getX()
Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.
double getY()
Returns the Y coordinate of the upper-left corner of the framing rectangle in double precision.
boolean isEmpty()
Determines whether the RectangularShape is empty.
int outcode(double x, double y)
Determines where the specified coordinates lie with respect to this Rectangle2D.
void setRect(double x, double y, double w, double h)
Sets the location and size of this Rectangle2D to the specified double values.
void setRect(float x, float y, float w, float h)
Sets the location and size of this Rectangle2D to the specified float values.
void setRect(Rectangle2D r)
Sets this Rectangle2D to be the same as the specified Rectangle2D.
String toString()
Returns the String representation of this Rectangle2D.
[Expand]
Inherited Methods
From class java.awt.geom.Rectangle2D
From class java.awt.geom.RectangularShape
From class java.lang.Object
From interface java.awt.Shape

Fields

public float height

The height of this Rectangle2D.

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.

Public Constructors

public Rectangle2D.Float ()

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

public Rectangle2D.Float (float x, float y, float w, float h)

Constructs and initializes a Rectangle2D from the specified float coordinates.

Parameters
x the X coordinate of the upper-left corner of the newly constructed Rectangle2D
y the Y coordinate of the upper-left corner of the newly constructed Rectangle2D
w the width of the newly constructed Rectangle2D
h the height of the newly constructed Rectangle2D

Public Methods

public Rectangle2D createIntersection (Rectangle2D r)

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

Parameters
r the Rectangle2D to be intersected with this Rectangle2D
Returns
  • the largest Rectangle2D contained in both the specified Rectangle2D and in this Rectangle2D.

public Rectangle2D createUnion (Rectangle2D r)

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

Parameters
r the Rectangle2D to be combined with this Rectangle2D
Returns
  • the smallest Rectangle2D containing both the specified Rectangle2D and this Rectangle2D.

public Rectangle2D getBounds2D ()

public double getHeight ()

Returns the height of the framing rectangle in double precision.

Returns
  • the height of the framing rectangle.

public double getWidth ()

Returns the width of the framing rectangle in double precision.

Returns
  • the width of the framing rectangle.

public double getX ()

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

Returns
  • the X coordinate of the upper-left corner of the framing rectangle.

public double getY ()

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

Returns
  • the Y coordinate of the upper-left corner of the framing rectangle.

public boolean isEmpty ()

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

Returns
  • true if the RectangularShape is empty; false otherwise.

public 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 the specified X coordinate
y the specified Y coordinate
Returns
  • the logical OR of all appropriate out codes.

public 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 the X coordinate of the upper-left corner of this Rectangle2D
y the Y coordinate of the upper-left corner of this Rectangle2D
w the width of this Rectangle2D
h the height of this Rectangle2D

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 the X coordinate of the upper-left corner of this Rectangle2D
y the Y coordinate of the upper-left corner of this Rectangle2D
w the width of this Rectangle2D
h the height of this Rectangle2D

public void setRect (Rectangle2D r)

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

Parameters
r the specified Rectangle2D

public String toString ()

Returns the String representation of this Rectangle2D.

Returns
  • a String representing this Rectangle2D.