Skip to main content

Class: DiagramModel

Defined in: diagram/model.ts:133

Stores the diagram content: graph (elements, links); maintains selection and the current language to display the data.

Additionally, the diagram model provides the means to undo/redo commands via history.

Extended by

Implements

Properties

PropertyModifierTypeDescription

events

readonly

Events<DiagramModelEvents>

Events for the diagram model.

history

readonly

CommandHistory

Provides the mechanism to undo/redo commands on the diagram.

Accessors

cellsVersion

Get Signature

get cellsVersion(): number

Defined in: diagram/model.ts:213

Graph content (elements and links) version number which changes on every cell change (when element or link added/removed/reordered, see DiagramModelEvents.changeCells).

Returns

number

Implementation of

GraphStructure.cellsVersion


elements

Get Signature

get elements(): readonly Element[]

Defined in: diagram/model.ts:217

All elements (nodes) in the graph.

Returns

readonly Element[]

Implementation of

GraphStructure.elements


factory

Get Signature

get factory(): DataFactory

Defined in: diagram/model.ts:209

Provides an RDF term factory to create RDF terms for identifiers and property values.

Returns

DataFactory

Implementation of

GraphStructure.factory


language

Get Signature

get language(): string

Defined in: diagram/model.ts:168

Current language for the diagram content.

Language code is specified as lowercase BCP47 string (examples: en, en-gb, etc).

Initial language is en.

Returns

string


Get Signature

get links(): readonly Link[]

Defined in: diagram/model.ts:221

All links (edges) between elements in the graph.

Returns

readonly Link[]

Implementation of

GraphStructure.links


selection

Get Signature

get selection(): readonly (Element | Link)[]

Defined in: diagram/model.ts:188

Current diagram selection (elements and/or links).

Returns

readonly (Element | Link)[]

Methods

addElement()

addElement(element): void

Defined in: diagram/model.ts:352

Adds the element to the diagram.

Throws an error if element with the same Element.id already exists in the graph.

The operation puts a command to the command history.

Parameters

ParameterType

element

Element

Returns

void


addLink(link): void

Defined in: diagram/model.ts:382

Adds the link to the diagram.

Throws an error if link with the same Link.id already exists in the graph or any of source or target is not in the graph.

The operation puts a command to the command history.

Parameters

ParameterType

link

Link

Returns

void


bringElements()

bringElements(targets, to): void

Defined in: diagram/model.ts:333

Puts specified elements before or after all other in the display order.

Parameters

ParameterType

targets

readonly Element[]

to

"front" | "back"

Returns

void


findLink(linkTypeId, sourceId, targetId): undefined | Link

Defined in: diagram/model.ts:244

Searches for any link of the specified type between elements with specified IDs in the graph if exists.

If multiple links is found, any of them could be returned.

Parameters

ParameterType

linkTypeId

LinkTypeIri

sourceId

string

targetId

string

Returns

undefined | Link

Implementation of

GraphStructure.findLink


getElement()

getElement(elementId): undefined | Element

Defined in: diagram/model.ts:232

Gets an element by its Element.id in the graph if exists.

Parameters

ParameterType

elementId

string

Returns

undefined | Element

Implementation of

GraphStructure.getElement


getElementLinks(element): readonly Link[]

Defined in: diagram/model.ts:236

Gets all links connected to the specified element in the graph.

If element is not in the graph, no links would be returned.

Parameters

ParameterType

element

Element

Returns

readonly Link[]

Implementation of

GraphStructure.getElementLinks


getLink(linkId): undefined | Link

Defined in: diagram/model.ts:240

Gets a link by its Link.id in the graph if exists.

Parameters

ParameterType

linkId

string

Returns

undefined | Link

Implementation of

GraphStructure.getLink


getLinkVisibility()

getLinkVisibility(linkTypeId): LinkTypeVisibility

Defined in: diagram/model.ts:259

Gets current visibility mode for the specified link type.

Parameters

ParameterType

linkTypeId

LinkTypeIri

Returns

LinkTypeVisibility

Implementation of

GraphStructure.getLinkVisibility


removeElement()

removeElement(elementId): void

Defined in: diagram/model.ts:365

Removes the element with specified ID from the diagram if exists.

When element is removed, all connected links will be removed as well.

The operation puts a command to the command history.

Parameters

ParameterType

elementId

string

Returns

void


removeLink(linkId): void

Defined in: diagram/model.ts:391

Removes the link with specified ID from the diagram if exists.

The operation puts a command to the command history.

Parameters

ParameterType

linkId

string

Returns

void


reorderElements()

reorderElements(compare): void

Defined in: diagram/model.ts:325

Changes display order of elements on the diagram.

Parameters

ParameterTypeDescription

compare

(a, b) => number

Sort comparator to establish a particular ordering

Returns

void


setLanguage()

setLanguage(value): void

Defined in: diagram/model.ts:175

Sets current language for the diagram content.

Language code is specified as lowercase BCP47 string (examples: en, en-gb, etc).

Parameters

ParameterType

value

string

Returns

void


setLinkVisibility()

setLinkVisibility(linkTypeId, value): void

Defined in: diagram/model.ts:266

Sets current visibility mode for the specified link type.

Parameters

ParameterType

linkTypeId

LinkTypeIri

value

LinkTypeVisibility

Returns

void


setSelection()

setSelection(value): void

Defined in: diagram/model.ts:195

Sets current diagram selection (elements and/or links).

When called, selected cells will be brought to the front before all other diagram cells.

Parameters

ParameterType

value

readonly (Element | Link)[]

Returns

void


sourceOf()

sourceOf(link): undefined | Element

Defined in: diagram/model.ts:251

Gets a source element for the specified link in the graph.

If link is not in the graph, undefined would be returned instead.

Parameters

ParameterType

link

Link

Returns

undefined | Element

Implementation of

GraphStructure.sourceOf


targetOf()

targetOf(link): undefined | Element

Defined in: diagram/model.ts:255

Gets a target element for the specified link in the graph.

If link is not in the graph, undefined would be returned instead.

Parameters

ParameterType

link

Link

Returns

undefined | Element

Implementation of

GraphStructure.targetOf