edu.rit.draw.item
Class Ellipse
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class Ellipse extends RectangularItem
Class Ellipse provides an ellipse DrawingItem. A circle is a special case of an ellipse with equal width and height.The static defaultSize(), defaultWidth(), and defaultHeight() methods are provided to set the default size, width, and height. If an ellipse's size, width, or height is not specified, the current default size, width, or height is used.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleNORMAL_HEIGHTThe normal height for ellipses (72).static doubleNORMAL_WIDTHThe normal width for ellipses (72).-
Fields inherited from class edu.rit.draw.item.FilledItem
NORMAL_FILL
-
Fields inherited from class edu.rit.draw.item.OutlinedItem
NORMAL_OUTLINE
-
-
Constructor Summary
Constructors Constructor and Description Ellipse()Construct a new ellipse.Ellipse(Ellipse theItem)Construct a new ellipse with the same outline, fill paint, location, and size as the given ellipse.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Ellipseadd()Add this ellipse to the end of the default drawing's sequence of drawing items.Ellipseadd(Drawing theDrawing)Add this ellipse to the end of the given drawing's sequence of drawing items.EllipseaddFirst()Add this ellipse to the beginning of the default drawing's sequence of drawing items.EllipseaddFirst(Drawing theDrawing)Add this ellipse to the beginning of the given drawing's sequence of drawing items.Ellipsec(double x, double y)Set the center point of this ellipse's bounding box.Ellipsec(Point thePoint)Set the center point of this ellipse's bounding box.PointcircumferencePoint(double angle)Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center.PointcircumferencePoint(double angle, double length)Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center, extended outward by the given length.PointcircumferencePointDegrees(double angle)Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center.PointcircumferencePointDegrees(double angle, double length)Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center, extended outward by the given length.static doubledefaultHeight()Returns the default height for ellipses.static voiddefaultHeight(double theHeight)Set the default height for ellipses.static SizedefaultSize()Returns the default size for ellipses.static voiddefaultSize(Size theSize)Set the default size for ellipses.static doubledefaultWidth()Returns the default width for ellipses.static voiddefaultWidth(double theWidth)Set the default width for ellipses.Ellipsediameter(double theDiameter)Set the width and height of this ellipse's bounding box to make this ellipse a circle.Ellipsee(double x, double y)Set the east middle point of this ellipse's bounding box.Ellipsee(Point thePoint)Set the east middle point of this ellipse's bounding box.Ellipsefill(Fill theFill)Set this ellipse's fill paint.Ellipseheight(double theHeight)Set the height of this ellipse's bounding box.Ellipsen(double x, double y)Set the north middle point of this ellipse's bounding box.Ellipsen(Point thePoint)Set the north middle point of this ellipse's bounding box.Ellipsene(double x, double y)Set the northeast corner point of this ellipse's bounding box.Ellipsene(Point thePoint)Set the northeast corner point of this ellipse's bounding box.Ellipsenw(double x, double y)Set the northwest corner point of this ellipse's bounding box.Ellipsenw(Point thePoint)Set the northwest corner point of this ellipse's bounding box.Ellipseoutline(Outline theOutline)Set this ellipse's outline.PointperimeterIntersection(double x, double y)Returns the point of intersection between (1) this ellipse's perimeter and (2) the line passing through this ellipse's center and the given point.PointperimeterIntersection(Point point)Returns the point of intersection between (1) this ellipse's perimeter and (2) the line passing through this ellipse's center and the given point.Ellipses(double x, double y)Set the south middle point of this ellipse's bounding box.Ellipses(Point thePoint)Set the south middle point of this ellipse's bounding box.Ellipsese(double x, double y)Set the southeast corner point of this ellipse's bounding box.Ellipsese(Point thePoint)Set the southeast corner point of this ellipse's bounding box.Ellipsesize(Size theSize)Set the size of this ellipse's bounding box.Ellipsesw(double x, double y)Set the southwest corner point of this ellipse's bounding box.Ellipsesw(Point thePoint)Set the southwest corner point of this ellipse's bounding box.Ellipsew(double x, double y)Set the west middle point of this ellipse's bounding box.Ellipsew(Point thePoint)Set the west middle point of this ellipse's bounding box.Ellipsewidth(double theWidth)Set the width of this ellipse's bounding box.-
Methods inherited from class edu.rit.draw.item.RectangularItem
height, nw, readExternal, width, writeExternal
-
Methods inherited from class edu.rit.draw.item.FilledItem
defaultFill, defaultFill, fill
-
Methods inherited from class edu.rit.draw.item.OutlinedItem
defaultOutline, defaultOutline, outline
-
-
-
-
Field Detail
-
NORMAL_WIDTH
public static final double NORMAL_WIDTH
The normal width for ellipses (72). Note: 72 points = 1 inch.- See Also:
- Constant Field Values
-
NORMAL_HEIGHT
public static final double NORMAL_HEIGHT
The normal height for ellipses (72). Note: 72 points = 1 inch.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Ellipse
public Ellipse()
Construct a new ellipse. The ellipse's northwest corner is located at (0,0). The ellipse's size is the default size.
-
Ellipse
public Ellipse(Ellipse theItem)
Construct a new ellipse with the same outline, fill paint, location, and size as the given ellipse.- Parameters:
theItem- Ellipse.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theItem is null.
-
-
Method Detail
-
defaultSize
public static Size defaultSize()
Returns the default size for ellipses.- Returns:
- Default size.
-
defaultSize
public static void defaultSize(Size theSize)
Set the default size for ellipses.- Parameters:
theSize- Default size.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the width or the height of theSize is less than 0.
-
defaultWidth
public static double defaultWidth()
Returns the default width for ellipses.- Returns:
- Default width.
-
defaultWidth
public static void defaultWidth(double theWidth)
Set the default width for ellipses.- Parameters:
theWidth- Default width.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theWidth is less than 0.
-
defaultHeight
public static double defaultHeight()
Returns the default height for ellipses.- Returns:
- Default height.
-
defaultHeight
public static void defaultHeight(double theHeight)
Set the default height for ellipses.- Parameters:
theHeight- Default height.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theHeight is less than 0.
-
outline
public Ellipse outline(Outline theOutline)
Set this ellipse's outline.- Overrides:
outlinein classRectangularItem- Parameters:
theOutline- Outline, or Outline.NONE.- Returns:
- This ellipse.
-
fill
public Ellipse fill(Fill theFill)
Set this ellipse's fill paint.- Overrides:
fillin classRectangularItem- Parameters:
theFill- Fill paint, or Fill.NONE.- Returns:
- This ellipse.
-
size
public Ellipse size(Size theSize)
Set the size of this ellipse's bounding box.- Overrides:
sizein classRectangularItem- Parameters:
theSize- Size.- Returns:
- This ellipse.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the width or the height of theSize is less than 0.
-
width
public Ellipse width(double theWidth)
Set the width of this ellipse's bounding box.- Overrides:
widthin classRectangularItem- Parameters:
theWidth- Width.- Returns:
- This ellipse.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theWidth is less than 0.
-
height
public Ellipse height(double theHeight)
Set the height of this ellipse's bounding box.- Overrides:
heightin classRectangularItem- Parameters:
theHeight- Height.- Returns:
- This ellipse.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theHeight is less than 0.
-
diameter
public Ellipse diameter(double theDiameter)
Set the width and height of this ellipse's bounding box to make this ellipse a circle.- Parameters:
theDiameter- Diameter.- Returns:
- This ellipse.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theDiameter is less than 0.
-
nw
public Ellipse nw(double x, double y)
Set the northwest corner point of this ellipse's bounding box.- Overrides:
nwin classRectangularItem- Parameters:
x- X coordinate of northwest corner point.y- Y coordinate of northwest corner point.- Returns:
- This ellipse.
-
nw
public Ellipse nw(Point thePoint)
Set the northwest corner point of this ellipse's bounding box.- Overrides:
nwin classRectangularItem- Parameters:
thePoint- Northwest corner point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
n
public Ellipse n(double x, double y)
Set the north middle point of this ellipse's bounding box.- Overrides:
nin classRectangularItem- Parameters:
x- X coordinate of north middle point.y- Y coordinate of north middle point.- Returns:
- This ellipse.
-
n
public Ellipse n(Point thePoint)
Set the north middle point of this ellipse's bounding box.- Overrides:
nin classRectangularItem- Parameters:
thePoint- North middle point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
ne
public Ellipse ne(double x, double y)
Set the northeast corner point of this ellipse's bounding box.- Overrides:
nein classRectangularItem- Parameters:
x- X coordinate of northeast corner point.y- Y coordinate of northeast corner point.- Returns:
- This ellipse.
-
ne
public Ellipse ne(Point thePoint)
Set the northeast corner point of this ellipse's bounding box.- Overrides:
nein classRectangularItem- Parameters:
thePoint- Northeast corner point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
w
public Ellipse w(double x, double y)
Set the west middle point of this ellipse's bounding box.- Overrides:
win classRectangularItem- Parameters:
x- X coordinate of west middle point.y- Y coordinate of west middle point.- Returns:
- This ellipse.
-
w
public Ellipse w(Point thePoint)
Set the west middle point of this ellipse's bounding box.- Overrides:
win classRectangularItem- Parameters:
thePoint- West middle point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
c
public Ellipse c(double x, double y)
Set the center point of this ellipse's bounding box.- Overrides:
cin classRectangularItem- Parameters:
x- X coordinate of center point.y- Y coordinate of center point.- Returns:
- This ellipse.
-
c
public Ellipse c(Point thePoint)
Set the center point of this ellipse's bounding box.- Overrides:
cin classRectangularItem- Parameters:
thePoint- Center point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
e
public Ellipse e(double x, double y)
Set the east middle point of this ellipse's bounding box.- Overrides:
ein classRectangularItem- Parameters:
x- X coordinate of east middle point.y- Y coordinate of east middle point.- Returns:
- This ellipse.
-
e
public Ellipse e(Point thePoint)
Set the east middle point of this ellipse's bounding box.- Overrides:
ein classRectangularItem- Parameters:
thePoint- East middle point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
sw
public Ellipse sw(double x, double y)
Set the southwest corner point of this ellipse's bounding box.- Overrides:
swin classRectangularItem- Parameters:
x- X coordinate of southwest corner point.y- Y coordinate of southwest corner point.- Returns:
- This ellipse.
-
sw
public Ellipse sw(Point thePoint)
Set the southwest corner point of this ellipse's bounding box.- Overrides:
swin classRectangularItem- Parameters:
thePoint- Southwest corner point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
s
public Ellipse s(double x, double y)
Set the south middle point of this ellipse's bounding box.- Overrides:
sin classRectangularItem- Parameters:
x- X coordinate of south middle point.y- Y coordinate of south middle point.- Returns:
- This ellipse.
-
s
public Ellipse s(Point thePoint)
Set the south middle point of this ellipse's bounding box.- Overrides:
sin classRectangularItem- Parameters:
thePoint- South middle point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
se
public Ellipse se(double x, double y)
Set the southeast corner point of this ellipse's bounding box.- Overrides:
sein classRectangularItem- Parameters:
x- X coordinate of southeast corner point.y- Y coordinate of southeast corner point.- Returns:
- This ellipse.
-
se
public Ellipse se(Point thePoint)
Set the southeast corner point of this ellipse's bounding box.- Overrides:
sein classRectangularItem- Parameters:
thePoint- Southeast corner point.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePoint is null.
-
add
public Ellipse add()
Add this ellipse to the end of the default drawing's sequence of drawing items.- Overrides:
addin classRectangularItem- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if there is no default drawing.- See Also:
Drawing.defaultDrawing()
-
add
public Ellipse add(Drawing theDrawing)
Add this ellipse to the end of the given drawing's sequence of drawing items.- Overrides:
addin classRectangularItem- Parameters:
theDrawing- Drawing.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theDrawing is null.
-
addFirst
public Ellipse addFirst()
Add this ellipse to the beginning of the default drawing's sequence of drawing items.- Overrides:
addFirstin classRectangularItem- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if there is no default drawing.- See Also:
Drawing.defaultDrawing()
-
addFirst
public Ellipse addFirst(Drawing theDrawing)
Add this ellipse to the beginning of the given drawing's sequence of drawing items.- Overrides:
addFirstin classRectangularItem- Parameters:
theDrawing- Drawing.- Returns:
- This ellipse.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theDrawing is null.
-
circumferencePoint
public Point circumferencePoint(double angle)
Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center. The point on the ellipse's circumference is determined by angle, measured in radians. An angle of 0 gives the east point; an angle of pi/2 gives the south point; an angle of pi gives the west point; an angle of 3*pi/2 gives the north point.- Parameters:
angle- Angle (radians).- Returns:
- Point on this ellipse's circumference.
-
circumferencePointDegrees
public Point circumferencePointDegrees(double angle)
Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center. The point on the ellipse's circumference is determined by angle, measured in degrees. An angle of 0 gives the east point; an angle of 90 gives the south point; an angle of 180 gives the west point; an angle of 270 gives the north point.- Parameters:
angle- Angle (degrees).- Returns:
- Point on this ellipse's circumference.
-
circumferencePoint
public Point circumferencePoint(double angle, double length)
Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center, extended outward by the given length. First, a point on this ellipse's circumference is determined by angle, measured in radians. An angle of 0 gives the east point; an angle of pi/2 gives the south point; an angle of pi gives the west point; an angle of 3*pi/2 gives the north point. A line is projected from the center of this ellipse, through the point on the circumference, for a further distance of length; the endpoint of this line is returned.- Parameters:
angle- Angle (radians).length- Length to extend from circumference.- Returns:
- Point extended outward from this ellipse's circumference.
-
circumferencePointDegrees
public Point circumferencePointDegrees(double angle, double length)
Returns the point on the circumference of this ellipse at the given angle relative to this ellipse's center, extended outward by the given length. First, a point on this ellipse's circumference is determined by angle, measured in degrees. An angle of 0 gives the east point; an angle of 90 gives the south point; an angle of 180 gives the west point; an angle of 270 gives the north point. A line is projected from the center of this ellipse, through the point on the circumference, for a further distance of length; the endpoint of this line is returned.- Parameters:
angle- Angle (degrees).length- Length to extend from circumference.- Returns:
- Point extended outward from this ellipse's circumference.
-
perimeterIntersection
public Point perimeterIntersection(Point point)
Returns the point of intersection between (1) this ellipse's perimeter and (2) the line passing through this ellipse's center and the given point.- Parameters:
point- One point on the line.- Returns:
- Point of intersection between perimeter and line.
-
perimeterIntersection
public Point perimeterIntersection(double x, double y)
Returns the point of intersection between (1) this ellipse's perimeter and (2) the line passing through this ellipse's center and the given point.- Parameters:
x- X coordinate of one point on the line.y- Y coordinate of one point on the line.- Returns:
- Point of intersection between perimeter and line.
-
-
DMelt 3.0 © DataMelt by jWork.ORG