public class

RectangleShape

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

Class Overview

A shape that is drawn as a rectangle.

Summary

Public Constructors
RectangleShape()
Creates a RectangleShape with default position and size.
RectangleShape(RectF bounds)
Creates a RectangleShape with the specified bounds.
RectangleShape(float left, float top, float right, float bottom)
Creates a RectangleShape with the specified bounds.
Public Methods
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.
void setLeftTop(float left, float top)
void setRightBottom(float right, float bottom)
Protected Methods
void createFixtures()
This method is intended for internal use only, or by advanced users subclassing one of the abstract shape types.
[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 RectangleShape ()

Creates a RectangleShape with default position and size.

public RectangleShape (RectF bounds)

Creates a RectangleShape with the specified bounds.

Parameters
bounds the bounds of the rectangle

public RectangleShape (float left, float top, float right, float bottom)

Creates a RectangleShape with the specified bounds.

Parameters
left the x-coordinate of the top-left corner of the rectangle
top the y-coordinate of the top-left corner of the rectangle
right the x-coordinate of the bottom-right corner of the rectangle
bottom the y-coordinate of the bottom-right corner of the rectangle

Public Methods

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.

public void setLeftTop (float left, float top)

public void setRightBottom (float right, float bottom)

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.