java.awt.geom

Class Rectangle2D.Double

public static class Rectangle2D.Double extends Rectangle2D

This class defines a rectangle in double precision.

Since: 1.2

UNKNOWN: updated to 1.4

Field Summary
doubleheight
The height of the rectangle.
doublewidth
The width of the rectangle.
doublex
The x coordinate of the lower left corner.
doubley
The y coordinate of the lower left corner.
Constructor Summary
Double()
Create a rectangle at (0,0) with width 0 and height 0.
Double(double x, double y, double w, double 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(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 double height
The height of the rectangle.

width

public double width
The width of the rectangle.

x

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

y

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

Constructor Detail

Double

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

Double

public Double(double x, double y, double w, double 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: Double Double Double Double

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