java.lang.Object | ||||
↳ | sofia.graphics.Shape | |||
↳ | sofia.graphics.StrokedShape | |||
↳ | sofia.graphics.FillableShape | |||
↳ | sofia.graphics.OvalShape |
Known Direct Subclasses |
A shape that is drawn as an oval.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
OvalShape()
Creates an
OvalShape with default position and size. | |||||||||||
OvalShape(RectF bounds)
Creates an
OvalShape with the specified bounds. | |||||||||||
OvalShape(PointF center, float radius)
Creates a circular
OvalShape with the specified center point
and radius. | |||||||||||
OvalShape(float x, float y, float radius)
Creates a circular
OvalShape with the specified center point
and radius. | |||||||||||
OvalShape(PointF center, float horizontalRadius, float verticalRadius)
Creates an
OvalShape with the specified center point and
horizontal and vertical radii. | |||||||||||
OvalShape(float x, float y, float horizontalRadius, float verticalRadius)
Creates an
OvalShape with the specified center point and
horizontal and vertical radii. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean |
contains(float x, float y)
Gets a value indicating whether the specified pixel location is contained in the receiver. | ||||||||||
void |
draw(Canvas canvas)
Subclasses must implement this method to define how the shape is to be
drawn on the canvas.
| ||||||||||
RectF |
getBounds()
Gets the bounding rectangle of the shape.
| ||||||||||
void |
setBounds(RectF newBounds)
Sets the bounding rectangle of the shape.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
createFixtures()
This method is intended for internal use only, or by advanced
users subclassing one of the abstract shape types.
| ||||||||||
Paint |
getFillPaint()
Gets a
Paint used to fill the shape. | ||||||||||
Paint |
getPaint()
Gets the
Paint object that describes how this shape should be
drawn. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
sofia.graphics.FillableShape
| |||||||||||
From class
sofia.graphics.StrokedShape
| |||||||||||
From class
sofia.graphics.Shape
| |||||||||||
From class
java.lang.Object
|
Creates an OvalShape
with default position and size.
Creates a circular OvalShape
with the specified center point
and radius.
center | the center of the circle |
---|---|
radius | the radius of the circle |
Creates a circular OvalShape
with the specified center point
and radius.
x | the x-coordinate of the center of the circle |
---|---|
y | the y-coordinate of the center of the circle |
radius | the radius of the circle |
Creates an OvalShape
with the specified center point and
horizontal and vertical radii.
center | the center of the oval |
---|---|
horizontalRadius | the radius of the oval along the x-axis |
verticalRadius | the radius of the oval along the y-axis |
Creates an OvalShape
with the specified center point and
horizontal and vertical radii.
x | the x-coordinate of the center of the oval |
---|---|
y | the y-coordinate of the center of the oval |
horizontalRadius | the radius of the oval along the x-axis |
verticalRadius | the radius of the oval along the y-axis |
Gets a value indicating whether the specified pixel location is contained in the receiver.
By default, this method checks to see whether the point is located within the bounding rectangle of the shape. Shapes where this would produce incorrect results, such as ovals or lines, override this method accordingly.
This method does take the shape's rotation into
account. This means that if you subclass Shape
and need to
provide logic that is different from the default bounding box behavior,
then you may need to undo the rotation of the incoming point before
testing it against your shape's bounds. The
inverseTransformPoint(float, float)
method has been provided
to simplify this.
x | The x-coordinate. |
---|---|
y | The y-coordinate. |
Subclasses must implement this method to define how the shape is to be drawn on the canvas. Users should never call this method directly; it is called as part of the repaint cycle by the ShapeView that contains the shape.
canvas | The Canvas on which to draw the shape.
|
---|
Gets the bounding rectangle of the shape. The top-left corner of the bounding rectangle is the shape's origin, and the bottom-right corner is the shape's extent.
Sets the bounding rectangle of the shape. The bounding rectangle passed to this method is copied, so changes to it after this method is called will not be reflected by the shape.
newBounds | The new bounding rectangle of the shape. |
---|
This method is intended for internal use only, or by advanced
users subclassing one of the abstract shape types. Subclasses
must override this method to create the necessary fixtures for the body
that this shape represents. Use the getB2Body()
method to access
the body when creating fixtures.
Gets a Paint
used to fill the shape. Android's drawing
primitives in the Canvas
class do not support having separate
stroke and fill colors in a single drawing operation, so subclasses of
FillableShape
s typically draw themselves twice -- once for the
fill, using the Paint
returned by this method, and then again
for the outline, using the Paint
returned by
getPaint()
.
Paint
used to fill the shape when it is drawn
Gets the Paint
object that describes how this shape should be
drawn. By default, the Paint
's style is set to STROKE
and the color to the value returned by getColor()
. Subclasses
can override this method to add their own attributes; they should call
the superclass implementation and then add their own styles to the
returned object.