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
|
- 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
_emitIntegrationEvent(name, payload, ctxopt)
Emit an integration hook event to the configured targets.
This is the single entrypoint for toolkit-owned "public hook" events so we can
keep payloads consistent and optionally avoid extra calls.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | event name (kebab-case) | |||||||||
payload |
Object | event payload (will be shallow-cloned and enriched) | |||||||||
ctx |
Object |
<optional> |
Properties
|
- Source:
addAnnotationLayout(optsopt) → {AnnotationLayout|null}
Build the annotation layout (grid, resize, toggle button) using AnnotationLayout.
Uses getToolbar() and getLayerUI() (lazy-creating with default opts if needed). Mutually exclusive with addAnnotationUI.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
addButton, buttonTogglesToolbar, buttonTogglesLayerUI, initialOpen (all optional). |
- Source:
Returns:
The layout, or null if addAnnotationUI already exists.
- Type
- AnnotationLayout | null
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:
addTools(toolNamesopt)
Add a set of tools without the full UI (toolbar). Use when addUI is false.
Creates a toolset (tool layer + tool instances) so getTool(name) and activation work.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
toolNames |
Array.<string> |
<optional> |
Array of tool names (e.g. ['default', 'ruler']). Default tool is always included. |
- 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>
getLayerUI(optsopt) → {LayerUI|null}
Get the toolkit's layer UI, creating it on first call with the given opts. Use .element to get the root DOM node (official API; do not look up by CSS class or id).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
Used only when creating: opts.addFileButton - optional boolean. |
- Source:
Returns:
The layer UI instance, or null if addAnnotationUI exists but did not create a layer UI.
- Type
- LayerUI | null
getLayerUIElement(optsopt) → {HTMLElement|null}
Get the root DOM element for the layer UI (official API). Returns null if no layer UI exists.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
Passed to getLayerUI(opts) when lazy-creating. |
- Source:
Returns:
- Type
- HTMLElement | null
getTool(name) → {OSDPaperjsAnnotation.ToolBase|null}
Get a tool instance by name (e.g. 'ruler', 'default'). Works with full UI or headless addTools().
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Tool name. |
- Source:
Returns:
- Type
- OSDPaperjsAnnotation.ToolBase | null
getToolbar(optsopt) → {AnnotationToolbar|null}
Get the toolkit's toolbar, creating it on first call with the given opts. Use .element to get the root DOM node (official API; do not look up by CSS class or id).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
Used only when creating: opts.tools - optional array of tool names. |
- Source:
Returns:
The toolbar instance, or null if addAnnotationUI exists but did not create a toolbar.
- Type
- AnnotationToolbar | null
getToolbarElement(optsopt) → {HTMLElement|null}
Get the root DOM element for the toolbar (official API). Returns null if no toolbar exists.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
Passed to getToolbar(opts) when lazy-creating. |
- Source:
Returns:
- Type
- HTMLElement | null
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:
off(name, fn) → {this}
Unsubscribe from Paper.js project events.
Equivalent to: `tk.paperScope.project.off(name, fn)`.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | |
fn |
function |
- Source:
Returns:
- Type
- this
on(name, fn) → {this}
Subscribe to Paper.js project events without reaching into paperScope internals.
Equivalent to: `tk.paperScope.project.on(name, fn)`.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | |
fn |
function |
- Source:
Returns:
- Type
- this
registerWithConfigurationWidget(configurationWidget)
Opt in to a ConfigurationWidget by adding an "Annotations" custom section (generic addSection only).
The toolkit owns the section DOM (toolbar visibility toggles for the pencil and save/load buttons when present).
Requires `addAnnotationUI()` first. Idempotent when called again with the same widget. Unregisters automatically on `destroy()`.
Parameters:
| Name | Type | Description |
|---|---|---|
configurationWidget |
OSDPaperjsAnnotation.ConfigurationWidget |
- 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
|
- 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: