Build 1.0_r1(from source)

android.graphics.drawable.shapes
Class Shape

java.lang.Object
  extended by android.graphics.drawable.shapes.Shape
Direct Known Subclasses:
PathShape, RectShape

public abstract class Shape
extends Object

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


Constructor Summary
Shape()
           
 
Method Summary
abstract  void draw(Canvas canvas, Paint paint)
          Draw this shape into the provided Canvas, with the provided Paint.
 float getHeight()
          Returns the height of the Shape.
 float getWidth()
          Returns the width of the Shape.
 boolean hasAlpha()
          Checks whether the Shape is opaque.
protected  void onResize(float width, float height)
          Callback method called when resize(float,float) is executed.
 void resize(float width, float height)
          Resizes the dimensions of this shape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shape

public Shape()
Method Detail

getWidth

public final float getWidth()
Returns the width of the Shape.


getHeight

public final float getHeight()
Returns the height of the Shape.


draw

public abstract void draw(Canvas canvas,
                          Paint paint)
Draw this shape into the provided Canvas, with the provided Paint. Before calling this, you must call resize(float,float).

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

resize

public final void resize(float width,
                         float height)
Resizes the dimensions of this shape. Must be called before draw(Canvas,Paint).

Parameters:
width - the width of the shape (in pixels)
height - the height of the shape (in pixels)

hasAlpha

public boolean hasAlpha()
Checks whether the Shape is opaque. Default impl returns true. Override if your subclass can be opaque.

Returns:
true if any part of the drawable is not opaque.

onResize

protected void onResize(float width,
                        float height)
Callback method called when resize(float,float) is executed.

Parameters:
width - the new width of the Shape
height - the new height of the Shape

Build 1.0_r1(from source)

Please submit a feedback, bug or feature