# Class: SelectionModel

## Core.Annotations. SelectionModel

Represents a class that contains information about how an annotation should behave when selected.

#### new SelectionModel(annotation, canModify, isSelected, docViewer)

  Create a new selection model.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `annotation` | Core.Annotations.Annotation | The annotation selected
  `canModify` | boolean | Modification of the annotation is allowed
  `isSelected` | boolean | The annotation is already selected
  `docViewer` | Core.DocumentViewer | An instance of DocumentViewer.

### Members

#### <static> defaultNoPermissionSelectionOutlineColor

  Defines the default color for the annotation selection outline when the user is not permitted to make modifications.

  ##### Type:

  - Core.Annotations.Color

#### <static> defaultSelectionOutlineColor

  Defines the default color for the annotation selection outline.

  ##### Type:

  - Core.Annotations.Color

#### <static> selectionAccuracyPadding

  Defines padding for selection accuracy. Default is 2. Increase this value to make selection more forgiving.

  ##### Type:

  - number

#### <static> selectionOutlineDashSize

  Defines the dash size for the selection outline. Default is 4;

  ##### Type:

  - number

#### <static> selectionOutlineExtraPadding

  Defines the default padding between selection control points. The padding only appears when the control points are too close.

  ##### Type:

  - number

#### <static> selectionOutlineThickness

  Defines thickness of the annotation selection outline. Default is 1.

  ##### Type:

  - number

#### <static> showPaddingWhenAnnotationIsSmall

  Defines if extra padding should be shown when the selected annotation is too small. Default is true.

  ##### Type:

  - boolean

#### <static> useDashedLine

  Defines if a dashed line style should be used for the selection outline. Default is false.

  ##### Type:

  - boolean

### 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
  --- | --- | ---
  `ctx` | CanvasRenderingContext2D |
  `annotation` | Core.Annotations.Annotation |
  `zoom` | number |

#### getControlHandles()

  Returns the ControlHandle objects associated with this selection model.

  ##### Returns:

  An array of ControlHandleObject
  Type
    Array.<Core.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
  --- | --- | ---
  `annotation` | Core.Annotations.Annotation |

  ##### Returns:

  Type
    Core.Math.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
  --- | --- | ---
  `annotation` | Core.Annotations.Annotation |
  `zoom` | number |
  `x` | number |
  `y` | number |

  ##### Returns:

  The control handle that was hit
  Type
    Core.Annotations.ControlHandle

#### testSelection(annotation, x, y, pageMatrix, zoom, rotation)

  Determines if the provided point is a hit on the selected annotationhandle. * See Core.Annotations.SelectionAlgorithm for usuable selection algorithms.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `annotation` | Core.Annotations.Annotation | the annotation
  `x` | number | the x-coordinate of the point to test, in page coordinates
  `y` | number | the y-coordinate of the point to test, in page coordinates
  `pageMatrix` | object | the page matrix of the page the annotation is on
  `zoom` | number | the zoom level of the page the annotation is on
  `rotation` | Core.PageRotation | the rotation of the page the annotation is on

  ##### Returns:

  true if the provided point is a hit
  Type
    boolean

#### Search results