java.awt.geom

Class Rectangle2D.Float

public static class Rectangle2D.Float extends Rectangle2D

This class defines a rectangle in float precision.

Since: 1.2

UNKNOWN: updated to 1.4

Field Summary
floatheight
The height of the rectangle.
floatwidth
The width of the rectangle.
floatx
The x coordinate of the lower left corner.
floaty
The y coordinate of the lower left corner.
Constructor Summary
Float()
Create a rectangle at (0,0) with width 0 and height 0.
Float(float x, float y, float w, float h)
Create a rectangle with the given values.
Method Summary
Rectangle2DcreateIntersection(Rectangle2D r)
Return a new rectangle which is the intersection of this and the given one.
Rectangle2DcreateUnion(Rectangle2D r)
Return a new rectangle which is the union of this and the given one.
Rectangle2DgetBounds2D()
Returns the bounds of this rectangle.
doublegetHeight()
Return the height.
doublegetWidth()
Return the width.
doublegetX()
Return the X coordinate.
doublegetY()
Return the Y coordinate.
booleanisEmpty()
Test if the rectangle is empty.
intoutcode(double x, double y)
Determine where the point lies with respect to this rectangle.
voidsetRect(float x, float y, float w, float h)
Set the contents of this rectangle to those specified.
voidsetRect(double x, double y, double w, double h)
Set the contents of this rectangle to those specified.
voidsetRect(Rectangle2D r)
Set the contents of this rectangle to those specified.
StringtoString()
Returns a string representation of this rectangle.

Field Detail

height

public float height
The height of the rectangle.

width

public float width
The width of the rectangle.

x

public float x
The x coordinate of the lower left corner.

y

public float y
The y coordinate of the lower left corner.

Constructor Detail

Float

public Float()
Create a rectangle at (0,0) with width 0 and height 0.

Float

public Float(float x, float y, float w, float h)
Create a rectangle with the given values.

Parameters: x the x coordinate y the y coordinate w the width h the height

Method Detail

createIntersection

public Rectangle2D createIntersection(Rectangle2D r)
Return a new rectangle which is the intersection of this and the given one. The result will be empty if there is no intersection.

Parameters: r the rectangle to be intersected

Returns: the intersection

Throws: NullPointerException if r is null

createUnion

public Rectangle2D createUnion(Rectangle2D r)
Return a new rectangle which is the union of this and the given one.

Parameters: r the rectangle to be merged

Returns: the union

Throws: NullPointerException if r is null

getBounds2D

public Rectangle2D getBounds2D()
Returns the bounds of this rectangle. A pretty useless method, as this is already a rectangle.

Returns: a copy of this rectangle

getHeight

public double getHeight()
Return the height.

Returns: the value of height

getWidth

public double getWidth()
Return the width.

Returns: the value of width

getX

public double getX()
Return the X coordinate.

Returns: the value of x

getY

public double getY()
Return the Y coordinate.

Returns: the value of y

isEmpty

public boolean isEmpty()
Test if the rectangle is empty.

Returns: true if width or height is not positive

outcode

public int outcode(double x, double y)
Determine where the point lies with respect to this rectangle. The result will be the binary OR of the appropriate bit masks.

Parameters: x the x coordinate to check y the y coordinate to check

Returns: the binary OR of the result

Since: 1.2

See Also: Float Float Float Float

setRect

public void setRect(float x, float y, float w, float h)
Set the contents of this rectangle to those specified.

Parameters: x the x coordinate y the y coordinate w the width h the height

setRect

public void setRect(double x, double y, double w, double h)
Set the contents of this rectangle to those specified.

Parameters: x the x coordinate y the y coordinate w the width h the height

setRect

public void setRect(Rectangle2D r)
Set the contents of this rectangle to those specified.

Parameters: r the rectangle to copy

Throws: NullPointerException if r is null

toString

public String toString()
Returns a string representation of this rectangle. This is in the form getClass().getName() + "[x=" + x + ",y=" + y + ",w=" + width + ",h=" + height + ']'.

Returns: a string representation of this rectangle