Class: DiagramModel
Defined in: diagram/model.ts:128
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
elements
Get Signature
get elements(): readonly
Element
[]
Defined in: diagram/model.ts:208
All elements (nodes) in the graph.
Returns
readonly Element
[]
Implementation of
factory
Get Signature
get factory():
DataFactory
Defined in: diagram/model.ts:204
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: diagram/model.ts:163
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: diagram/model.ts:212
All links (edges) between elements in the graph.
Returns
readonly Link
[]
Implementation of
selection
Get Signature
Defined in: diagram/model.ts:183
Current diagram selection (elements and/or links).
Returns
Methods
addElement()
addElement(
element
):void
Defined in: diagram/model.ts:343
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: diagram/model.ts:373
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: diagram/model.ts:324
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: diagram/model.ts:235
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: diagram/model.ts:223
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: diagram/model.ts:227
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: diagram/model.ts:231
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: diagram/model.ts:250
Gets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
|
Returns
Implementation of
GraphStructure
.getLinkVisibility
removeElement()
removeElement(
elementId
):void
Defined in: diagram/model.ts:356
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: diagram/model.ts:382
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: diagram/model.ts:316
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: diagram/model.ts:170
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: diagram/model.ts:257
Sets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
| |
|
Returns
void
setSelection()
setSelection(
value
):void
Defined in: diagram/model.ts:190
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: diagram/model.ts:242
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: diagram/model.ts:246
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