Skip to content

Control

Constructors

constructor

new Control(ogma, options?): Control

Parameters

NameType
ogmaOgma<any, any>
optionsPartial<ControllerOptions>

Returns

Control

Properties

prefixed

Static prefixed: string | boolean

Methods

add

add(annotation): this

Add an annotation to the controller

Parameters

NameTypeDescription
annotationArrow | Text | AnnotationCollectionThe annotation to add

Returns

this

addListener

addListener<T>(event, fn, context?): this

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
fn(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void
context?any

Returns

this

cancelDrawing

cancelDrawing(): void

Cancel drawing on the current frame

Returns

void

destroy

destroy(): void

Destroy the controller and its elements

Returns

void

emit

emit<T>(event, ...args): boolean

Calls each of the listeners registered for a given event.

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
...argsArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]

Returns

boolean

eventNames

eventNames(): keyof FeatureEvents[]

Return an array listing the events for which the emitter has registered listeners.

Returns

keyof FeatureEvents[]

findMagnetPoint

findMagnetPoint(magnets, textToMagnet, point): undefined | MagnetPoint

Parameters

NameType
magnetsPoint[]
textToMagnetText
pointPoint

Returns

undefined | MagnetPoint

getAnnotation

getAnnotation(id): undefined | Arrow | Text

Retrieve the annotation with the given id

Parameters

NameTypeDescription
idIdthe id of the annotation to get

Returns

undefined | Arrow | Text

The annotation with the given id

getAnnotations

getAnnotations(): AnnotationCollection

Returns

AnnotationCollection

the annotations in the controller

getSelected

getSelected(): null | Annotation

Returns

null | Annotation

the currently selected annotation

listenerCount

listenerCount(event): number

Return the number of listeners listening to a given event.

Parameters

NameType
eventkeyof FeatureEvents

Returns

number

listeners

listeners<T>(event): (...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void[]

Return the listeners registered for a given event.

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT

Returns

(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void[]

loadLink(arrow): void

Parameters

NameType
arrowArrow

Returns

void

off

off<T>(event, fn?, context?, once?): this

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
fn?(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void
context?any
once?boolean

Returns

this

on

on<T>(event, fn, context?): this

Add a listener for a given event.

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
fn(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void
context?any

Returns

this

onUpdate

onUpdate(annotation): void

Triggers the update event on the annotation

Parameters

NameTypeDescription
annotationAnnotationThe annotation updated

Returns

void

once

once<T>(event, fn, context?): this

Add a one-time listener for a given event.

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
fn(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void
context?any

Returns

this

refreshTextLinks(): void

Returns

void

remove

remove(annotation): this

Remove an annotation or an array of annotations from the controller

Parameters

NameTypeDescription
annotationArrow | Text | AnnotationCollectionThe annotation(s) to remove

Returns

this

removeAllListeners

removeAllListeners(event?): this

Remove all listeners, or those of the specified event.

Parameters

NameType
event?keyof FeatureEvents

Returns

this

removeListener

removeListener<T>(event, fn?, context?, once?): this

Remove the listeners of a given event.

Type parameters

NameType
Textends keyof FeatureEvents

Parameters

NameType
eventT
fn?(...args: ArgumentMap<FeatureEvents>[Extract<T, keyof FeatureEvents>]) => void
context?any
once?boolean

Returns

this

select

select(id): this

Selects the annotation with the given id

Parameters

NameTypeDescription
idIdthe id of the annotation to select

Returns

this

setOptions

setOptions(options?): ControllerOptions

Set the options for the controller

Parameters

NameTypeDescription
optionsPartial<ControllerOptions>new Options

Returns

ControllerOptions

the updated options

setScale

setScale(id, scale, ox, oy): Control

Parameters

NameType
idId
scalenumber
oxnumber
oynumber

Returns

Control

startArrow

startArrow(x, y, arrow?): void

Start adding an arrow (add it, and give control to the user)

Parameters

NameTypeDescription
xnumbercoord of the first point
ynumbercoord of the first point
arrow?ArrowThe arrow to add

Returns

void

startText

startText(x, y, text?): void

Start adding a text (add it, and give control to the user)

Parameters

NameTypeDescription
xnumbercoord of the top left point
ynumbercoord of the top left point
text?TextThe text to add

Returns

void

unselect

unselect(): this

Unselects the currently selected annotation

Returns

this

updateStyle

updateStyle<A>(id, style): this

Update the style of the annotation with the given id

Type parameters

NameType
Aextends Annotation

Parameters

NameTypeDescription
idIdThe id of the annotation to update
styleA["properties"]["style"]The new style

Returns

this