Shape.javaAPI DocAndroid 5.1 API3351Thu Mar 12 22:22:30 GMT


public abstract class Shape extends Object implements Cloneable
Defines a generic graphical "shape." Any Shape can be drawn to a Canvas with its own draw() method, but more graphical control is available if you instead pass it to a {@link}.

Fields Summary
private float
private float
Constructors Summary
Methods Summary

        return (Shape) super.clone();
public abstract voiddraw( canvas, paint)
Draw this shape into the provided Canvas, with the provided Paint. Before calling this, you must call {@link #resize(float,float)}.

canvas the Canvas within which this shape should be drawn
paint the Paint object that defines this shape's characteristics

public final floatgetHeight()
Returns the height of the Shape.

        return mHeight;
public voidgetOutline( outline)
Compute the Outline of the shape and return it in the supplied Outline parameter. The default implementation does nothing and {@code outline} is not changed.

outline The Outline to be populated with the result. Should not be null.

public final floatgetWidth()
Returns the width of the Shape.

        return mWidth;
public booleanhasAlpha()
Checks whether the Shape is opaque. Default impl returns true. Override if your subclass can be opaque.

true if any part of the drawable is not opaque.

        return true;
protected voidonResize(float width, float height)
Callback method called when {@link #resize(float,float)} is executed.

width the new width of the Shape
height the new height of the Shape

public final voidresize(float width, float height)
Resizes the dimensions of this shape. Must be called before {@link #draw(Canvas,Paint)}.

width the width of the shape (in pixels)
height the height of the shape (in pixels)

        if (width < 0) {
            width = 0;
        if (height < 0) {
            height =0;
        if (mWidth != width || mHeight != height) {
            mWidth = width;
            mHeight = height;
            onResize(width, height);