Class: DiagramModel
Defined in: src/diagram/model.ts:135
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
| Property | Modifier | Type | Description |
|---|---|---|---|
| Events for the diagram model. | ||
| Provides the mechanism to undo/redo commands on the diagram. |
Accessors
cellsVersion
Get Signature
get cellsVersion():
number
Defined in: src/diagram/model.ts:220
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
elements
Get Signature
get elements(): readonly
Element[]
Defined in: src/diagram/model.ts:224
All elements (nodes) in the graph.
Returns
readonly Element[]
Implementation of
factory
Get Signature
get factory():
DataFactory
Defined in: src/diagram/model.ts:216
Provides an RDF term factory to create RDF terms for identifiers and property values.
Returns
Implementation of
language
Get Signature
get language():
string
Defined in: src/diagram/model.ts:175
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
links
Get Signature
get links(): readonly
Link[]
Defined in: src/diagram/model.ts:228
All links (edges) between elements in the graph.
Returns
readonly Link[]
Implementation of
selection
Get Signature
Defined in: src/diagram/model.ts:195
Current diagram selection (elements and/or links).
Returns
Methods
addElement()
addElement(
element):void
Defined in: src/diagram/model.ts:359
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
| Parameter | Type |
|---|---|
|
Returns
void
addLink()
addLink(
link):void
Defined in: src/diagram/model.ts:389
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
| Parameter | Type |
|---|---|
|
Returns
void
bringElements()
bringElements(
targets,to):void
Defined in: src/diagram/model.ts:340
Puts specified elements before or after all other in the display order.
Parameters
| Parameter | Type |
|---|---|
| readonly |
|
|
Returns
void
findLink()
findLink(
linkTypeId,sourceId,targetId):undefined|Link
Defined in: src/diagram/model.ts:251
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
| Parameter | Type |
|---|---|
| |
|
|
|
|
Returns
undefined | Link
Implementation of
getElement()
getElement(
elementId):undefined|Element
Defined in: src/diagram/model.ts:239
Gets an element by its Element.id in the graph if exists.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
undefined | Element
Implementation of
getElementLinks()
getElementLinks(
element): readonlyLink[]
Defined in: src/diagram/model.ts:243
Gets all links connected to the specified element in the graph.
If element is not in the graph, no links would be returned.
Parameters
| Parameter | Type |
|---|---|
|
Returns
readonly Link[]
Implementation of
GraphStructure.getElementLinks
getLink()
getLink(
linkId):undefined|Link
Defined in: src/diagram/model.ts:247
Gets a link by its Link.id in the graph if exists.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
undefined | Link
Implementation of
getLinkVisibility()
getLinkVisibility(
linkTypeId):LinkTypeVisibility
Defined in: src/diagram/model.ts:266
Gets current visibility mode for the specified link type.
Parameters
| Parameter | Type |
|---|---|
|
Returns
Implementation of
GraphStructure.getLinkVisibility
removeElement()
removeElement(
elementId):void
Defined in: src/diagram/model.ts:372
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
| Parameter | Type |
|---|---|
|
|
Returns
void
removeLink()
removeLink(
linkId):void
Defined in: src/diagram/model.ts:398
Removes the link with specified ID from the diagram if exists.
The operation puts a command to the command history.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
void
reorderElements()
reorderElements(
compare):void
Defined in: src/diagram/model.ts:332
Changes display order of elements on the diagram.
Parameters
| Parameter | Type | Description |
|---|---|---|
| ( | Sort comparator to establish a particular ordering |
Returns
void
setLanguage()
setLanguage(
value):void
Defined in: src/diagram/model.ts:182
Sets current language for the diagram content.
Language code is specified as lowercase BCP47
string (examples: en, en-gb, etc).
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
void
setLinkVisibility()
setLinkVisibility(
linkTypeId,value):void
Defined in: src/diagram/model.ts:273
Sets current visibility mode for the specified link type.
Parameters
| Parameter | Type |
|---|---|
| |
|
Returns
void
setSelection()
setSelection(
value):void
Defined in: src/diagram/model.ts:202
Sets current diagram selection (elements and/or links).
When called, selected cells will be brought to the front before all other diagram cells.
Parameters
| Parameter | Type |
|---|---|
|
Returns
void
sourceOf()
sourceOf(
link):undefined|Element
Defined in: src/diagram/model.ts:258
Gets a source element for the specified link in the graph.
If link is not in the graph, undefined would be returned instead.
Parameters
| Parameter | Type |
|---|---|
|
Returns
undefined | Element
Implementation of
targetOf()
targetOf(
link):undefined|Element
Defined in: src/diagram/model.ts:262
Gets a target element for the specified link in the graph.
If link is not in the graph, undefined would be returned instead.
Parameters
| Parameter | Type |
|---|---|
|
Returns
undefined | Element