new SelectionModel(annotation, canModify, isSelected)
Create a new selection model.
Parameters:
| Name | Type | Description |
|---|---|---|
annotation |
Annotations.Annotation | the annotation selected |
canModify |
Boolean | modification of the annotation is allowed |
isSelected |
Boolean | the annotation is already selected |
Members
-
defaultNoPermissionSelectionOutlineColor
-
Defines the default color for the annotation selection outline when the user is not permitted to make modifications.
-
defaultSelectionOutlineColor
-
Defines the default color for the annotation selection outline.
-
selectionAccuracyPadding
-
Defines a padding for selection accuracy. Default is 2. Increase this value to make selection more forgiving.
-
selectionOutlineDashSize
-
Defines the dash size for the selection outline. Default is 4;
-
selectionOutlineThickness
-
Defines thickness of the annotation selection outline. Default is 2.
Methods
-
canModify()
-
Indicates that the associated annotation is able to be modified
Returns:
- Type
- Boolean
-
drawSelectionOutline(ctx, annotation, zoom)
-
Draws the selection outline of the annotation. By default, a rectangle is drawn based on the annotations x, y, width and height.
Parameters:
Name Type Description ctxCanvasRenderingContext2D annotationAnnotations.Annotation zoomnumber -
getControlHandles()
-
Returns the ControlHandle objects associated with this selection model.
Returns:
an array of ControlHandleObject
- Type
- Array.<Annotations.ControlHandle>
-
getDimensions(annotation)
-
Gets the dimensions {x, y, width, height} of the selection bounding box. It may be different from the annotation's bounding box. e.g. The selection bounding box may have a padding.
Parameters:
Name Type Description annotationAnnotations.Annotation Returns:
- Type
- Annotations.Rect
-
isSelected()
-
Indicates that the associated annotation is already selected. This can be useful to implement different selection behaviors when an annotation is selected.
Returns:
- Type
- Boolean
-
testControlHandles(annotation, zoom, x, y)
-
Hit detection for each control handle.
Parameters:
Name Type Description annotationAnnotations.Annotation zoomnumber xnumber ynumber Returns:
the control handle that was hit
-
testSelection(annotation, x, y, pageMatrix, zoom, rotation)
-
Determines if the provided point is a hit on the selected annotationhandle.
- See Annotations.SelectionAlgorithm for usuable selection algorithms.
Parameters:
Name Type Description annotationAnnotations.Annotation the annotation
xnumber the x-coordinate of the point to test, in page coordinates
ynumber the y-coordinate of the point to test, in page coordinates
pageMatrixobject the page matrix of the page the annotation is on
zoomnumber the zoom level of the page the annotation is on
rotationCoreControls.PageRotation the rotation of the page the annotation is on
Returns:
true if the provided point is a hit
- Type
- boolean