Class: DiagramModel
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. | |
|
| Provides the methods to format the content according to the current language. Deprecated Use useTranslation hook instead. |
Accessors
elements
get
elements(): readonlyElement
[]
All elements (nodes) in the graph.
Returns
readonly Element
[]
Implementation of
Defined in
factory
get
factory():DataFactory
Provides an RDF term factory to create RDF terms for identifiers and property values.
Returns
Implementation of
Defined in
language
get
language():string
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
Defined in
links
get
links(): readonlyLink
[]
All links (edges) between elements in the graph.
Returns
readonly Link
[]
Implementation of
Defined in
selection
Current diagram selection (elements and/or links).
Returns
Defined in
Methods
addElement()
addElement(
element
):void
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
Defined in
addLink()
addLink(
link
):void
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
Defined in
bringElements()
bringElements(
targets
,to
):void
Puts specified elements before or after all other in the display order.
Parameters
Parameter | Type |
---|---|
| readonly |
|
|
Returns
void
Defined in
findLink()
findLink(
linkTypeId
,sourceId
,targetId
):undefined
|Link
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
Defined in
getElement()
getElement(
elementId
):undefined
|Element
Gets an element by its Element.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Element
Implementation of
Defined in
getElementLinks()
getElementLinks(
element
): readonlyLink
[]
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
Defined in
getLink()
getLink(
linkId
):undefined
|Link
Gets a link by its Link.id in the graph if exists.
Parameters
Parameter | Type |
---|---|
|
|
Returns
undefined
| Link
Implementation of
Defined in
getLinkVisibility()
getLinkVisibility(
linkTypeId
):LinkTypeVisibility
Gets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
|
Returns
Implementation of
GraphStructure
.getLinkVisibility
Defined in
removeElement()
removeElement(
elementId
):void
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
Defined in
removeLink()
removeLink(
linkId
):void
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
Defined in
reorderElements()
reorderElements(
compare
):void
Changes display order of elements on the diagram.
Parameters
Parameter | Type | Description |
---|---|---|
| ( | Sort comparator to establish a particular ordering |
Returns
void
Defined in
setLanguage()
setLanguage(
value
):void
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
Defined in
setLinkVisibility()
setLinkVisibility(
linkTypeId
,value
):void
Sets current visibility mode for the specified link type.
Parameters
Parameter | Type |
---|---|
| |
|
Returns
void
Defined in
setSelection()
setSelection(
value
):void
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
Defined in
sourceOf()
sourceOf(
link
):undefined
|Element
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
Defined in
targetOf()
targetOf(
link
):undefined
|Element
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