Skip to content

Texts

Texts Draw, update, edit texts

Constructors

constructor

new Texts(ogma, options?): Texts

Parameters

NameType
ogmaOgma<any, any>
optionsPick<Partial<ControllerOptions>, "textPlaceholder" | "textHandleSize">

Returns

Texts

Properties

editor

Protected editor: Overlay

elements

Protected elements: Text[]

hoveredId

Protected hoveredId: Id = NONE

isDragging

Protected isDragging: boolean

layer

Protected layer: SVGLayer

ogma

Protected ogma: Ogma<any, any>

ogmaOptions

Protected ogmaOptions: Options$a

selectedId

Protected selectedId: Id = NONE

shouldDetect

Protected shouldDetect: boolean

showeditorOnHover

Protected showeditorOnHover: boolean

prefixed

Static prefixed: string | boolean

Methods

add

add(options): Text

Parameters

NameTypeDescription
optionsTextParams for the annotation (merged with default)

Returns

Text

the added annotation

Method

add

addListener

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

Type parameters

NameType
Textends keyof Events<Text>

Parameters

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

Returns

this

cancelDrawing

cancelDrawing(): void

Returns

void

destroy

destroy(): void

Returns

void

detect

detect(«destructured», margin?): undefined | Text

Parameters

NameTypeDefault value
«destructured»Pointundefined
marginnumber0

Returns

undefined | Text

disableDetection

disableDetection(): void

Returns

void

Method

disableDetection Disables the hover behaviour, used by controller to avoid hovering arrows while dragging texts and vice versa

disableDragging

disableDragging(): void

Returns

void

Method

disableDragging Prevents Ogma from dragging elements or moving the view while dragging an annotation

draw

draw(svg): void

Parameters

NameType
svgSVGSVGElement

Returns

void

emit

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

Calls each of the listeners registered for a given event.

Type parameters

NameType
Textends keyof Events<Text>

Parameters

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

Returns

boolean

enableDetection

enableDetection(): void

Returns

void

eventNames

eventNames(): keyof Events<Text>[]

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

Returns

keyof Events<Text>[]

getById

getById(id): Text

Parameters

NameType
idId

Returns

Text

getDefaultOptions

getDefaultOptions(): Text

Returns

Text

getElements

getElements(): Text[]

Returns

Text[]

getSelectedFeature

getSelectedFeature(): null | Text

Returns

null | Text

hover

hover(id): void

Parameters

NameType
idId

Returns

void

listenerCount

listenerCount(event): number

Return the number of listeners listening to a given event.

Parameters

NameType
eventkeyof Events<Text>

Returns

number

listeners

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

Return the listeners registered for a given event.

Type parameters

NameType
Textends keyof Events<Text>

Parameters

NameType
eventT

Returns

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

off

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

Type parameters

NameType
Textends keyof Events<Text>

Parameters

NameType
eventT
fn?(...args: ArgumentMap<Events<Text>>[Extract<T, keyof Events<Text>>]) => 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 Events<Text>

Parameters

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

Returns

this

onHandleMouseDown

onHandleMouseDown(evt): void

Parameters

NameType
evtMouseEvent

Returns

void

onMouseMove

onMouseMove(evt): void

Parameters

NameType
evtMouseEvent

Returns

void

onMouseUp

onMouseUp(): void

Returns

void

onViewChanged

onViewChanged(): void

Returns

void

once

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

Add a one-time listener for a given event.

Type parameters

NameType
Textends keyof Events<Text>

Parameters

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

Returns

this

refreshDrawing

refreshDrawing(): void

Returns

void

refreshEditor

refreshEditor(): void

Returns

void

refreshLayer

refreshLayer(): void

Returns

void

remove

remove(id): void

Parameters

NameTypeDescription
idIdId of the annotation to remove Removes annotation with the given id

Returns

void

Method

remove

removeAllListeners

removeAllListeners(event?): this

Remove all listeners, or those of the specified event.

Parameters

NameType
event?keyof Events<Text>

Returns

this

removeListener

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

Remove the listeners of a given event.

Type parameters

NameType
Textends keyof Events<Text>

Parameters

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

Returns

this

restoreDragging

restoreDragging(): void

Returns

void

Method

restoreDragging restore ogma options as they were before we start dragging an annotation

scale

scale(annotation, scale, ox, oy): void

Parameters

NameType
annotationText
scalenumber
oxnumber
oynumber

Returns

void

select

select(id): void

Parameters

NameType
idId

Returns

void

startDragging

startDragging(text, clientX, clientY): void

Parameters

NameType
textText
clientXnumber
clientYnumber

Returns

void

startDrawing

startDrawing(x, y, text?): void

Parameters

NameType
xnumber
ynumber
textText

Returns

void

unhover

unhover(): Texts

Returns

Texts

unselect

unselect(): Texts

Returns

Texts

update

update(id, element): void

Parameters

NameTypeDescription
idIdId of the annotation to update
elementPartial<Text>params of the annotation

Returns

void

Method

update Updates an annotation (position, color etc)

updateAnnotation

updateAnnotation(target, element): void

Parameters

NameType
targetText
elementPartial<Text>

Returns

void

updateGeometry

updateGeometry(annotation, geometry): void

Parameters

NameType
annotationText
geometryPartial<Polygon>

Returns

void

updateStyle

updateStyle(annotation, style): void

Parameters

NameType
annotationText
stylePartial<undefined | TextStyle>

Returns

void