PMA.UI Documentation by Pathomation

Annotations

Annotations

Provides programmatic interaction with a Viewport instance to manipulate annotations

Constructor

new Annotations(options)

Source:
Tutorials:
  • Tutorial: 05-annotations
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

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(layerIdopt)

Source:
Saves all the annotations to PMA.core
Parameters:
Name Type Attributes Description
layerId number <optional>
If supplied, then only the contents of the particular layer are saved.

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

setMetadata(feature, metadata)

Source:
Sets the metadata for an existing annotation
Parameters:
Name Type Description
feature ol.Feature An annotation instance
metadata Annotations~Metadata The metadata to set

startDrawing(options)

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

startTool(options)

Source:
Starts an annotation drawing/editing tool
Parameters:
Name Type Description
options Object Options parameter required to start a tool
Properties
Name Type Attributes Description
type PMA.UI.Types.AnnotationTools The type of annotation 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
drawMode boolean <optional>
Enables drawing of new features in brush mode. Default: false
color string <optional>
Annotation outline color as HTML hex string. Required if type is Magic Wand or drawMode is enabled
fillColor string <optional>
Annotation fill color as HTML hex string. Required if type is Magic Wand or drawMode is enabled
penWidth Number <optional>
The line thickness. Required if type is Magic Wand or drawMode is enabled
notes string <optional>
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
Fires:
  • Components.Events#event:AnnotationEditingStarted

stopTool()

Source:
Stops the annotation tool
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
Context string <optional>
Optional context for the annotation
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

Metadata

Source:
Properties:
Name Type Description
AnnotationID number The annotation id
LayerID number The layer id for this annotations
Classification string The classification of the annotaion
Notes string The notes for this annotation if any
Color string The color of the annotation
CreatedOn Date The date this annotation was created
CreatedBy string The user that created this annotation
Image string The slide path this annotation belongs to
Geometry string The WKT describing this annotation's geometry
LineThickness number The line thickness this annotation is drawn
Dimensions number The dimensionality of this annotation, i.e. 0 for point, 1 for lines, 2 for polygons
FillColor string The color to fill this annotation if any
Area string The area for this annotation in mm^2, if applicable
FormattedArea string The area for this annotation in human friendly format
Length string The length of this annotation in mm
FormattedLength string The length of this annotation in human friendly format
Context string The context value
An object describing the metadata associated with an annotation

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