public static interface

PDFViewCtrl.ToolManager

com.pdftron.pdf.PDFViewCtrl.ToolManager
Known Indirect Subclasses

Class Overview

Tool manager interface that is used for creating tools. PDFViewCtrl uses this interface to interact with user-defined functional modules.

Note also that if the implementation of onMove(android.view.MotionEvent, android.view.MotionEvent, float, float) returns true, the subsequent code of #onScroll(android.view.MotionEvent, android.view.MotionEvent, float, float) won't be executed, preventing the view from being scrolled.

Summary

Public Methods
abstract boolean isCreatingAnnotation()
abstract void onAnnotPainterUpdated(int page, long which, CurvePainter painter)
Called when annotation CurvePainter has been updated.
abstract void onChangePointerIcon(PointerIcon pointerIcon)
The implementation should change the pointer icon.
abstract void onClose()
Called by PDFViewCtrl to indicate the tool is being closed, e.g., when the current document is being closed.
abstract void onConfigurationChanged(Configuration newConfig)
Called when configuration is changed.
abstract void onControlReady()
Called by PDFViewCtrl to indicate that the control is ready to be used by the ToolManager.
abstract void onCustomEvent(Object obj)
Called by PDFViewCtrl in the next message loop of the main thread.
abstract void onDestroy()
Called when destroy() is called.
abstract void onDocumentDownloadEvent(PDFViewCtrl.DownloadState state, int page_num, int page_downloaded, int page_count, String message)
Called when an update from document downloading is available, which can be started by openUrlAsync(String, String, String, HTTPRequestOptions)
abstract boolean onDoubleTap(MotionEvent e)
Called at the beginning when double tap event is triggered.
abstract void onDoubleTapEnd(MotionEvent e)
Called at the end when onDoubleTap(android.view.MotionEvent) is triggered.
abstract boolean onDoubleTapEvent(MotionEvent e)
abstract void onDoubleTapZoomAnimationBegin()
abstract void onDoubleTapZoomAnimationEnd()
abstract boolean onDown(MotionEvent e)
Called when down event is triggered.
abstract void onDraw(Canvas canvas, Matrix tfm)
Called by PDFViewCtrl to draw tool's content, if there is any.
abstract boolean onDrawEdgeEffects(Canvas canvas, int width, int verticalOffset)
Called when edge effect is drawn in onDraw.
abstract boolean onFlingStop()
Called when a fling motion stops by itself (not by a touching event).
abstract boolean onGenericMotionEvent(MotionEvent e)
called when generic motion event is called
abstract boolean onKeyUp(int keyCode, KeyEvent event)
Called when a key is released
abstract void onLayout(boolean changed, int l, int t, int r, int b)
Called when PDFViewCtrl's onLayout(), e.g., android.view.View.onLayout(), is triggered, or PDFViewCtrl's page presentation mode or page view mode is changed by setPagePresentationMode(PagePresentationMode) or setPageViewMode(PageViewMode).
abstract boolean onLongPress(MotionEvent e)
Called when long press event is triggered.
abstract boolean onMove(MotionEvent e1, MotionEvent e2, float x_dist, float y_dist)
Called when #onScroll(android.view.MotionEvent, android.view.MotionEvent, float, float) is triggered.
abstract void onPageTurning(int old_page, int cur_page)
Called when turning pages in non-continuous page presentation mode.
abstract void onPause()
Called when pause() is called.
abstract boolean onPointerDown(MotionEvent e)
Called when non-primary pointer down event is triggered.
abstract void onPostSingleTapConfirmed()
Called about 200ms after onSingleTapConfirmed(android.view.MotionEvent) is called.
abstract void onPullEdgeEffects(int which_edge, float delta_distance)
Called when edge effect should occur.
abstract void onReleaseEdgeEffects()
Called when edge effect is released in onUp.
abstract void onRenderingFinished()
abstract void onResume()
Called when resume() is called.
abstract boolean onScale(float x, float y)
Called when #onScale(android.view.ScaleGestureDetector) is triggered.
abstract boolean onScaleBegin(float x, float y)
Called when #onScaleBegin(android.view.ScaleGestureDetector) is triggered.
abstract boolean onScaleEnd(float x, float y)
Called when #onScaleEnd(android.view.ScaleGestureDetector) is triggered.
abstract void onScrollChanged(int l, int t, int oldl, int oldt)
Called in response to an internal scroll in PDFViewCtrl.
abstract void onSetDoc()
Called by PDFViewCtrl after {link setDoc(PDFDoc) is called and the document is set within PDFViewCtrl.
abstract boolean onShowPress(MotionEvent e)
Called when show press event is triggered.
abstract boolean onSingleTapConfirmed(MotionEvent e)
Called when single tap confirmed event is triggered.
abstract boolean onSingleTapUp(MotionEvent e)
Called when single tap up event is triggered.
abstract boolean onUp(MotionEvent e, PDFViewCtrl.PriorEventMode priorEventMode)
Called when up event is triggered.

Public Methods

public abstract boolean isCreatingAnnotation ()

Returns
  • true if tool is creating a new annotation; otherwise false

public abstract void onAnnotPainterUpdated (int page, long which, CurvePainter painter)

Called when annotation CurvePainter has been updated. Called from background thread.

Parameters
page the page number
which the annotation key

public abstract void onChangePointerIcon (PointerIcon pointerIcon)

The implementation should change the pointer icon.

Parameters
pointerIcon The pointer icon

public abstract void onClose ()

Called by PDFViewCtrl to indicate the tool is being closed, e.g., when the current document is being closed. Tool should clean up at this moment, e.g., closing its menu.

public abstract void onConfigurationChanged (Configuration newConfig)

Called when configuration is changed. This event can be used to perform some action when the device's configuration changes.

Parameters
newConfig the new device configuration

public abstract void onControlReady ()

Called by PDFViewCtrl to indicate that the control is ready to be used by the ToolManager. This event is triggered after the layout phase is complete, making it safe to use the other events. Note this is also called every time a new doc is set in PDFViewCtrl.

public abstract void onCustomEvent (Object obj)

Called by PDFViewCtrl in the next message loop of the main thread. This callback can be registered through postCustomEvent(Object) method. Note that this function is called only once per posting.

Parameters
obj the Object passed in when calling postCustomEvent(Object).

public abstract void onDestroy ()

Called when destroy() is called.

public abstract void onDocumentDownloadEvent (PDFViewCtrl.DownloadState state, int page_num, int page_downloaded, int page_count, String message)

Called when an update from document downloading is available, which can be started by openUrlAsync(String, String, String, HTTPRequestOptions)

Parameters
state the state of the update.
page_num the number of the page that was just downloaded. Meaningful if type is PAGE.
page_downloaded the total number of pages that have been downloaded
page_count the page count of the associated document
message error message in case the download has failed

public abstract boolean onDoubleTap (MotionEvent e)

Called at the beginning when double tap event is triggered.

Note: By default, PDFViewCtrl changes the zoom when double tapping. But since Tool.onDoubleTap() is called before the zoom is changed, calling getZoom() in this callback would return the old zoom factor.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract void onDoubleTapEnd (MotionEvent e)

Called at the end when onDoubleTap(android.view.MotionEvent) is triggered.

Note: By default, PDFViewCtrl changes the zoom when double tapping. Since Tool.onDoubleTapEnd() is called after the zoom is changed, calling getZoom() in this callback would return the new zoom factor.

public abstract boolean onDoubleTapEvent (MotionEvent e)

public abstract void onDoubleTapZoomAnimationBegin ()

public abstract void onDoubleTapZoomAnimationEnd ()

public abstract boolean onDown (MotionEvent e)

Called when down event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract void onDraw (Canvas canvas, Matrix tfm)

Called by PDFViewCtrl to draw tool's content, if there is any. Note that this is called after all the document content is drawn; therefore the content drawn in this function will be on top of the document content.

Parameters
canvas The android.graphics.Canvas object to draw on PDFViewCtrl.
tfm The extra transformation matrix applied to 'canvas'. This matrix is normally an identity matrix unless when the built-in page sliding is in process. The inverse of this matrix can be temporarily applied to 'canvas' in order to make the content drawn in this function appear stationary during sliding.

public abstract boolean onDrawEdgeEffects (Canvas canvas, int width, int verticalOffset)

Called when edge effect is drawn in onDraw.

Parameters
canvas canvas used to draw edge effect
width width of the edge effect
verticalOffset vertical offset to draw edge effect
Returns
  • whether the viewer should be invalidated

public abstract boolean onFlingStop ()

Called when a fling motion stops by itself (not by a touching event).

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onGenericMotionEvent (MotionEvent e)

called when generic motion event is called

Parameters
e the up motion event
Returns
  • true if the event was handled, false otherwise.

public abstract boolean onKeyUp (int keyCode, KeyEvent event)

Called when a key is released

Parameters
keyCode A key code that represents the button pressed, from android.view.KeyEvent.
event The KeyEvent object that defines the button action.
Returns
  • true if the event was handled, false otherwise.

public abstract void onLayout (boolean changed, int l, int t, int r, int b)

Called when PDFViewCtrl's onLayout(), e.g., android.view.View.onLayout(), is triggered, or PDFViewCtrl's page presentation mode or page view mode is changed by setPagePresentationMode(PagePresentationMode) or setPageViewMode(PageViewMode).

Parameters
changed This is a new size or position for this view.
l Left position, relative to parent.
t Top position, relative to parent.
r Right position, relative to parent.
b Bottom position, relative to parent.

public abstract boolean onLongPress (MotionEvent e)

Called when long press event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onMove (MotionEvent e1, MotionEvent e2, float x_dist, float y_dist)

Called when #onScroll(android.view.MotionEvent, android.view.MotionEvent, float, float) is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, true should be returned so that while the tool is moving, the content will not be scrolled.

public abstract void onPageTurning (int old_page, int cur_page)

Called when turning pages in non-continuous page presentation mode.

Note: Note that the event will be fired when the page is already turned, and not while it is being 'turned'.

public abstract void onPause ()

Called when pause() is called.

public abstract boolean onPointerDown (MotionEvent e)

Called when non-primary pointer down event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract void onPostSingleTapConfirmed ()

Called about 200ms after onSingleTapConfirmed(android.view.MotionEvent) is called.

Since onSingleTapConfirmed() event is typically the last event, it is difficult for a tool to trigger post behaviors if the tool is only initiated in onSingleTapConfirmed(). Therefore, PDFViewCtrl implements this callback function after onSingleTapConfirmed() is called to provide the tool a chance to implement post behaviors. For example, if a user clicks on a link, the tool could highlight the link in onSingleTapConfirmed() and then navigate to the link in onPostSingleTapConfirmed().

Note: If a new event is triggered by a user after onSingleTapConfirmed() is called but before onPostSingleTapConfirmed() is called, PDFViewCtrl ensures onPostSingleTapConfirmed() is called immediately before the new event. In other words, the 200ms delay is ignored.

public abstract void onPullEdgeEffects (int which_edge, float delta_distance)

Called when edge effect should occur.

Parameters
which_edge -1 for left edge, 1 for right edge
delta_distance distance of edge effect

public abstract void onReleaseEdgeEffects ()

Called when edge effect is released in onUp.

public abstract void onRenderingFinished ()

public abstract void onResume ()

Called when resume() is called.

public abstract boolean onScale (float x, float y)

Called when #onScale(android.view.ScaleGestureDetector) is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onScaleBegin (float x, float y)

Called when #onScaleBegin(android.view.ScaleGestureDetector) is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onScaleEnd (float x, float y)

Called when #onScaleEnd(android.view.ScaleGestureDetector) is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract void onScrollChanged (int l, int t, int oldl, int oldt)

Called in response to an internal scroll in PDFViewCtrl. This can be used to detect PDFViewCtrl is scrolling after a fling, for example.

Parameters
l current horizontal scroll origin
t current vertical scroll origin
oldl previous horizontal scroll origin
oldt previous vertical scroll origin

public abstract void onSetDoc ()

Called by PDFViewCtrl after {link setDoc(PDFDoc) is called and the document is set within PDFViewCtrl.

public abstract boolean onShowPress (MotionEvent e)

Called when show press event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onSingleTapConfirmed (MotionEvent e)

Called when single tap confirmed event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onSingleTapUp (MotionEvent e)

Called when single tap up event is triggered.

Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.

public abstract boolean onUp (MotionEvent e, PDFViewCtrl.PriorEventMode priorEventMode)

Called when up event is triggered.

Parameters
e the up motion event
priorEventMode indicates the prior event type.
Returns
  • true if the event is swallowed by the tool. This way, PDFViewCtrl will not perform its usual task associated with this event. In general, false should be returned.