FileDocCategorySizeDatePackage
Shape.javaAPI DocAndroid 1.5 API2949Wed May 06 22:42:00 BST 2009android.graphics.drawable.shapes

Shape

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 android.graphics.drawable.ShapeDrawable}.

Fields Summary
private float
mWidth
private float
mHeight
Constructors Summary
Methods Summary
public android.graphics.drawable.shapes.Shapeclone()

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

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

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

        return mHeight;
    
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.

return
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.

param
width the new width of the Shape
param
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)}.

param
width the width of the shape (in pixels)
param
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);
        }