Class: AnnotationToolkit

OSDPaperjsAnnotation.AnnotationToolkit(openSeadragonViewer, optsopt)

A class for creating and managing annotation tools on an OpenSeadragon viewer.

Constructor

new AnnotationToolkit(openSeadragonViewer, optsopt)

Create a new AnnotationToolkit instance.
Parameters:
Name Type Attributes Description
openSeadragonViewer OpenSeadragon.Viewer The OpenSeadragon viewer object.
opts object <optional>
Properties
Name Type Attributes Description
addUI object <optional>
a configuration object for the UI, if desired
overlay object <optional>
a PaperOverlay object to use
destroyOnViewerClose object <optional>
whether to destroy the toolkit and its overlay when the viewer closes
cacheAnnotations object <optional>
whether to keep annotations in memory for images which aren't currently open
Source:

Extends

  • OpenSeadragon.EventSource

Members

annotationUI

Get the default style for the annotation items.
Source:

defaultStyle

Get the default style for the annotation items.
Source:

paperScope

Get the paperScope associated with this toolkit
Source:

Methods

addAnnotationUI(optsopt) → {AnnotationUI}

Add an annotation UI to the toolkit.
Parameters:
Name Type Attributes Default Description
opts object <optional>
{} The options for the annotation UI.
Source:
Returns:
The annotation UI object.
Type
AnnotationUI

addEmptyFeatureCollectionGroup() → {paper.Group}

Add a new, empty FeatureCollection with default label and parent
Source:
Returns:
The paper group object representing the feature collection.
Type
paper.Group

addFeatureCollections(featureCollections, replaceCurrent, parentImageopt)

Add feature collections to the toolkit from GeoJSON objects.
Parameters:
Name Type Attributes Description
featureCollections Array.<object> The array of GeoJSON objects representing feature collections.
replaceCurrent boolean Whether to replace the current feature collections or not.
parentImage OpenSeadragon.TiledImage | OpenSeadragon.Viewport | false <optional>
which image to add the feature collections to
Source:

clearCache()

Empty any cached annotations
Source:

close()

Close the toolkit and remove its feature collections.
Source:

destroy()

Destroy the toolkit and its components.
Source:

getFeatureCollectionGroups(parentLayeropt) → {Array.<paper.Group>}

Get the feature collection groups that the toolkit is managing.
Parameters:
Name Type Attributes Description
parentLayer paper.Layer <optional>
The layer to find feature collections within. If not specified, finds across all layers.
Source:
Returns:
The array of paper groups representing feature collections.
Type
Array.<paper.Group>

getFeatures() → {Array.<paper.Item>}

Get the features in the toolkit.
Source:
Returns:
The array of paper item objects representing features.
Type
Array.<paper.Item>

loadGeoJSON(geoJSON, replaceCurrent, parentImageopt, pixelCoordinatesopt)

Load feature collections from GeoJSON objects and add them to the project.
Parameters:
Name Type Attributes Description
geoJSON Array.<object> The array of GeoJSON objects representing feature collections.
replaceCurrent boolean Whether to replace the current feature collections or not.
parentImage OpenSeadragon.TiledImage | OpenSeadragon.Viewport | false <optional>
Which image (or viewport) to add the object to
pixelCoordinates boolean <optional>
Source:

makePlaceholderItem(style)

Make a placeholder annotation item
Parameters:
Name Type Description
style Object options (e.g strokeColor) to pass to the paper item
Source:

setGlobalVisibility(showopt)

Set the global visibility of the toolkit.
Parameters:
Name Type Attributes Default Description
show boolean <optional>
false Whether to show or hide the toolkit.
Source:

toGeoJSON(optionsopt) → {Array.<Object>}

Convert the feature collections in the toolkit to GeoJSON objects.
Parameters:
Name Type Attributes Description
options Object <optional>
Properties
Name Type Attributes Description
layer Layer <optional>
The specific layer to use
Source:
Returns:
The array of GeoJSON objects representing feature collections.
Type
Array.<Object>

toGeoJSONString(replaceropt, spaceopt) → {string}

Convert the feature collections in the project to a JSON string.
Parameters:
Name Type Attributes Description
replacer function <optional>
The replacer function for JSON.stringify().
space number | string <optional>
The space argument for JSON.stringify().
Source:
Returns:
The JSON string representing the feature collections.
Type
string

(static) registerFeature(item)

Register an item as a GeoJSONFeature that the toolkit should track
Parameters:
Name Type Description
item paper.Item The item to track as a geoJSONFeature
Source:

(static) registerFeatureCollection(group)

Register a group as a GeoJSONFeatureCollection that the toolkit should track
Parameters:
Name Type Description
group paper.Group The group to track as a geoJSONFeatureCollection
Source: