Package edu.macalester.graphics
Class Ellipse
java.lang.Object
edu.macalester.graphics.GraphicsObject
edu.macalester.graphics.Ellipse
An ellipse that can be drawn on the screen.
An ellipse’s position
is the upper left corner of its bounding box.
-
Constructor Summary
ConstructorDescriptionEllipse
(double x, double y, double width, double height) Creates an ellipse whose upper left is at (x,y), and which has the specified width and height. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
For internal use.Returns the bounding box of this graphics object in its local coordinates.protected Object
For internal use only.Returns the color to fillColor that will be used to fill this shape if it is filled.Returns the color to strokeColor that will be used to stroke this shape if it is stroked.double
Returns the thickness of the stroke in pixels.boolean
isFilled()
Returns true if the interior of this shape will be filled with the fill color.boolean
Returns true if the interior of this shape will be stroked with the stroke color.void
setFillColor
(Paint fillColor) Sets the fill color to the given color.void
setFilled
(boolean filled) Causes the shape to be filled with the fill color when it is drawn.void
setSize
(double width, double height) Changes the width and height of the ellipse, preserving its upper left corner's position.void
Changes the width and height of the ellipse, preserving the position of its upper left corner.void
setStrokeColor
(Paint strokeColor) Sets the stroke color to the given color.void
setStroked
(boolean stroked) Causes the shape to be stroked with the stroke color when it is drawn.void
setStrokeWidth
(double width) Sets how thick the stroke is.boolean
testHitInLocalCoordinates
(double x, double y) Tests whether the given point is inside the boundary or interior of this object’s shape.toString()
Methods inherited from class edu.macalester.graphics.GraphicsObject
addObserver, changed, equals, getAnchor, getBoundsInParent, getCanvas, getCenter, getElementAt, getElementAtLocalCoordinates, getEmbeddedComponent, getHeight, getPosition, getRotation, getScale, getScaleX, getScaleY, getSize, getSizeInParent, getWidth, getX, getY, hashCode, isInBounds, moveBy, moveBy, removeObserver, renderToBuffer, rotateBy, setAnchor, setAnchor, setCenter, setCenter, setPosition, setPosition, setRotation, setScale, setScale, setScale, setX, setY, testHit
-
Constructor Details
-
Ellipse
public Ellipse(double x, double y, double width, double height) Creates an ellipse whose upper left is at (x,y), and which has the specified width and height. It has a 1 pixel black stroke outline by default.- Parameters:
x
- positiony
- positionwidth
- of the bounding rectangleheight
- of the bounding rectangle
-
-
Method Details
-
drawInLocalCoordinates
Description copied from class:GraphicsObject
For internal use. Draws this graphics object on the screen in its local coordinates, without rotation or scaling.- Specified by:
drawInLocalCoordinates
in classGraphicsObject
-
getFillColor
Description copied from interface:Fillable
Returns the color to fillColor that will be used to fill this shape if it is filled. Note that there will still be no fill if isFilled() is false.- Specified by:
getFillColor
in interfaceFillable
-
setFillColor
Description copied from interface:Fillable
Sets the fill color to the given color. Automatically calls setFilled(true).- Specified by:
setFillColor
in interfaceFillable
-
getStrokeColor
Description copied from interface:Strokable
Returns the color to strokeColor that will be used to stroke this shape if it is stroked. Note that there will still be no stroke if isStroked() is false or the stroke width is zero.- Specified by:
getStrokeColor
in interfaceStrokable
-
setStrokeColor
Description copied from interface:Strokable
Sets the stroke color to the given color. Automatically calls setStroked(true).- Specified by:
setStrokeColor
in interfaceStrokable
-
isFilled
public boolean isFilled()Description copied from interface:Fillable
Returns true if the interior of this shape will be filled with the fill color. -
setFilled
public void setFilled(boolean filled) Description copied from interface:Fillable
Causes the shape to be filled with the fill color when it is drawn. -
isStroked
public boolean isStroked()Description copied from interface:Strokable
Returns true if the interior of this shape will be stroked with the stroke color. -
setStroked
public void setStroked(boolean stroked) Description copied from interface:Strokable
Causes the shape to be stroked with the stroke color when it is drawn.- Specified by:
setStroked
in interfaceStrokable
-
getStrokeWidth
public double getStrokeWidth()Description copied from interface:Strokable
Returns the thickness of the stroke in pixels.- Specified by:
getStrokeWidth
in interfaceStrokable
-
setStrokeWidth
public void setStrokeWidth(double width) Description copied from interface:Strokable
Sets how thick the stroke is. Automatically calls setStroked(true).- Specified by:
setStrokeWidth
in interfaceStrokable
-
setSize
public void setSize(double width, double height) Changes the width and height of the ellipse, preserving its upper left corner's position. -
setSize
Changes the width and height of the ellipse, preserving the position of its upper left corner. -
testHitInLocalCoordinates
public boolean testHitInLocalCoordinates(double x, double y) Description copied from class:GraphicsObject
Tests whether the given point is inside the boundary or interior of this object’s shape. The point is in this object’s local coordinates.- Specified by:
testHitInLocalCoordinates
in classGraphicsObject
-
getBounds
Description copied from class:GraphicsObject
Returns the bounding box of this graphics object in its local coordinates.- Specified by:
getBounds
in classGraphicsObject
-
getEqualityAttributes
Description copied from class:GraphicsObject
For internal use only. Used to compute equals() and hashCode(). Returns an object whose equals() and hashCode() methods encompass the subclass-specific values that should be used to compute equality for the whole GraphicsObject.- Specified by:
getEqualityAttributes
in classGraphicsObject
-
toString
-