public class

HtcPaintingView

extends RelativeLayout
implements IStrokeNotifyPaintingView
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.RelativeLayout
         ↳ com.htc.painting.engine.HtcPaintingView

Class Overview

This class is an implementation of IStrokeNotifyPaintingView. It implements all functionalities of the IPaintingView and IStrokeNotifyPaintingView. Besides the features defined in IPaintingView and IStrokeNotifyPaintingView, HtcPaintingView also provides basic mechanism to save/load stroke information.

Summary

Nested Classes
interface HtcPaintingView.OnCacheListener Interface definition for a callback to be invoked when an Cache events occur. 
Constants
int NO_SEPARATOR
[Expand]
Inherited Constants
From class android.widget.RelativeLayout
From class android.view.ViewGroup
From class android.view.View
Fields
protected boolean mEnableEditMode
protected List<IPaintingView.OnPaintingViewListener> mPaintingViewListener
[Expand]
Inherited Fields
From class android.view.ViewGroup
From class android.view.View
Public Constructors
HtcPaintingView(Context context)
same as FrameLayout's constructor
HtcPaintingView(Context context, AttributeSet attrs)
same as FrameLayout's constructor
HtcPaintingView(Context context, AttributeSet attrs, int defStyle)
same as FrameLayout's constructor
Public Methods
boolean canRedo()
Indicates whether redo operation can be performed on this HtcPaintingView.
boolean canUndo()
Indicates whether undo operation can be performed on this HtcPaintingView.
void clearAll()
Clear all strokes from this HtcPaitingView.
void clearStrokeGroup(int groupId)
clear all strokes in a stroke group
void clearStrokeGroups(int[] groupIds)
clear all strokes in the specified StrokeGroups
void clearUndoRedoHistory()
clear undo/redo history.
void deleteStrokeGroup(int groupId)
Delete aStrokeGroup from this HtcPaintingView
void destroy()
This function release all resources within the HtcPainting.
boolean dispatchTouchEvent(MotionEvent event)
void drawOnBitmap(Bitmap bitmap, int groupId, int strokeId, ViewPort viewport)
Draws a specific Stroke and Viewport of a specific StrokeGroup on the input bitmap.
void drawOnBitmap(Bitmap bitmap, int groupId, int strokeId)
Draws a specific Stroke of a specific StrokeGroup on the input bitmap.
void drawOnBitmap(Bitmap bitmap, int groupId, ViewPort viewport)
Draw a specific StrokeGroups onto a bitmap with respect to the given viewport
void drawOnBitmap(Bitmap bitmap, int[] groupIds)
Draw a specific StrokeGroups onto a bitmap
void drawOnCanvas(Canvas canvas)
Draw requested groups on targes canvas
void drawStroke(Canvas canvas, int groupId, int strokeId, int startPoint, int endPoint, ViewPort viewport)
This function will draw a specific segment of a stroke on the input canvas The startPoint and endPoint together specify the segment in the Stroke to be drawn.
void drawStroke(Canvas canvas, int groupId, int strokeId, int startPoint, int endPoint)
This function will draw a specific segment of a stroke on the input canvas The startPoint and endPoint together specify the segment in the Stroke to be drawn.
void enableEraseMode(boolean enable)
Enable/disable erase mode
void enablePainting(boolean enable)
enable/disable HtcPainting This function is originally designed to show/hide strokes and is no longer needed
void enableTouchPainting(boolean enable)
Enable/disable painting strokes by touch event.
RectF getBoundingRectF(int groupId)
Returns the minimal rectangle that contains all strokes of a StrokeGroup.
int getDisplayAlpha()
Get alpha value apply on PaintingView
int getRequestedStrokeGroupCount()
This function returns the number of requested StrokeGroups.
int[] getRequestedStrokeGroupIds()
returns the StrokeGroup Id of current requested StrokeGroups
WeakReference<Stroke> getStroke(int groupId, int strokeID)
Get a specific Stroke instance
long getStrokeGroupMemorySize(int groupId)
Get the memory footprint from specified stroke group
StrokeProperties getStrokeProperties()
Get current StrokeProperties
List<Stroke> getStrokesFromReqGroup(int groupId)
Get Strokes from Requested Stroke Group.
List<Stroke> getStrokesFromReqGroup(int groupId, boolean containIneffectiveStroke)
Get Strokes from Requested Stroke Group.
ViewPort getViewPort(int groupId)
This method returns the ViewPort of a StrokeGroup.
void init(AbsSerializeDAO serializeDAO)
This init() must called before using the HtcPaintingView.
void interceptPenEvent(boolean intercept)
This method can be used to configure whether the HtcPainting should consume the PenEvent.
boolean isEraseModeOn()
Inidicates whether erase mode is on
boolean isInitialized()
Indicates whether this HtcPaintingView has been initialized.
boolean isPainting()
Indicates whether we are in the process of creating a stroke Ex.
boolean isPaintingEnable()
true if HtcPainting is enabled
boolean isStrokeGroupClean(int groupId)
Indicates whether this stroke group has stroke or not
boolean isStrokeGroupModified(int groupId)
void onConfigurationChanged(Configuration newConfig)
void onDraw(Canvas canvas)
void onWindowFocusChanged(boolean hasWindowFocus)
void redo()
redo previous undo action
void removeOnCacheListener(HtcPaintingView.OnCacheListener list)
void removeOnPaintingViewListener(IPaintingView.OnPaintingViewListener listener)
removes a registered OnPaintingViewListener from further event callbacks.
void removeOnStrokeListener(IStrokeNotifyPaintingView.OnStrokeListener listener)
removes a registered OnStrokeListener from further event callbacks.
void requestSaveStrokeGroup(int id)
requests the HtcPaitingView to save a specified StrokeGroup.
void requestSaveStrokeGroup(int id, boolean saveIneffectiveStrokes)
requests the HtcPaitingView to save a specified StrokeGroup.
void requestSaveStrokeGroups(int[] ids, boolean saveIneffectiveStrokes)
requests the HtcPaitingView to save some specified StrokeGroups.
void requestSaveStrokeGroups(int[] ids)
requests the HtcPaitingView to save some specified StrokeGroups.
void requestSaveStrokeGroupsAsync(int[] groupIds, int key, IPaintingCallBack.IActionCallback callback, boolean saveIneffectiveStrokes)
requests the HtcPaitingView to save a specified StrokeGroup.
void requestSaveStrokeGroupsAsync(int[] groupIds, int key, IPaintingCallBack.IActionCallback callback)
requests the HtcPaitingView to save a specified StrokeGroup.
boolean[] requestStrokeGroups(int[] groupIds, ViewPort[] viewports)
This method will change current stroke groups.
void requestStrokeGroupsAsync(int[] groupIds, ViewPort[] viewports, int key, IPaintingCallBack.IActionCallback callback)
void setDisplayAlpha(int alpha)
Apply alpha value on all strokes drawing in PaintingView This could be used to temporarily adjust the display transparency of strokes
void setDocViewPort(ViewPort docViewport)
Used by Notes
void setDrawingPartialInvalidate(boolean value)
Enable/disable partial invalidate dirty rectangle when drawing stroke
void setEnabled(boolean enabled)
void setInkDrawingCacheRatio(float xRatio, float yRatio)
sets the ink drawing cache ratio of this HtcPaintingView.
void setOnCacheListener(HtcPaintingView.OnCacheListener list)
void setOnPaintingViewListener(IPaintingView.OnPaintingViewListener listener)
Register a callback to be invoked when an PaintingView event occurs.
void setOnStrokeListener(IStrokeNotifyPaintingView.OnStrokeListener listener)
Register a callback to be invoked when an Stroke event occurs.
void setPen(Pen p, StrokeProperties defaultProperties)
void setShowProcessingIndicator(boolean show)
Set whether this HtcPaintingView should show processing indicator to user.
void setStrokeProperties(StrokeProperties p)
Set as current HtcPainting StrokeProperties.
boolean setViewPortForStrokeGroup(int groupId, ViewPort viewPort)
Sets a ViewPort to a StrokeGroup
void undo()
undo previous drawing action
Protected Methods
void onDetachedFromWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)
[Expand]
Inherited Methods
From class android.widget.RelativeLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.graphics.drawable.Drawable.Callback2
From interface android.view.HtcIfViewGroup
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource
From interface com.htc.painting.engine.IPaintingView
From interface com.htc.painting.engine.IStrokeNotifyPaintingView

Constants

public static final int NO_SEPARATOR

Since: API Level 2.0

Constant Value: -1 (0xffffffff)

Fields

protected boolean mEnableEditMode

Since: API Level 2.0

protected List<IPaintingView.OnPaintingViewListener> mPaintingViewListener

Since: API Level 2.0

Public Constructors

public HtcPaintingView (Context context)

Since: API Level 2.0

same as FrameLayout's constructor

public HtcPaintingView (Context context, AttributeSet attrs)

Since: API Level 2.0

same as FrameLayout's constructor

public HtcPaintingView (Context context, AttributeSet attrs, int defStyle)

Since: API Level 2.0

same as FrameLayout's constructor

Public Methods

public boolean canRedo ()

Since: API Level 2.0

Indicates whether redo operation can be performed on this HtcPaintingView.

Returns
  • true if it is a valid redo state

public boolean canUndo ()

Since: API Level 2.0

Indicates whether undo operation can be performed on this HtcPaintingView.

Returns
  • true if it is a valid undo state

public void clearAll ()

Since: API Level 2.0

Clear all strokes from this HtcPaitingView.

public void clearStrokeGroup (int groupId)

Since: API Level 2.0

clear all strokes in a stroke group

Parameters
groupId which stroke group

public void clearStrokeGroups (int[] groupIds)

Since: API Level 2.0

clear all strokes in the specified StrokeGroups

Parameters
groupIds which stroke groups to clear

public void clearUndoRedoHistory ()

Since: API Level 2.0

clear undo/redo history. This should be called in onDestroy() but before destroyHtcPainting() is called

public void deleteStrokeGroup (int groupId)

Since: API Level 2.0

Delete aStrokeGroup from this HtcPaintingView

Parameters
groupId which stroke group

public void destroy ()

Since: API Level 2.0

This function release all resources within the HtcPainting. This should be call in onDestroy()

public boolean dispatchTouchEvent (MotionEvent event)

Since: API Level

public void drawOnBitmap (Bitmap bitmap, int groupId, int strokeId, ViewPort viewport)

Since: API Level 2.0

Draws a specific Stroke and Viewport of a specific StrokeGroup on the input bitmap.

Parameters
bitmap bitmap to be drawn
groupId the StrokeGroup id of the stroke to be drawn
strokeId the Stroke Id of the stroke to be drawn
viewport the view port of the stroke to be drawn

public void drawOnBitmap (Bitmap bitmap, int groupId, int strokeId)

Since: API Level 2.0

Draws a specific Stroke of a specific StrokeGroup on the input bitmap.

Parameters
bitmap bitmap to be drawn
groupId the StrokeGroup id of the stroke to be drawn
strokeId the Stroke Id of the stroke to be drawn

public void drawOnBitmap (Bitmap bitmap, int groupId, ViewPort viewport)

Since: API Level 2.0

Draw a specific StrokeGroups onto a bitmap with respect to the given viewport

Parameters
bitmap the bitmap to be drawn
groupId which stroke group to draw
viewport the viewport to be applied to the strokes

public void drawOnBitmap (Bitmap bitmap, int[] groupIds)

Since: API Level 2.0

Draw a specific StrokeGroups onto a bitmap

Parameters
bitmap the bitmap to be drawn
groupIds which stroke groups to draw

public void drawOnCanvas (Canvas canvas)

Since: API Level 2.0

Draw requested groups on targes canvas

Parameters
canvas target canvas

public void drawStroke (Canvas canvas, int groupId, int strokeId, int startPoint, int endPoint, ViewPort viewport)

Since: API Level 2.0

This function will draw a specific segment of a stroke on the input canvas The startPoint and endPoint together specify the segment in the Stroke to be drawn.

Parameters
canvas the canvas to draw on
groupId the StrokeGroup id of the stroke to be drawn
strokeId the stroke id of the stroke to be drawn
startPoint starting point of the segment
endPoint end point of the segment.
viewport the viewport to be applied to the strokes

public void drawStroke (Canvas canvas, int groupId, int strokeId, int startPoint, int endPoint)

Since: API Level 2.0

This function will draw a specific segment of a stroke on the input canvas The startPoint and endPoint together specify the segment in the Stroke to be drawn.

Parameters
canvas the canvas to draw on
groupId the StrokeGroup id of the stroke to be drawn
strokeId the stroke id of the stroke to be drawn
startPoint starting point of the segment
endPoint end point of the segment.

public void enableEraseMode (boolean enable)

Since: API Level 2.0

Enable/disable erase mode

Parameters
enable If true, next stroke will be an eraser. If false, next stroke will be a pen

public void enablePainting (boolean enable)

Since: API Level 2.0

enable/disable HtcPainting This function is originally designed to show/hide strokes and is no longer needed

public void enableTouchPainting (boolean enable)

Since: API Level 2.0

Enable/disable painting strokes by touch event.

Parameters
enable true to enable painting by touch event, false to disable.

public RectF getBoundingRectF (int groupId)

Since: API Level 2.0

Returns the minimal rectangle that contains all strokes of a StrokeGroup.

Parameters
groupId which stroke group
Returns
  • bounding rectangle of specified stroke group

public int getDisplayAlpha ()

Since: API Level 4.0

Get alpha value apply on PaintingView

Returns
  • the display transparency of strokes

public int getRequestedStrokeGroupCount ()

Since: API Level 2.0

This function returns the number of requested StrokeGroups.

Returns
  • number of stroke group ids that has been requested

public int[] getRequestedStrokeGroupIds ()

Since: API Level 2.0

returns the StrokeGroup Id of current requested StrokeGroups

Returns
  • current stroke groups' ids

public WeakReference<Stroke> getStroke (int groupId, int strokeID)

Since: API Level 2.0

Get a specific Stroke instance

Parameters
groupId the group Id of the desired Stroke
strokeID the Stroke Id of the desired Stroke
Returns
  • the Stroke instance of the desired Stroke

public long getStrokeGroupMemorySize (int groupId)

Since: API Level 2.0

Get the memory footprint from specified stroke group

Returns
  • memory size in bytes

public StrokeProperties getStrokeProperties ()

Since: API Level 2.0

Get current StrokeProperties

Returns
  • the currentStrokeProperties

public List<Stroke> getStrokesFromReqGroup (int groupId)

Since: API Level 2.0

Get Strokes from Requested Stroke Group. Only effective stroke will be included.

public List<Stroke> getStrokesFromReqGroup (int groupId, boolean containIneffectiveStroke)

Since: API Level 2.0

Get Strokes from Requested Stroke Group.

Parameters
containIneffectiveStroke true: Include Ineffective strokes

public ViewPort getViewPort (int groupId)

Since: API Level 2.0

This method returns the ViewPort of a StrokeGroup.

Parameters
groupId which stroke group
Returns
  • the AbsHtcPaintingViewPort of the specified StrokeGroup; null if such ViewPort cannot be found.

public void init (AbsSerializeDAO serializeDAO)

Since: API Level 2.0

This init() must called before using the HtcPaintingView. It will create HtcPainting and set up HtcPainting default settings.

Parameters
serializeDAO The DAO callback used load/save/delete strokes

public void interceptPenEvent (boolean intercept)

Since: API Level 2.0

This method can be used to configure whether the HtcPainting should consume the PenEvent.

Parameters
intercept the HtcPaintingView will consume the PenEvent if this value is set to true and will not consume the PenEvent if the value is set to false.

public boolean isEraseModeOn ()

Since: API Level 2.0

Inidicates whether erase mode is on

Returns
  • true if next stroke is an eraser

public boolean isInitialized ()

Since: API Level 2.0

Indicates whether this HtcPaintingView has been initialized.

Returns
  • true if this HtcPaintingView has been initialized, and false otherwise

public boolean isPainting ()

Since: API Level 2.0

Indicates whether we are in the process of creating a stroke Ex. between pen down and up

Returns
  • true if painting view is in the process of creating a stroke, false otherwise

public boolean isPaintingEnable ()

Since: API Level 2.0

true if HtcPainting is enabled

Returns
  • true if HtcPainting is enabled

public boolean isStrokeGroupClean (int groupId)

Since: API Level 2.0

Indicates whether this stroke group has stroke or not

Parameters
groupId which stroke group
Returns
  • true if it has no strokes

public boolean isStrokeGroupModified (int groupId)

Since: API Level 2.0

public void onConfigurationChanged (Configuration newConfig)

Since: API Level 2.0

public void onDraw (Canvas canvas)

Since: API Level 2.0

public void onWindowFocusChanged (boolean hasWindowFocus)

Since: API Level

public void redo ()

Since: API Level 2.0

redo previous undo action

public void removeOnCacheListener (HtcPaintingView.OnCacheListener list)

Since: API Level 2.0

public void removeOnPaintingViewListener (IPaintingView.OnPaintingViewListener listener)

Since: API Level 2.0

removes a registered OnPaintingViewListener from further event callbacks.

Parameters
listener the callback to be removed

public void removeOnStrokeListener (IStrokeNotifyPaintingView.OnStrokeListener listener)

Since: API Level 2.0

removes a registered OnStrokeListener from further event callbacks.

Parameters
listener the callback to be removed

public void requestSaveStrokeGroup (int id)

Since: API Level 2.0

requests the HtcPaitingView to save a specified StrokeGroup. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

Parameters
id the StrokeGroup id of that StrokeGroup that is to be saved

public void requestSaveStrokeGroup (int id, boolean saveIneffectiveStrokes)

Since: API Level 2.0

requests the HtcPaitingView to save a specified StrokeGroup. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

Parameters
id the StrokeGroup id of that StrokeGroup that is to be saved

public void requestSaveStrokeGroups (int[] ids, boolean saveIneffectiveStrokes)

Since: API Level 2.0

requests the HtcPaitingView to save some specified StrokeGroups. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

Parameters
ids the StrokeGroup id of that StrokeGroups that are to be saved
saveIneffectiveStrokes StrokeEventArg.StrokeStatus

public void requestSaveStrokeGroups (int[] ids)

Since: API Level 2.0

requests the HtcPaitingView to save some specified StrokeGroups. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

Parameters
ids the StrokeGroup id of that StrokeGroups that are to be saved

public void requestSaveStrokeGroupsAsync (int[] groupIds, int key, IPaintingCallBack.IActionCallback callback, boolean saveIneffectiveStrokes)

Since: API Level 2.0

requests the HtcPaitingView to save a specified StrokeGroup. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

public void requestSaveStrokeGroupsAsync (int[] groupIds, int key, IPaintingCallBack.IActionCallback callback)

Since: API Level 2.0

requests the HtcPaitingView to save a specified StrokeGroup. When upon saving the StrokeGroup, the designated AbsSerializeDAO.save will be called to perform the actual saving.

public boolean[] requestStrokeGroups (int[] groupIds, ViewPort[] viewports)

Since: API Level 2.0

This method will change current stroke groups. If the specified stroke groups are not in memory, painting framework will request them by serializeDAO. If serializeDAO returns null, it will create empty new stroke groups with specified stroke group ids.

Parameters
groupIds which stroke groups
Returns
  • true(s) if success

public void requestStrokeGroupsAsync (int[] groupIds, ViewPort[] viewports, int key, IPaintingCallBack.IActionCallback callback)

Since: API Level 2.0

Parameters
groupIds which stroke group
key action key
callback callback when operation completed

public void setDisplayAlpha (int alpha)

Since: API Level 2.0

Apply alpha value on all strokes drawing in PaintingView This could be used to temporarily adjust the display transparency of strokes

public void setDocViewPort (ViewPort docViewport)

Since: API Level

Used by Notes

public void setDrawingPartialInvalidate (boolean value)

Since: API Level 2.0

Enable/disable partial invalidate dirty rectangle when drawing stroke

Parameters
value if true, only invalidate the rectangle that stroke do partial render. if false, invalidate stroke's bounding rectangle.

public void setEnabled (boolean enabled)

Since: API Level

public void setInkDrawingCacheRatio (float xRatio, float yRatio)

Since: API Level 2.0

sets the ink drawing cache ratio of this HtcPaintingView. Note that the ratio must be greater or equal to 1.0f

Parameters
xRatio ink cache size to display size ratio in x-axis
yRatio ink cache size to display size ratio in y-axis

public void setOnCacheListener (HtcPaintingView.OnCacheListener list)

Since: API Level 2.0

public void setOnPaintingViewListener (IPaintingView.OnPaintingViewListener listener)

Since: API Level 2.0

Register a callback to be invoked when an PaintingView event occurs.

Parameters
listener the callback to be run on

public void setOnStrokeListener (IStrokeNotifyPaintingView.OnStrokeListener listener)

Since: API Level 2.0

Register a callback to be invoked when an Stroke event occurs.

Parameters
listener the callback to be run on

public void setPen (Pen p, StrokeProperties defaultProperties)

Since: API Level 2.0

public void setShowProcessingIndicator (boolean show)

Since: API Level 2.0

Set whether this HtcPaintingView should show processing indicator to user. If set to true, the HtcPaintingView will show indicator when performing loading process. The default value is set to true.

Parameters
show true to show indicator

public void setStrokeProperties (StrokeProperties p)

Since: API Level 2.0

Set as current HtcPainting StrokeProperties. These properties will determine how the pen stroke is drawn.

Parameters
p the StrokeProperties to be used when drawing a stroke

public boolean setViewPortForStrokeGroup (int groupId, ViewPort viewPort)

Since: API Level 2.0

Sets a ViewPort to a StrokeGroup

Parameters
groupId which stroke group
viewPort the view port assigned to the stroke group
Returns
  • true if the operation was done successfully; false otherwise.

public void undo ()

Since: API Level 2.0

undo previous drawing action

Protected Methods

protected void onDetachedFromWindow ()

Since: API Level

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

Since: API Level