Annotations

Annotations

Provides programmatic interaction with a Viewport instance to manipulate annotations

Constructor

new Annotations(options)

Source:
Tutorials:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
context Context
viewport Viewport
serverUrl string PMA.core server URL
path string Path of an slide to save annotations for
enabled boolean
Fires:

Classes

Annotations

Methods

addAnnotation(annotation)

Source:
Adds an annotation to the current ones (without saving them to the server)
Parameters:
Name Type Description
annotation Annotations~annotationEntity An annotation object

booleanDifference(inputPolygonFeature, polygonFeatureToDifferentiate)

Source:
Finds the difference between two annotations by clipping the second annotation from the first. Original annotations will be deleted. Style is based on inputPolygonFeature.
Parameters:
Name Type Description
inputPolygonFeature ol.Feature Base annotation feature to perform boolean difference.
polygonFeatureToDifferentiate ol.Feature Annotation feature to difference from inputPolygonFeature

booleanUnion(annotations)

Source:
Takes two or more annotations and adds a combined annotation. Original annotations will be deleted. Style is based on first annotation in array.
Parameters:
Name Type Description
annotations Array.<ol.Feature> An array of annotations to compine with at least two elements.

clearHighlight()

Source:
Clears all highlighted annotations

clearSelection()

Source:
Clears all selected annotations

deleteAnnotation(id)

Source:
Deletes an annotation
Parameters:
Name Type Description
id number The id of the annotation to delete
Fires:
  • PMA.UI.Components.Events#event:AnnotationDeleted

enterEditMode(type, brushTypeopt, brushSizeopt, brushStepopt, coloropt, fillColoropt, penWidthopt, notesopt, iconRelativePathopt, featureopt)

Source:
Options parameter required to start editing
Parameters:
Name Type Attributes Description
type PMA.UI.Types.Edit The type of edit tool to start
brushType string <optional>
The type of brush tip to use, 'circle' or 'square'. Used by brush and eraser tool. Default: 'circle'
brushSize Number <optional>
The size of brush tip. Used by brush and eraser tool. Default: 500
brushStep Number <optional>
The step to increase or decrease size of brush tip. Used by brush and eraser tool. Default: 50
color string <optional>
Annotation outline color as HTML hex string. Required if type is Magic Wand
fillColor string <optional>
Annotation fill color as HTML hex string. Required if type is Magic Wand
penWidth Number <optional>
The line thickness. Required if type is Magic Wand
notes string <optional>
Text to add to the annotation. Required if type is Magic Wand
iconRelativePath string <optional>
Relative path to an image that will be used when drawing a point. The base URL is defined by the imageBaseUrl property of the annotations initialization option supplied in the PMA.UI.View.Viewport constructor. Required if type is Magic Wand
feature ol.Feature <optional>
An existing feature to edit. If this argument has a value, the viewport goes into edit mode, instead of drawing a new annotation
Fires:
  • Components.Events#event:AnnotationEditingStarted

finishDrawing(accept, annotationType)

Source:
Exits drawing mode
Parameters:
Name Type Description
accept boolean True to accept the annotation that was currently being drawn
annotationType PMA.UI.Types.Annotation The annotation type that was drawing

getEnabled() → {boolean}

Source:
Gets the state of the annotation component
Returns:
Type
boolean

getSelection() → {Array.<{metaData: {PointCount: Number}}>}

Source:
Get the currently selected annotations
Returns:
Array of PMA.core annotation instances
Type
Array.<{metaData: {PointCount: Number}}>

hasChanges() → {bool}

Source:
Returns whether any annotation has unsaved changes
Returns:
Type
bool

highlightAnnotation(id)

Source:
Renders the requested annotation using the highlight style
Parameters:
Name Type Description
id Number The id of the annotation to render

listen(eventName, callback)

Source:
Attaches an event listener
Parameters:
Name Type Description
eventName PMA.UI.Components.Events The name of the event to listen to
callback function The function to call when the event occurs

mergeSelection(selectionopt)

Source:
Merges the selected annotations into one geometry
Parameters:
Name Type Attributes Default Description
selection Array.<ol.Feature> <optional>
null An array of annotations to merge. If this parameter is not supplied, the currently selected annotations are used.

replaceAnnotations(annotations)

Source:
Replaces the currently loaded annotations with the provided ones (without saving them to the server)
Parameters:
Name Type Description
annotations Array.<Annotations~annotationEntity> Array of annotation objects

saveAnnotations()

Source:
Saves all the annotations to PMA.core

selectAnnotation(id)

Source:
Adds the requested annotation in the selection list
Parameters:
Name Type Description
id Number The id of the annotation to select

setEnabled(enabled)

Source:
Enables or disables annotation drawing
Parameters:
Name Type Description
enabled boolean

startDrawing(options)

Source:
Instructs the viewport to enter annotation drawing mode
Parameters:
Name Type Description
options Annotations~startDrawingOptions Options to start drawing

stopEditing()

Source:
Exits editing mode
Fires:
  • Components.Events#event:AnnotationEditingEnded

Type Definitions

annotationEntity

Source:
Properties:
Name Type Attributes Default Description
LayerID Number The layer id
Geometry string The annotation geometry in wkt format
Notes string <optional>
Optional notes for the annotation
Classification string <optional>
Optional classification string (Necrosis, tumor etc)
Color string <optional>
Optional stroke color (e.g. #ff0000)
UpdateInfo string <optional>
Optional update info
FillColor string <optional>
Optional fill color (e.g. #ff0000)
Dimensions Number <optional>
Optional dimensionality of the annotation
LineThickness Number <optional>
1 Optional stroke line thickness
Annotation entity
Type:
  • Object

startDrawingOptions

Source:
Properties:
Name Type Attributes Description
type PMA.UI.Types.Annotation The type of the annotation to start drawing
color string Annotation outline color as HTML hex string
fillColor string Annotation fill color as HTML hex string
penWidth Number The line thickness
notes string Text to add to the annotation
iconRelativePath string <optional>
Relative path to an image that will be used when drawing a point. The base URL is defined by the imageBaseUrl property of the annotations initialization option supplied in the PMA.UI.View.Viewport constructor
feature ol.Feature <optional>
An existing feature to edit. If this argument has a value, the viewport goes into edit mode, instead of drawing a new annotation
size Array.<Number> <optional>
An optional array of [width, height] in microns. Applies only to circles and rectangles. When drawing a circle only width is taken into account and it's the diameter of the circle.
Options parameter required to start drawing
Type:
  • Object