public class

FreehandCreate

extends SimpleShapeCreate
java.lang.Object
   ↳ com.pdftron.pdf.tools.Tool
     ↳ com.pdftron.pdf.tools.BaseTool
       ↳ com.pdftron.pdf.tools.SimpleShapeCreate
         ↳ com.pdftron.pdf.tools.FreehandCreate
Known Direct Subclasses

Class Overview

This class is for creating a free hand annotation.

If mMultiStrokeMode is true, then each subsequent stroke will be added to the same annot.

If mTimedModeEnabled is true, then the strokes will be committed to the annot on a timer basis. This flag is only under effect if mMultiStrokeMode is true.

If mIsFromEditToolbar is true, then mMultiStrokeMode must be false and mTimedModeEnabled must be false.

# Test cases:

## Stylus as Pen: ### Invariants mTimedModeEnabled can be true or false mMultiStrokeMode can be true or false mIsEditingAnnot must be false ### Tests 1. mTimedModeEnabled = true and mMultiStrokeMode = true. A new annot should not be created each stroke, and strokes should be saved every 3 seconds. 2. mMultiStrokeMode = false. A new annot will be created after every stroke.

## Ink tool from toolbar: ### Invariants mTimedModeEnabled can be true or false mMultiStrokeMode can be true or false mIsEditingAnnot must be false ### Tests 1. mTimedModeEnabled = true and mMultiStrokeMode = true. A new annot should not be created each stroke, and strokes should be saved every 30 seconds. 2. mMultiStrokeMode = false. A new annot will be created after every stroke.

## Ink tool from quick menu: ### Invariants mTimedModeEnabled can be true or false mMultiStrokeMode must be true mIsEditingAnnot must be false 1. mTimedModeEnabled = true and mMultiStrokeMode = true. A new annot should not be created each stroke, and strokes should be saved every 30 seconds.

## Draw with finger setting

### 1. Draw with finger setting enabled: i. Enable stylus as pen setting and **enable** draw with finger setting. ii. Open a document and select the ink tool. iii. When you draw with the finger first, ink should be created. However once you start drawing with the stylus, the finger should only pan.

### 2. Draw with finger setting disabled: i. Enable stylus as pen setting and **disable** draw with finger setting. ii. Open a document and select the ink tool. iii. When you draw with the finger, it should always pan and never draw.

### 3. Stylus as pen setting disabled: i. Disable stylus as pen setting. ii. Open a document and select the ink tool. iii. When you draw with the finger, ink should be created. However once you start drawing with the stylus, the finger should only pan. Same as expected behavior 1.

## Always Draw with Finger and Stylus Setting

When this setting is enabled, the tool will always draw with finger and stylus.

Summary

[Expand]
Inherited Constants
From class com.pdftron.pdf.tools.SimpleShapeCreate
From class com.pdftron.pdf.tools.BaseTool
From class com.pdftron.pdf.tools.Tool
Fields
public static float sSampleDelta
[Expand]
Inherited Fields
From class com.pdftron.pdf.tools.Tool
Public Constructors
FreehandCreate(PDFViewCtrl ctrl)
Class constructor
Public Methods
boolean canEraseStroke()
boolean canRedoStroke()
boolean canUndoStroke()
void clearStrokes()
Clears all strokes.
void commitAnnotation()
Commits all changes to the annotation and resets this FreehandCreate object to it's initial state.
static float computeThresholdValue(View pdfViewCtrl)
static List<List<PointF>> createPageStrokesFromArrayObj(Obj strokesArray)
static List<List<PointF>> createStrokeListFromArrayObj(Obj strokesArray)
int getCreateAnnotType()
Gets what annotation type this tool can create
String getPressureSensitiveKey()
ToolManager.ToolModeBase getToolMode()
The overload implementation of getToolMode().
boolean isCreatingAnnotation()
The overload implementation of isCreatingAnnotation().
void onClose()
The overload implementation of onClose().
boolean onDoubleTap(MotionEvent e)
The overload implementation of onDoubleTap(MotionEvent).
boolean onDoubleTapEvent(MotionEvent e)
The overload implementation of onDoubleTapEvent(MotionEvent).
boolean onDown(MotionEvent e)
The overload implementation of onDown(MotionEvent).
void onDraw(Canvas canvas, Matrix tfm)
The overload implementation of onDraw(Canvas, Matrix).
boolean onFlingStop()
The overload implementation of onFlingStop().
boolean onMove(MotionEvent e1, MotionEvent e2, float x_dist, float y_dist)
The overload implementation of onMove(MotionEvent, MotionEvent, float, float).
void onRenderingFinished()
The overload implementation of onRenderingFinished().
boolean onScaleBegin(float x, float y)
The overload implementation of onScaleBegin(float, float).
boolean onUp(MotionEvent e, PDFViewCtrl.PriorEventMode priorEventMode)
The overload implementation of onUp(MotionEvent, PDFViewCtrl.PriorEventMode).
void redoStroke()
Redoes the last undo.
void saveAnnotation()
Save the current ink strokes back to the annotation.
void setAllowTapToSelect(boolean allowTapToSelect)
Sets whether allow tap to select another annotation.
static void setDebug(boolean debug)
void setInitInkItem(Annot inkAnnot, int pageNum)
Initializes the ink item based on the specified annotation.
void setMultiStrokeMode(boolean mode)
Sets multiple stroke mode.
void setOnToolbarStateUpdateListener(OnToolbarStateUpdateListener listener)
Sets the OnToolbarStateUpdateListener listener.
void setPressureSensitive(boolean isPressureSensitive)
Sets whether the Ink annotation should be use pressure sensitive data.
void setTimedModeEnabled(boolean enabled)
Sets time mode.
void setupAnnotProperty(AnnotStyle annotStyle)
Setup annotation properties.
void setupAnnotProperty(int color, float opacity, float thickness, int fillColor, String icon, String pdfTronFontName)
void setupEraserProperty(AnnotStyle annotStyle)
Setups eraser property.
void undoStroke()
Undoes the last stroke.
[Expand]
Inherited Methods
From class com.pdftron.pdf.tools.SimpleShapeCreate
From class com.pdftron.pdf.tools.BaseTool
From class com.pdftron.pdf.tools.Tool
From class java.lang.Object
From interface com.pdftron.pdf.tools.ToolManager.Tool

Fields

public static float sSampleDelta

Public Constructors

public FreehandCreate (PDFViewCtrl ctrl)

Class constructor

Public Methods

public boolean canEraseStroke ()

Returns
  • True if can erase any strokes

public boolean canRedoStroke ()

Returns
  • True if can redo the last undo

public boolean canUndoStroke ()

Returns
  • True if can undo the last stroke

public void clearStrokes ()

Clears all strokes.

public void commitAnnotation ()

Commits all changes to the annotation and resets this FreehandCreate object to it's initial state.

After this is called, the tool should not continue to be used. Before undo/redo, you should ensure there is no commit left to annotations.

public static float computeThresholdValue (View pdfViewCtrl)

public static List<List<PointF>> createPageStrokesFromArrayObj (Obj strokesArray)

public static List<List<PointF>> createStrokeListFromArrayObj (Obj strokesArray)

public int getCreateAnnotType ()

Gets what annotation type this tool can create

Returns
  • annot type for annotation creation tool, or unknown for non-creation tool.

public String getPressureSensitiveKey ()

public ToolManager.ToolModeBase getToolMode ()

The overload implementation of getToolMode().

Returns
  • the mode/identifier of this tool.

public boolean isCreatingAnnotation ()

The overload implementation of isCreatingAnnotation().

public void onClose ()

The overload implementation of onClose().

public boolean onDoubleTap (MotionEvent e)

The overload implementation of onDoubleTap(MotionEvent).

public boolean onDoubleTapEvent (MotionEvent e)

The overload implementation of onDoubleTapEvent(MotionEvent).

public boolean onDown (MotionEvent e)

The overload implementation of onDown(MotionEvent).

public void onDraw (Canvas canvas, Matrix tfm)

The overload implementation of onDraw(Canvas, Matrix).

public boolean onFlingStop ()

The overload implementation of onFlingStop().

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

The overload implementation of onMove(MotionEvent, MotionEvent, float, float).

public void onRenderingFinished ()

The overload implementation of onRenderingFinished().

public boolean onScaleBegin (float x, float y)

The overload implementation of onScaleBegin(float, float).

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

The overload implementation of onUp(MotionEvent, PDFViewCtrl.PriorEventMode).

public void redoStroke ()

Redoes the last undo.

public void saveAnnotation ()

Save the current ink strokes back to the annotation. The tool can continue to be used to edit the current annotation.

public void setAllowTapToSelect (boolean allowTapToSelect)

Sets whether allow tap to select another annotation. Only allowed in single stroke mode.

Parameters
allowTapToSelect true if allow tap to select another annotation, dot will not be drawn. Default to false.

public static void setDebug (boolean debug)

public void setInitInkItem (Annot inkAnnot, int pageNum)

Initializes the ink item based on the specified annotation.

Parameters
inkAnnot The ink annotation
pageNum The page number

public void setMultiStrokeMode (boolean mode)

Sets multiple stroke mode.

Parameters
mode True if multiple stroke mode is enabled

public void setOnToolbarStateUpdateListener (OnToolbarStateUpdateListener listener)

Sets the OnToolbarStateUpdateListener listener.

Parameters
listener the OnToolbarStateUpdateListener listener

public void setPressureSensitive (boolean isPressureSensitive)

Sets whether the Ink annotation should be use pressure sensitive data. This is only available for devices that support capacitive touch screen that provide pressure data to MotionEvents.

By default Pressure Sensitivity is disabled.

Parameters
isPressureSensitive True if pressure sensitivity is enabled.

public void setTimedModeEnabled (boolean enabled)

Sets time mode.

Parameters
enabled True if time mode is enabled

public void setupAnnotProperty (AnnotStyle annotStyle)

Setup annotation properties.

public void setupAnnotProperty (int color, float opacity, float thickness, int fillColor, String icon, String pdfTronFontName)

Parameters
color The color
opacity The opacity
thickness The thickness
fillColor The color for filling
icon The icon
pdfTronFontName The PDFTron font name

public void setupEraserProperty (AnnotStyle annotStyle)

Setups eraser property.

Parameters
annotStyle The annot style

public void undoStroke ()

Undoes the last stroke.