public abstract class

StrokedShape

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

Class Overview

An abstract class that represents shapes that include a stroke or outline when they are drawn. This class provides getters and setters for the visual appearance of the stroke.

Summary

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

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

Paint.Cap getStrokeCap()
Gets the stroke's cap, which determines how to treat the beginning and end of the stroke.
Paint.Join getStrokeJoin()
Gets the stroke's join type.
double getStrokeMiter()
Gets the stroke's miter value, which is used to control the behavior of miter joins when the join angle is sharp.
double getStrokeWidth()
Gets the width of the stroke.
void setStrokeCap(Paint.Cap newStrokeCap)
Sets the stroke's cap, which determines how to treat the beginning and end of the stroke.
void setStrokeJoin(Paint.Join newStrokeJoin)
Sets the stroke's join type.
void setStrokeMiter(double newStrokeMiter)
Sets the stroke's miter value, which is used to control the behavior of miter joins when the join angle is sharp.
void setStrokeWidth(double newStrokeWidth)
Sets the width of the stroke.
Protected Methods
Paint getPaint()
Gets the Paint object that describes how this shape should be drawn.
[Expand]
Inherited Methods
From class sofia.graphics.Shape
From class java.lang.Object

Public Constructors

public StrokedShape ()

Creates a new StrokedShape.

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 Paint.Cap getStrokeCap ()

Gets the stroke's cap, which determines how to treat the beginning and end of the stroke.

Returns
  • the stroke's cap

public Paint.Join getStrokeJoin ()

Gets the stroke's join type.

Returns
  • the stroke's join type

public double getStrokeMiter ()

Gets the stroke's miter value, which is used to control the behavior of miter joins when the join angle is sharp.

Returns
  • the stroke's miter value

public double getStrokeWidth ()

Gets the width of the stroke.

Returns
  • the width of the stroke

public void setStrokeCap (Paint.Cap newStrokeCap)

Sets the stroke's cap, which determines how to treat the beginning and end of the stroke.

Parameters
newStrokeCap the stroke's cap

public void setStrokeJoin (Paint.Join newStrokeJoin)

Sets the stroke's join type.

Parameters
newStrokeJoin the stroke's join type

public void setStrokeMiter (double newStrokeMiter)

Sets the stroke's miter value, which is used to control the behavior of miter joins when the join angle is sharp.

Parameters
newStrokeMiter the stroke's miter value

public void setStrokeWidth (double newStrokeWidth)

Sets the width of the stroke. A width of 0 indicates a "hairline" stroke that will always be rendered with a width of 1 pixel regardless of the scaling applied to the view.

Parameters
newStrokeWidth the new width of the stroke

Protected Methods

protected Paint getPaint ()

Gets the Paint object that describes how this shape should be drawn. By default, the Paint's style is set to STROKE and the color to the value returned by getColor(). Subclasses can override this method to add their own attributes; they should call the superclass implementation and then add their own styles to the returned object.

Returns
  • A Paint object describing how the shape should be drawn.