public class

OvalShape

extends FillableShape
java.lang.Object
   ↳ sofia.graphics.Shape
     ↳ sofia.graphics.StrokedShape
       ↳ sofia.graphics.FillableShape
         ↳ sofia.graphics.OvalShape
Known Direct Subclasses

Class Overview

A shape that is drawn as an oval.

Summary

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

Public Constructors

public OvalShape ()

Creates an OvalShape with default position and size.

public OvalShape (RectF bounds)

Creates an OvalShape with the specified bounds.

public OvalShape (PointF center, float radius)

Creates a circular OvalShape with the specified center point and radius.

Parameters
center the center of the circle
radius the radius of the circle

public OvalShape (float x, float y, float radius)

Creates a circular OvalShape with the specified center point and radius.

Parameters
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

public OvalShape (PointF center, float horizontalRadius, float verticalRadius)

Creates an OvalShape with the specified center point and horizontal and vertical radii.

Parameters
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

public OvalShape (float x, float y, float horizontalRadius, float verticalRadius)

Creates an OvalShape with the specified center point and horizontal and vertical radii.

Parameters
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

Public Methods

public boolean contains (float x, float y)

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.

Parameters
x The x-coordinate.
y The y-coordinate.
Returns
  • True if the shape contains the point, otherwise false.

public void draw (Canvas canvas)

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.

Parameters
canvas The Canvas on which to draw the shape.

public RectF getBounds ()

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.

Returns
  • The bounding rectangle of the shape.

public void setBounds (RectF newBounds)

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.

Parameters
newBounds The new bounding rectangle of the shape.

Protected Methods

protected void createFixtures ()

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.

protected Paint getFillPaint ()

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 FillableShapes 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().

Returns
  • the Paint used to fill the shape when it is drawn

protected Paint getPaint ()

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.

Returns
  • A Paint object describing how the shape should be drawn.