Top Description Inners Constructors Methods
java.awt.geom

public abstract Class Ellipse2D

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

The Ellipse2D class describes an ellipse that is defined by a framing rectangle.

This class is only the abstract superclass for all objects which store a 2D ellipse. 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
Ellipse2D.Double

The Double class defines an ellipse specified in double precision.

public static class
Ellipse2D.Float

The Float class defines an ellipse specified in float precision.

Constructor Summary

AccessConstructor and Description
protected
Ellipse2D()

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(double
the specified X coordinate to be tested
x
,
double
the specified Y coordinate to be tested
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
the X coordinate of the upper-left corner of the specified rectangular area
x
,
double
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Implements java.awt.Shape.contains.

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

Returns:

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

Overrides java.lang.Object.equals.

Determines whether or not the specified Object is equal to this Ellipse2D.
public PathIterator

Returns:

the PathIterator object that returns the geometry of the outline of this Ellipse2D, 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 Ellipse2D.
public int

Returns:

the hashcode for this Ellipse2D.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this Ellipse2D.
public boolean
intersects(double
the X coordinate of the upper-left corner of the specified rectangular area
x
,
double
the Y coordinate of the upper-left corner of the specified rectangular area
y
,
double
the width of the specified rectangular area
w
,
double
the height of the specified rectangular area
h
)

Implements java.awt.Shape.intersects.

Tests if the interior of the Shape intersects the interior of a specified rectangular area.
Inherited from java.awt.geom.RectangularShape:
clonecontainscontainsgetBoundsgetCenterXgetCenterYgetFramegetHeightgetMaxXgetMaxYgetMinXgetMinYgetPathIteratorgetWidthgetXgetYintersectsisEmptysetFramesetFramesetFramesetFrameFromCentersetFrameFromCentersetFrameFromDiagonalsetFrameFromDiagonal

Constructor Detail

Ellipse2Dback to summary
protected Ellipse2D()

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.Ellipse2D.Float, java.awt.geom.Ellipse2D.Double

Method Detail

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.

Parameters
x:double

the specified X coordinate to be tested

y:double

the specified Y coordinate to be tested

Returns:boolean

true if the specified coordinates are inside the Shape boundary; false otherwise.

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.
Parameters
x:double

the X coordinate of the upper-left corner of the specified rectangular area

y:double

the Y coordinate of the upper-left corner of the specified rectangular area

w:double

the width of the specified rectangular area

h:double

the height of the specified rectangular area

Returns:boolean

true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape contains the rectangular area and the intersects method returns true and the containment calculations would be too expensive to perform.

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 Ellipse2D. The specified Object is equal to this Ellipse2D if it is an instance of Ellipse2D and if its location and size are the same as this Ellipse2D.

Parameters
obj:Object

an Object to be compared with this Ellipse2D.

Returns:boolean

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

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

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of this Ellipse2D. The iterator for this class is multi-threaded safe, which means that this Ellipse2D class guarantees that modifications to the geometry of this Ellipse2D 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 Ellipse2D, one segment at a time.

Since
1.2
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this Ellipse2D.

Returns:int

the hashcode for this Ellipse2D.

Since
1.6
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.
Parameters
x:double

the X coordinate of the upper-left corner of the specified rectangular area

y:double

the Y coordinate of the upper-left corner of the specified rectangular area

w:double

the width of the specified rectangular area

h:double

the height of the specified rectangular area

Returns:boolean

true if the interior of the Shape and the interior of the rectangular area intersect, or are both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.

Since
1.2
java.awt.geom back to summary

public Class Ellipse2D.Double

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

The Double class defines an ellipse specified in double precision.
Since
1.2

Field Summary

Modifier and TypeField and Description
public double
height

The overall height of the Ellipse2D.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

public double
width

The overall width of this Ellipse2D.

public double
x

The X coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

public double
y

The Y coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Constructor Summary

AccessConstructor and Description
public
Double()

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

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

Constructs and initializes an Ellipse2D from the specified coordinates.

Method Summary

Modifier and TypeMethod and Description
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 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 void
setFrame(double
the X coordinate of the upper-left corner of the specified rectangular shape
x
,
double
the Y coordinate of the upper-left corner of the specified rectangular shape
y
,
double
the width of the specified rectangular shape
w
,
double
the height of the specified rectangular shape
h
)

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

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.
Inherited from java.awt.geom.Ellipse2D:
containscontainsequalsgetPathIteratorhashCodeintersects

Field Detail

heightback to summary
public double height

The overall height of the Ellipse2D.

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 overall width of this Ellipse2D.

Since
1.2
xback to summary
public double x

The X coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Since
1.2
yback to summary
public double y

The Y coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Since
1.2

Constructor Detail

Doubleback to summary
public Double()

Constructs a new Ellipse2D, 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 an Ellipse2D from the specified coordinates.

Parameters
x:double

the X coordinate of the upper-left corner of the framing rectangle

y:double

the Y coordinate of the upper-left corner of the framing rectangle

w:double

the width of the framing rectangle

h:double

the height of the framing rectangle

Since
1.2

Method Detail

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)

Returns:Rectangle2D

an instance of Rectangle2D that is a high-precision bounding box of the Shape.

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.

Returns:double

the height of the framing rectangle.

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.

Returns:double

the width of the framing rectangle.

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.

Returns:double

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

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.

Returns:double

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

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.

Returns:boolean

true if the RectangularShape is empty; false otherwise.

Since
1.2
setFrameback to summary
public void setFrame(double x, double y, double w, double h)

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

Doc from java.awt.geom.RectangularShape.setFrame.

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.

Parameters
x:double

the X coordinate of the upper-left corner of the specified rectangular shape

y:double

the Y coordinate of the upper-left corner of the specified rectangular shape

w:double

the width of the specified rectangular shape

h:double

the height of the specified rectangular shape

Since
1.2
java.awt.geom back to summary

public Class Ellipse2D.Float

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

The Float class defines an ellipse specified in float precision.
Since
1.2

Field Summary

Modifier and TypeField and Description
public float
height

The overall height of this Ellipse2D.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.6 for interoperability.

public float
width

The overall width of this Ellipse2D.

public float
x

The X coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

public float
y

The Y coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Constructor Summary

AccessConstructor and Description
public
Float()

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

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

Constructs and initializes an Ellipse2D from the specified coordinates.

Method Summary

Modifier and TypeMethod and Description
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 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 void
setFrame(float
the X coordinate of the upper-left corner of the specified rectangular shape
x
,
float
the Y coordinate of the upper-left corner of the specified rectangular shape
y
,
float
the width of the specified rectangular shape
w
,
float
the height of the specified rectangular shape
h
)

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.

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

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

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.
Inherited from java.awt.geom.Ellipse2D:
containscontainsequalsgetPathIteratorhashCodeintersects

Field Detail

heightback to summary
public float height

The overall height of this Ellipse2D.

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 overall width of this Ellipse2D.

Since
1.2
xback to summary
public float x

The X coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Since
1.2
yback to summary
public float y

The Y coordinate of the upper-left corner of the framing rectangle of this Ellipse2D.

Since
1.2

Constructor Detail

Floatback to summary
public Float()

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

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

Constructs and initializes an Ellipse2D from the specified coordinates.

Parameters
x:float

the X coordinate of the upper-left corner of the framing rectangle

y:float

the Y coordinate of the upper-left corner of the framing rectangle

w:float

the width of the framing rectangle

h:float

the height of the framing rectangle

Since
1.2

Method Detail

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)

Returns:Rectangle2D

an instance of Rectangle2D that is a high-precision bounding box of the Shape.

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.

Returns:double

the height of the framing rectangle.

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.

Returns:double

the width of the framing rectangle.

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.

Returns:double

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

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.

Returns:double

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

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.

Returns:boolean

true if the RectangularShape is empty; false otherwise.

Since
1.2
setFrameback to summary
public void setFrame(float x, float y, float w, float h)

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.

Parameters
x:float

the X coordinate of the upper-left corner of the specified rectangular shape

y:float

the Y coordinate of the upper-left corner of the specified rectangular shape

w:float

the width of the specified rectangular shape

h:float

the height of the specified rectangular shape

Since
1.2
setFrameback to summary
public void setFrame(double x, double y, double w, double h)

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

Doc from java.awt.geom.RectangularShape.setFrame.

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.

Parameters
x:double

the X coordinate of the upper-left corner of the specified rectangular shape

y:double

the Y coordinate of the upper-left corner of the specified rectangular shape

w:double

the width of the specified rectangular shape

h:double

the height of the specified rectangular shape

Since
1.2