Class: EditorSvgAnnotation

EditorSvgAnnotation

EditorSvgAnnotation enables creation and editing of SVG annotations in OpenLIME. It provides tools for drawing various shapes and managing annotations through a user interface.

Features:

  • Drawing tools: point, pin, line, box, circle
  • Annotation editing and management
  • Custom state and data storage
  • Integration with annotation databases through callbacks
  • Undo/redo functionality
  • SVG export capabilities

new EditorSvgAnnotation(viewer, layer [, options])

Creates an EditorSvgAnnotation instance

Parameters:
Name Type Argument Description
viewer Viewer

The OpenLIME viewer instance

layer LayerSvgAnnotation

The annotation layer to edit

options Object <optional>

Configuration options

Properties
Name Type Argument Default Description
classes Object.<string, {stroke: string, label: string}>

Annotation classes with colors and labels

createCallback crudCallback <optional>

Called when creating annotations

updateCallback crudCallback <optional>

Called when updating annotations

deleteCallback crudCallback <optional>

Called when deleting annotations

enableState boolean <optional>
false

Whether to save viewer state with annotations

customState customStateCallback <optional>

Customize saved state data

customData customDataCallback <optional>

Customize annotation data

selectedCallback selectedCallback <optional>

Called when annotation is selected

tools Object <optional>

Custom tool configurations

priority number <optional>
20000

Event handling priority

Source:
Example
```javascript
// Create annotation layer
const anno = new OpenLIME.Layer(options);
viewer.addLayer('annotations', anno);

// Initialize editor
const editor = new OpenLIME.EditorSvgAnnotation(viewer, anno, {
  classes: {
    'default': { stroke: '#000', label: 'Default' },
    'highlight': { stroke: '#ff0', label: 'Highlight' }
  }
});

// Setup callbacks
editor.createCallback = (anno) => { 
  console.log("Created:", anno);
  return saveToDatabase(anno);
};
```

Methods


createAnnotation()

Creates a new annotation

Source:
Returns:
Type
void

deleteSelected()

Deletes the selected annotation

Source:
Returns:
Type
void

exportAnnotations()

Exports all annotations as SVG

Source:
Returns:
Type
void

redo()

Performs a redo operation

Source:
Returns:
Type
void

undo()

Performs an undo operation

Source:
Returns:
Type
void