public abstract class

Stroke

extends Object
java.lang.Object
   ↳ com.htc.painting.engine.stroke.Stroke
Known Direct Subclasses

Class Overview

A Stroke is a drawing that is generated when a user touches, moves, and leaves the screen. The user can touch the screen either by hand or by a pen. A Stroke is represented by a path and other informations that determines the drawing texture.

Summary

Constants
int INVALID_STROKE_ID Invalid stroke id
Fields
protected long mCreationTime
protected int mId
protected boolean mIsDestroyed
protected boolean mIsEffective
protected Path mPath
protected List<MotionPoint> mPoints
protected RectF mRectF
protected StrokeProperties mStrokeProperties
Public Constructors
Stroke(int id)
Constructor os an stroke
Stroke(int id, ByteArrayInputStream is)
Constructor of an stroke
Stroke(int id, StrokeProperties property)
Constructor of a Stroke.
Public Methods
abstract Stroke create(List<MotionPoint> points)
abstract int deserialize(ByteArrayInputStream is)
final void destroy()
void draw(Canvas canvas, int startIndex, int endIndex)
if stroke support partial render.
abstract void draw(Canvas canvas)
final void end(Canvas canvas, RectF dirtyRect)
long getCreationTime()
creation time of stroke
int getId()
getter function for the Stroke's id
List<MotionPoint> getMotionPoints()
Get sequence of MotionPoint
Path getPath()
Get path of the Stroke
StrokeProperties getProperties()
Get the StrokeProperties of the Stroke
RectF getRect()
Get Bounding Rect of Stroke
int getTotalBytes()
if stroke could provide memory information, override this function
boolean isDestroyed()
Indicates whether this Stroke is destroyed
boolean isEffective()
Indicates whether this Stroke is effective
final void move(Canvas canvas, float x, float y, float pressure, float size, RectF dirtyRect)
abstract boolean serialize(ByteArrayOutputStream os)
void setEffective(boolean effective)
mark this Stroke to be effective or ineffective
final void start(Canvas canvas, RectF dirtyRect)
void transform(Matrix m)
Protected Methods
boolean filterOutPoint(float preX, float preY, float currentX, float currentY)
Given previous and current points to decide filter out point or not
void onDestroy()
Implement this to customized your own data
void onEnd(Canvas canvas, RectF dirtyRect)
Implement this to customized your own data
void onMove(Canvas canvas, float x, float y, float pressure, float size, RectF dirtyRect)
Implement this to customized your own data
void onStart(Canvas canvas, RectF dirtyRect)
Implement this to customized your own data
void setStrokeId(int id)
void updateBoundingRect(RectF dirtyRect)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int INVALID_STROKE_ID

Since: API Level 2.0

Invalid stroke id

Constant Value: -2147483648 (0x80000000)

Fields

protected long mCreationTime

Since: API Level 2.0

protected int mId

Since: API Level 2.0

protected boolean mIsDestroyed

Since: API Level 2.0

protected boolean mIsEffective

Since: API Level 2.0

protected Path mPath

Since: API Level 2.0

protected List<MotionPoint> mPoints

Since: API Level 2.0

protected RectF mRectF

Since: API Level 2.0

protected StrokeProperties mStrokeProperties

Since: API Level 2.0

Public Constructors

public Stroke (int id)

Since: API Level 2.0

Constructor os an stroke

Parameters
id the id of the Stroke

public Stroke (int id, ByteArrayInputStream is)

Since: API Level 2.0

Constructor of an stroke

Parameters
id the id of the Stroke
is an intput stream that provides the data to convert to a Stroke

public Stroke (int id, StrokeProperties property)

Since: API Level 2.0

Constructor of a Stroke.

Parameters
id the id of the Stroke
property the StrokeProperties of with this Stroke

Public Methods

public abstract Stroke create (List<MotionPoint> points)

Since: API Level 4.0

public abstract int deserialize (ByteArrayInputStream is)

Since: API Level 2.0

Throws
IOException

public final void destroy ()

Since: API Level 2.0

public void draw (Canvas canvas, int startIndex, int endIndex)

Since: API Level 2.0

if stroke support partial render. override this function

public abstract void draw (Canvas canvas)

Since: API Level 2.0

public final void end (Canvas canvas, RectF dirtyRect)

Since: API Level 2.0

public long getCreationTime ()

Since: API Level 2.0

creation time of stroke

public int getId ()

Since: API Level 2.0

getter function for the Stroke's id

Returns
  • the id of this Stroke

public List<MotionPoint> getMotionPoints ()

Since: API Level 2.0

Get sequence of MotionPoint

public Path getPath ()

Since: API Level 2.0

Get path of the Stroke

public StrokeProperties getProperties ()

Since: API Level 2.0

Get the StrokeProperties of the Stroke

Returns
  • the StrokeProperties of the Stroke

public RectF getRect ()

Since: API Level 2.0

Get Bounding Rect of Stroke

public int getTotalBytes ()

Since: API Level 2.0

if stroke could provide memory information, override this function

public boolean isDestroyed ()

Since: API Level 2.0

Indicates whether this Stroke is destroyed

Returns
  • true if the Stroke is destroyed, false otherwise.

public boolean isEffective ()

Since: API Level 2.0

Indicates whether this Stroke is effective

Returns
  • true if the Stroke is effective, false otherwise.

public final void move (Canvas canvas, float x, float y, float pressure, float size, RectF dirtyRect)

Since: API Level 2.0

public abstract boolean serialize (ByteArrayOutputStream os)

Since: API Level 2.0

Throws
IOException

public void setEffective (boolean effective)

Since: API Level 2.0

mark this Stroke to be effective or ineffective

Parameters
effective true to mark Stroke effective, false otherwise

public final void start (Canvas canvas, RectF dirtyRect)

Since: API Level 2.0

public void transform (Matrix m)

Since: API Level 2.0

Protected Methods

protected boolean filterOutPoint (float preX, float preY, float currentX, float currentY)

Since: API Level 2.0

Given previous and current points to decide filter out point or not

Parameters
preX x of previous point
preY y of previous point
currentX x of current point
currentY y of current point
Returns
  • true to filter out current point

protected void onDestroy ()

Since: API Level 2.0

Implement this to customized your own data

protected void onEnd (Canvas canvas, RectF dirtyRect)

Since: API Level 2.0

Implement this to customized your own data

protected void onMove (Canvas canvas, float x, float y, float pressure, float size, RectF dirtyRect)

Since: API Level 2.0

Implement this to customized your own data

protected void onStart (Canvas canvas, RectF dirtyRect)

Since: API Level 2.0

Implement this to customized your own data

protected void setStrokeId (int id)

Since: API Level 2.0

protected void updateBoundingRect (RectF dirtyRect)

Since: API Level 2.0