Nodes
A node is a graph item which represents an entity. It is modeled by the interface INode. INode provides a number of properties which define the node’s characteristics. All properties (except tag) are read-only. You can set their values using the corresponding methods on IGraph.
Property | Setter | Description |
---|---|---|
A node cannot be simply created with a constructor. Instead, you can create nodes as well as remove them from the graph using IGraph’s methods:
- createNode(layout: Rect, style: INodeStyle, tag: Object): INode
- createNodeAt(location: Point, style: INodeStyle, tag: Object): INode
- createNode(parent: INode, layout: Rect, style: INodeStyle, tag: Object): INode
- Creates a node. The various overloads allow setting the new node’s properties at creation time. Values which are not passed as parameters will be set to the default values as defined in the node defaults.
- remove(item: IModelItem): void
- Removes the given node from the graph. Before the node is removed all dependent items (the node’s labels and ports, also adjacent edges) are removed.
You can only modify or remove nodes which are part of the current graph instance. Trying to modify or remove a node which already has been removed will result in an exception. Also, if your use case involves several IGraph instances (especially if you are using filtering or folding) take care to modify and remove nodes only with the graph the node belongs to.