public class SpenPaintingSurfaceView extends SurfaceView implements SpenPaintingViewInterface
SpenSettingViewPenInterface.SpenBackgroundColorChangeListenerREPLAY_STATE_ON_COMPLETE, REPLAY_STATE_PAUSED, REPLAY_STATE_PLAYING, REPLAY_STATE_STOPPEDACTION_COLOR_PICKER, ACTION_ERASER, ACTION_GESTURE, ACTION_NONE, ACTION_RECOGNITION, ACTION_SELECTION, ACTION_STROKE, ACTION_STROKE_REMOVER, ACTION_TEXT, TOOL_ERASER, TOOL_FINGER, TOOL_MOUSE, TOOL_MULTI_TOUCH, TOOL_PEN_BUTTON, TOOL_SPEN, TOOL_UNKNOWN| Constructor and Description |
|---|
SpenPaintingSurfaceView(Context context)
Creates an SpenPaintingSurfaceView instance.
|
SpenPaintingSurfaceView(Context context,
AttributeSet attrs)
Creates an SpenPaintingSurfaceView instance with the specified XML attributes.
|
SpenPaintingSurfaceView(Context context,
AttributeSet attrs,
int defStyleAttr)
Creates an SpenPaintingSurfaceView instance with the specified XML attributes and a class-specific default
style.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelStroke()
Cancel the drawing stroke.
|
Bitmap |
captureCurrentView(boolean includeBlank)
Get the bitmap of the current view.
|
Bitmap |
captureRect(RectF rect)
Get the bitmap of the specified area.
|
void |
close()
Close the canvas view.
|
int |
getBlankColor()
Get the blank color.
|
int |
getCanvasHeight()
Get the current canvas width.
|
int |
getCanvasWidth()
Get the current canvas height.
|
SpenSettingEraserInfo |
getEraserSettingInfo()
Get the eraser settings information.
|
float |
getMaxZoomRatio()
Get the maximum zoom ratio of the view.
|
float |
getMinZoomRatio()
Get the minimum zoom ratio of the view.
|
PointF |
getPan()
Get the current pan position.
|
SpenSettingPenInfo |
getPenSettingInfo()
Get the Pen settings information.
|
int |
getToolTypeAction(int toolType)
Get the action of the specified tool type.
|
float |
getZoomRatio()
Get the zoom ratio of the view.
|
boolean |
isHorizontalSmartScrollEnabled()
Gets smart horizontal scroll use or not
|
boolean |
isToolTipEnabled()
Check if tool tips are enabled.
|
boolean |
isVerticalSmartScrollEnabled()
Gets smart vertical scroll use or not
|
boolean |
isZoomable()
Check if zoom mode is enabled for the view.
|
protected void |
onAttachedToWindow() |
boolean |
onHoverEvent(MotionEvent event)
Called when a hover event occurs.
|
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom) |
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh) |
boolean |
onTouchEvent(MotionEvent event)
Called when a touch event is dispatched to a view.
|
protected void |
onWindowVisibilityChanged(int visibility) |
void |
setBackgroundColorChangeListener(Object object,
SpenSettingViewPenInterface.SpenBackgroundColorChangeListener listener)
Sets the background color changed event listener.
|
void |
setBlankColor(int color)
Set the specified blank color.
|
void |
setColorPickerListener(SpenColorPickerListener listener)
Sets the specified SpenColorPickerListener instance to receive color picker events.
|
void |
setEraserChangeListener(SpenEraserChangeListener listener)
Sets the eraser change event listener
|
void |
setEraserSettingInfo(SpenSettingEraserInfo info)
Set the specified eraser settings information.
|
void |
setHorizontalSmartScrollEnabled(boolean enable,
Rect leftScrollRegion,
Rect rightScrollRegion,
int responseTime,
int velocity)
Sets smart horizontal scroll use or not
|
void |
setLongPressListener(SpenLongPressListener listener)
Sets the long press listener for LongPressListener.
|
boolean |
setMaxZoomRatio(float ratio)
Set the specified maximum zoom ratio of the view.
|
boolean |
setMinZoomRatio(float ratio)
Set the specified minimum zoom ratio of the view.
|
void |
setMouseWheelZoomEnabled(boolean wheelZoomEnabled)
Enable or disable the zoom with mouse wheel.
|
boolean |
setPaintingDoc(SpenPaintingDoc paintingDoc,
boolean isUpdate)
Set the specified PaintingDoc instance to the current view.
|
void |
setPan(PointF position)
Set the specified pan position and move to the position in the view.
|
void |
setPenChangeListener(SpenPenChangeListener listener)
Set the specified SpenPenChangeListener instance to receive Pen settings events.
|
void |
setPenDetachmentListener(SpenPenDetachmentListener listener)
Sets the pen detachement listener.
|
void |
setPenSettingInfo(SpenSettingPenInfo info)
Set the specified Pen settings information for the specified user.
|
void |
setPreTouchListener(SpenTouchListener listener)
Set the specified SpenTouchListener instance to receive pre-touch events.
|
void |
setToolTipEnabled(boolean enable)
Enable or disable tool tips.
|
void |
setToolTypeAction(int toolType,
int action)
Set the specified action for the specified tool type.
|
void |
setTouchListener(SpenTouchListener listener)
Set the specified SpenTouchListener instance to receive touch events.
|
void |
setVerticalSmartScrollEnabled(boolean enable,
Rect topScrollRegion,
Rect bottomScrollRegion,
int responseTime,
int velocity)
Sets smart vertical scroll use or not
|
void |
setZoom(float centerX,
float centerY,
float ratio)
Set the specified zoom ratio of the view.
|
void |
setZoomable(boolean enable)
Enable or disable the zoom mode of the view.
|
void |
setZoomListener(SpenZoomListener listener)
Sets the zoom event listener.
|
void |
update()
Update the canvas.
|
void |
updateRedo(SpenPaintingDoc.HistoryUpdateInfo[] userDataList)
Update the screen after executing the redo command.
|
void |
updateUndo(SpenPaintingDoc.HistoryUpdateInfo[] userDataList)
Update the screen after executing the undo command.
|
public SpenPaintingSurfaceView(Context context)
context - The Context for your application. The context should not be nullNullPointerException - Thrown if the context is set null.SpenPaintingSurfaceView(Context, AttributeSet),
SpenPaintingSurfaceView(Context, AttributeSet, int)public SpenPaintingSurfaceView(Context context, AttributeSet attrs)
context - The Context for your application. The context should not be nullattrs - The XML attributes for the view.NullPointerException - Thrown if the context is set null.SpenPaintingSurfaceView(Context),
SpenPaintingSurfaceView(Context, AttributeSet, int)public SpenPaintingSurfaceView(Context context, AttributeSet attrs, int defStyleAttr)
context - The Context for your application. The context should not be nullattrs - The XML attributes for the view.defStyleAttr - The default style to apply to this view.
Set to 0 to apply no style beyond what is included in the theme.
This can be an attribute resource value retrieved from the current theme or an explicit style
resource.NullPointerException - Thrown if the context is set null.SpenPaintingSurfaceView(Context),
SpenPaintingSurfaceView(Context, AttributeSet)public void close()
close in interface SpenPaintingViewInterfacepublic void setPenSettingInfo(SpenSettingPenInfo info)
getPenSettingInfo()setPenSettingInfo in interface SpenSettingViewPenInterfaceinfo - The Pen settings information object.SpenSettingPenInfopublic SpenSettingPenInfo getPenSettingInfo()
getPenSettingInfo in interface SpenSettingViewPenInterfaceSpenSettingPenInfopublic void setToolTypeAction(int toolType,
int action)
SpenSettingViewInterfacesetToolTypeAction in interface SpenSettingViewInterfacetoolType - toolType of motion event SpenSettingViewInterface.TOOL_UNKNOWN, SpenSettingViewInterface.TOOL_FINGER, SpenSettingViewInterface.TOOL_SPEN,
SpenSettingViewInterface.TOOL_MOUSE, SpenSettingViewInterface.TOOL_ERASERaction - action of tool SpenSettingViewInterface.ACTION_NONE, SpenSettingViewInterface.ACTION_GESTURE, SpenSettingViewInterface.ACTION_STROKE,
SpenSettingViewInterface.ACTION_ERASER, SpenSettingViewInterface.ACTION_STROKE_REMOVER, SpenSettingViewInterface.ACTION_COLOR_PICKER,
SpenSettingViewInterface.ACTION_SELECTIONpublic int getToolTypeAction(int toolType)
SpenSettingViewInterfacegetToolTypeAction in interface SpenSettingViewInterfacetoolType - toolType of motion event SpenSettingViewInterface.TOOL_UNKNOWN, SpenSettingViewInterface.TOOL_FINGER, SpenSettingViewInterface.TOOL_SPEN,
SpenSettingViewInterface.TOOL_MOUSE, SpenSettingViewInterface.TOOL_ERASERSpenSettingViewInterface.ACTION_NONE, SpenSettingViewInterface.ACTION_GESTURE, SpenSettingViewInterface.ACTION_STROKE,
SpenSettingViewInterface.ACTION_ERASER, SpenSettingViewInterface.ACTION_STROKE_REMOVER, SpenSettingViewInterface.ACTION_COLOR_PICKER,
SpenSettingViewInterface.ACTION_SELECTIONpublic int getCanvasWidth()
SpenSettingViewInterfacegetCanvasWidth in interface SpenSettingViewInterfacepublic int getCanvasHeight()
SpenSettingViewInterfacegetCanvasHeight in interface SpenSettingViewInterfacepublic void setBackgroundColorChangeListener(Object object, SpenSettingViewPenInterface.SpenBackgroundColorChangeListener listener)
SpenSettingViewPenInterfacesetBackgroundColorChangeListener in interface SpenSettingViewPenInterfaceobject - Object layout which changed background color.listener - The callback listener for Changed BackgroundColorpublic boolean setPaintingDoc(SpenPaintingDoc paintingDoc, boolean isUpdate)
setPaintingDoc in interface SpenPaintingViewInterfacepaintingDoc - The PaintingDoc instance that you want to set.isUpdate - Set to true to update the screen, set to false to not update the screen.OutOfMemoryError - Thrown if there is insufficient memory available.public void setZoomable(boolean enable)
setZoomable in interface SpenPaintingViewInterfaceenable - Set to true to enable the zoom mode, set to false to disable the zoom mode.public boolean isZoomable()
isZoomable in interface SpenPaintingViewInterfacepublic void setZoom(float centerX,
float centerY,
float ratio)
setZoom in interface SpenPaintingViewInterfacecenterX - The X coordinate in pixels for the center.centerY - The Y coordinate in pixels for the center.ratio - The zoom ratio.public float getZoomRatio()
getZoomRatio in interface SpenPaintingViewInterfacepublic boolean setMaxZoomRatio(float ratio)
setMaxZoomRatio in interface SpenPaintingViewInterfaceratio - The maximum zoom ratio.public float getMaxZoomRatio()
getMaxZoomRatio in interface SpenPaintingViewInterfacepublic boolean setMinZoomRatio(float ratio)
setMinZoomRatio in interface SpenPaintingViewInterfaceratio - The minimum zoom ratio.public float getMinZoomRatio()
getMinZoomRatio in interface SpenPaintingViewInterfacepublic void setPan(PointF position)
setPan in interface SpenPaintingViewInterfaceposition - The pan position.NullPointerException - If position is set nullpublic PointF getPan()
getPan in interface SpenPaintingViewInterfacepublic void setBlankColor(int color)
setBlankColor in interface SpenPaintingViewInterfacecolor - The blank color.public int getBlankColor()
getBlankColor in interface SpenPaintingViewInterfacepublic void setPenChangeListener(SpenPenChangeListener listener)
setPenChangeListener in interface SpenPaintingViewInterfacelistener - The SpenPenChangeListener instance to receive Pen settings events.public boolean onTouchEvent(MotionEvent event)
onTouchEvent in class Viewevent - The MotionEvent instance that contains the event information.public boolean onHoverEvent(MotionEvent event)
onHoverEvent in class Viewevent - The MotionEvent instance that contains the event information.protected void onLayout(boolean changed,
int left,
int top,
int right,
int bottom)
protected void onSizeChanged(int w,
int h,
int oldw,
int oldh)
onSizeChanged in class Viewprotected void onAttachedToWindow()
onAttachedToWindow in class SurfaceViewpublic void update()
update in interface SpenPaintingViewInterfacepublic void updateUndo(SpenPaintingDoc.HistoryUpdateInfo[] userDataList)
updateUndo in interface SpenPaintingViewInterfaceuserDataList - The data list for the previous state.public void updateRedo(SpenPaintingDoc.HistoryUpdateInfo[] userDataList)
updateRedo in interface SpenPaintingViewInterfaceuserDataList - The data list for the previous state.public void setPreTouchListener(SpenTouchListener listener)
setPreTouchListener in interface SpenPaintingViewInterfacelistener - The SpenTouchListener instance to receive pre-touch events.public void setTouchListener(SpenTouchListener listener)
setTouchListener in interface SpenPaintingViewInterfacelistener - The SpenTouchListener instance to receive touch events.public Bitmap captureCurrentView(boolean includeBlank)
captureCurrentView in interface SpenPaintingViewInterfaceincludeBlank - Set to true to include a blank in the captured bitmap, set to false to capture only the screen without
the blank.OutOfMemoryError - Thrown if device run out of memorypublic void setToolTipEnabled(boolean enable)
setToolTipEnabled in interface SpenPaintingViewInterfaceenable - Set to true to enable tool tips, set to false to disable tool tips.public boolean isToolTipEnabled()
isToolTipEnabled in interface SpenPaintingViewInterfacepublic void cancelStroke()
cancelStroke in interface SpenPaintingViewInterfacepublic void setLongPressListener(SpenLongPressListener listener)
setLongPressListener in interface SpenPaintingViewInterfacelistener - The callback listener for LongPressListenerpublic void setZoomListener(SpenZoomListener listener)
setZoomListener in interface SpenPaintingViewInterfacelistener - The callback listener for zoom eventpublic void setPenDetachmentListener(SpenPenDetachmentListener listener)
setPenDetachmentListener in interface SpenPaintingViewInterfacelistener - The callback listener for pen detachement listenerpublic void setEraserSettingInfo(SpenSettingEraserInfo info)
setEraserSettingInfo in interface SpenSettingViewEraserInterfaceinfo - The eraser settings information object.SpenSettingEraserInfopublic SpenSettingEraserInfo getEraserSettingInfo()
getEraserSettingInfo in interface SpenSettingViewEraserInterfaceSpenSettingEraserInfopublic void setEraserChangeListener(SpenEraserChangeListener listener)
listener - The callback listener for eraser datapublic Bitmap captureRect(RectF rect)
captureRect in interface SpenPaintingViewInterfacerect - The area to capture.OutOfMemoryError - thrown if not enough memory to create captured .public void setColorPickerListener(SpenColorPickerListener listener)
setColorPickerListener in interface SpenPaintingViewInterfacelistener - The SpenColorPickerListener instance to receive color picker events.public void setHorizontalSmartScrollEnabled(boolean enable,
Rect leftScrollRegion,
Rect rightScrollRegion,
int responseTime,
int velocity)
setHorizontalSmartScrollEnabled in interface SpenPaintingViewInterfaceenable - true is use smart horizontal scroll, false is not use smart
horizontal scroll.leftScrollRegion - left smart scroll operating resionrightScrollRegion - right smart scroll operating resionresponseTime - scroll activity after time after hover entervelocity - scroll velocity (pixel)public boolean isHorizontalSmartScrollEnabled()
isHorizontalSmartScrollEnabled in interface SpenPaintingViewInterfacepublic void setVerticalSmartScrollEnabled(boolean enable,
Rect topScrollRegion,
Rect bottomScrollRegion,
int responseTime,
int velocity)
setVerticalSmartScrollEnabled in interface SpenPaintingViewInterfaceenable - true is use smart vertical scroll, false is not use smart
svertical scroll.topScrollRegion - top smart scroll operating resionbottomScrollRegion - bottom smart scroll operating resionresponseTime - scroll activity after time after hover entervelocity - scroll velocity (pixel)public boolean isVerticalSmartScrollEnabled()
isVerticalSmartScrollEnabled in interface SpenPaintingViewInterfacepublic void setMouseWheelZoomEnabled(boolean wheelZoomEnabled)
setMouseWheelZoomEnabled in interface SpenPaintingViewInterfacewheelZoomEnabled - Set to true to enable the zoom with mouse wheel, set to false to disable the zoom with mouse wheel.protected void onWindowVisibilityChanged(int visibility)
onWindowVisibilityChanged in class SurfaceView