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

Invalid stroke id

Constant Value: -2147483648 (0x80000000)

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

public Stroke (int id)

Constructor os an stroke

Parameters
id the id of the Stroke

public Stroke (int id, ByteArrayInputStream is)

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)

Constructor of a Stroke.

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

Public Methods

public abstract int deserialize (ByteArrayInputStream is)

Throws
IOException

public final void destroy ()

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

if stroke support partial render. override this function

public abstract void draw (Canvas canvas)

public final void end (Canvas canvas, RectF dirtyRect)

public long getCreationTime ()

creation time of stroke

public int getId ()

getter function for the Stroke's id

Returns
  • the id of this Stroke

public List<MotionPoint> getMotionPoints ()

Get sequence of MotionPoint

public Path getPath ()

Get path of the Stroke

public StrokeProperties getProperties ()

Get the StrokeProperties of the Stroke

Returns
  • the StrokeProperties of the Stroke

public RectF getRect ()

Get Bounding Rect of Stroke

public int getTotalBytes ()

if stroke could provide memory information, override this function

public boolean isDestroyed ()

Indicates whether this Stroke is destroyed

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

public boolean isEffective ()

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)

public abstract boolean serialize (ByteArrayOutputStream os)

Throws
IOException

public void setEffective (boolean effective)

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)

public void transform (Matrix m)

Protected Methods

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

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

Implement this to customized your own data

protected void onEnd (Canvas canvas, RectF dirtyRect)

Implement this to customized your own data

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

Implement this to customized your own data

protected void onStart (Canvas canvas, RectF dirtyRect)

Implement this to customized your own data

protected void setStrokeId (int id)

protected void updateBoundingRect (RectF dirtyRect)