public abstract class

FillableShape

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

Class Overview

An abstract class that represents shapes that can be filled when they are drawn, and for which the fill color can be set independently of the shape's other color (for the stroke).

Summary

Nested Classes
class FillableShape.Animator<AnimatorType extends Animator<AnimatorType>> Provides animation support for shapes. 
Public Constructors
FillableShape()
Creates a new FillableShape.
Public Methods
Animator<?> animate(long duration)

Gets an animator object that lets the user animate properties of the receiving shape.

int getAlpha()

A convenience method that gets the alpha (opacity) component of the shape's color.

Color getFillColor()
Gets the color used to fill the shape.
Image getImage()
boolean isFilled()
Gets a value indicating whether the shape will be filled when it is drawn.
void setAlpha(int newAlpha)
A convenience method that sets the alpha (opacity) component of the shape's color and fill color without changing the other color components.
void setFillColor(Color newFillColor)
Sets the color used to fill the shape.
void setFilled(boolean newFilled)
Sets a value indicating whether the shape will be filled when it is drawn.
void setImage(Image newImage)
void setImage(String imageName)
Protected Methods
void drawBitmap(Canvas canvas)
Paint getFillPaint()
Gets a Paint used to fill the shape.
Paint getImagePaint()
[Expand]
Inherited Methods
From class sofia.graphics.StrokedShape
From class sofia.graphics.Shape
From class java.lang.Object

Public Constructors

public FillableShape ()

Creates a new FillableShape.

Public Methods

public Animator<?> animate (long duration)

Gets an animator object that lets the user animate properties of the receiving shape.

For ease of use, the description of the animation desired can be chained directly to the result of this method. For example, the following code fragment would create an animation that runs for 2 seconds, gradually changing the shape's color to red, its position to the top-right corner of the view, and then starts the animation after a delay of 1 second after the method is called:

     shape.animate(2000)
          .delay(1000)
          .color(Color.red)
          .position(Anchor.TOP_RIGHT.ofView())
          .play();

Parameters
duration The length of the animation in milliseconds.
Returns
  • A ShapeAnimator that lets the user animate properties of the receiving shape.

public int getAlpha ()

A convenience method that gets the alpha (opacity) component of the shape's color.

Note that calling the setAlpha(int) method will update the alpha components of both the color and the fill color of the shape, so this method would return the single alpha value in that case. In the event that the shape's color and fill color have been set explicitly to have different alpha components, this method returns the alpha component of the color returned by getColor().

Returns
  • The alpha component of the shape's color, where 0 means that the color is fully transparent and 255 means that it is fully opaque.

public Color getFillColor ()

Gets the color used to fill the shape. This color can be set explicitly by calling setFillColor(Color); if it has not been set, then the shape's color as defined by getColor() will be used to fill the shape.

Returns
  • the Color used to fill the shape

public Image getImage ()

public boolean isFilled ()

Gets a value indicating whether the shape will be filled when it is drawn.

Returns
  • true if the shape will be filled when it is drawn, or false if it will be drawn as an outline

public void setAlpha (int newAlpha)

A convenience method that sets the alpha (opacity) component of the shape's color and fill color without changing the other color components.

Parameters
newAlpha The new alpha component of the shape's color, where 0 means that the color is fully transparent and 255 means that it is fully opaque.

public void setFillColor (Color newFillColor)

Sets the color used to fill the shape. If it has not been set, then the shape's color as defined by getColor() will be used to fill the shape.

Parameters
newFillColor the Color to use to fill the shape

public void setFilled (boolean newFilled)

Sets a value indicating whether the shape will be filled when it is drawn.

Parameters
newFilled true if the shape will be filled when it is drawn, or false to draw it as an outline

public void setImage (Image newImage)

public void setImage (String imageName)

Protected Methods

protected void drawBitmap (Canvas canvas)

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 getImagePaint ()