Central implementation of the IGraph interface.
Remarks
This implementation deals with the proper firing of events and handling of default values.
This implementation has inherent support for undoability. If the undoEngineEnabled property is set to true
, changes to the structure of the graph will automatically be recorded using the UndoEngine instance that can be queried from this instance's lookup method. Clients that wish to enqueue custom undo events or that need to make non-structural changes to the graph can use the UndoEngine to do so. The current instance of UndoEngine can be queried using the lookup method of this instance. Also there are several protected methods Create...UndoUnit
that will be used by this instance to create the actual undo units for structural changes in the graph's structure. If clients need to customize these units they can create a subclass of Graph and override these methods.
Finally this implementation supports grouped graphs.
Related Reading in the Developer's Guide
DefaultGraph
is IGraph's default implementation as described in the section The Graph Model - IGraph.Related Programming Samples
- Graph Editor
- Shows the graph editing features of the graph component.
Type Details
- yFiles module
- view
See Also
Constructors
Creates a new instance of a graph that provides an ILookupDecorator for all of its entities.
Parameters
A map of options to pass to the method.
- undoEngineEnabled - boolean
- Whether the UndoEngine used for this instance should be enabled. This option sets the undoEngineEnabled property on the created object.
- edgeDefaults - IEdgeDefaults
- nodeDefaults - INodeDefaults
- groupNodeDefaults - INodeDefaults
- tag - any
- nodes - Object[]
- An array of nodes to create in this graph. Each item will be passed to the createNode method.
Properties
Gets a live view of all bends contained in this IGraph.
Gets a GraphDecorator instance for use with this graph.
Defined in
Gets or sets the defaults for edges.
Remarks
Implements
Gets a view of the edges contained in this graph.
Remarks
This is a live view of the edges that always represents the current state of the graph. The same reference will be returned for each invocation.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the edges via a foreach
loop.
Implements
Gets the IFoldingView instance associated with this IGraph or null
if none is associated with it.
Remarks
See Also
Defined in
Creates a GroupingSupport instance for the graph.
Remarks
Defined in
Gets or sets the defaults for group nodes.
Remarks
Implements
Gets a view of the labels contained in this graph.
Remarks
This is a live view of the labels that always represents the current state of the graph. The same reference will be returned for each invocation.
Note that even though labels can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the labels in your own list, if possible. This is not necessary for the first or last element or when iterating over the labels via a foreach
loop.
See Also
Implements
Gets or sets the defaults for normal nodes.
Remarks
Implements
Gets a view of the nodes contained in this graph.
Remarks
This is a live view of the nodes that always represents the current state of the graph. The same reference will be returned for each invocation.
Note that even though nodes can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the nodes in your own list, if possible. This is not necessary for the first or last element or when iterating over the nodes via a foreach
loop.
Implements
Gets a view of the ports contained in this graph.
Remarks
This is a live view of the ports that always represents the current state of the graph. The same reference will be returned for each invocation.
Note that even though ports can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the ports in your own list, if possible. This is not necessary for the first or last element or when iterating over the ports via a foreach
loop.
Implements
Gets or sets the tag object associated with this item instance.
Remarks
Implements
Gets the UndoEngine instance associated with this IGraph or null
if none is associated with it.
Remarks
Defined in
Gets or sets whether the UndoEngine used for this instance should be enabled.
Remarks
false
. In order to enable undoability for this instance, set this property to true
and lookup the UndoEngine type. Disabling this property clears and removes the current UndoEngine (and all enqueued IUndoUnits).See Also
Overrides
Methods
Adds a bend at the given index to the given edge using the coordinates provided.
Remarks
The added instance will be returned.
To retrieve the current bends of an edge, use bends
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to which the bend will be added.
- location - Point
- The coordinates to use for the newly created bend. To change the location after the bend has been added, use setBendLocation.
- index - number
- The index for the newly added bend; A negative value (which is the default) indicates that the bend should be appended to the end of the list of bends.
Returns
- ↪IBend
- A newly created live bend
Throws
- Exception({ name: 'ArgumentError' })
edge
is not in this graph, orlocation
contains one or more NaN values.
See Also
Implements
Adds bends with the given locations to the end of the bend list of the given edge.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to add the bends to.
- locations - IEnumerable<Point>
- The locations of the bends.
Throws
- Exception({ name: 'ArgumentError' })
edge
is not in this graph.- Exception({ name: 'ArgumentError' })
locations
contains one or more NaN values.
See Also
Defined in
addLabel
(owner: ILabelOwner, text: string, layoutParameter?: ILabelModelParameter, style?: ILabelStyle, preferredSize?: Size, tag?: ILabel['tag']) : ILabelAdd a label to the given node or edge using the text as the initial label text and label model parameter, style, and tag.
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The node, edge, or port to add the label to. Note that the owner cannot be changed after the label has been added.
- text - string
- The initial text of the label. To change the text after the label has been added, use setLabelText.
- layoutParameter - ILabelModelParameter
- The label model parameter instance to use. If omitted the default parameter will be set. To change the parameter after the label has been added, use setLabelLayoutParameter.
- style - ILabelStyle
- The style to use for the label. If omitted the default style will be set. To change the style after the label has been added, use setStyle.
- preferredSize - Size
- The initial values to use for the preferredSize. If omitted size will be determined automatically. To change the preferred size after the label has been added, use setLabelPreferredSize.
- tag - ILabel['tag']
- The initial tag to assign.
Returns
- ↪ILabel
- The newly created label.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph orpreferredSize
contains one or more NaN values.
See Also
Implements
Adds the chain element to the lookup for this instance.
Parameters
A map of options to pass to the method.
- lookup - IContextLookupChainLink
- The lookup to decorate the current instance with.
addPort
(owner: IPortOwner, locationParameter?: IPortLocationModelParameter, style?: IPortStyle, tag?: IPort['tag']) : IPortAdd a port to the given port owner using the coordinates as the new initial position of the port anchor.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner to add the port instance to.
- locationParameter - IPortLocationModelParameter
- The parameter to use for the port to determine its location.
- style - IPortStyle
- The style to assign initially to the port, e.g. VOID_PORT_STYLE.
- tag - IPort['tag']
- The tag to associate with the port, may be
null
.
Returns
- ↪IPort
- The newly created port
Throws
- Exception({ name: 'NotSupportedError' })
- If this instance cannot add a port to
owner
. - Exception({ name: 'ArgumentError' })
- If
owner
is not in this graph.
See Also
Implements
Add a port to the given port owner using the absolute coordinates as the new initial position of the port anchor.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner to add the port instance to.
- location - Point
- The location to use for the port to determine its location. This is passed to the createDefaultPortLocationParameter method to determine the initial IPortLocationModelParameter to use.
- style - IPortStyle
- The style to initially assign to the style property, e.g. VOID_PORT_STYLE.
- tag - IPort['tag']
- The initial tag to assign.
Returns
- ↪IPort
- The newly created port
Throws
- Exception({ name: 'NotSupportedError' })
- If this instance cannot add a port to
owner
. - Exception({ name: 'ArgumentError' })
owner
is not in this graph.- Exception({ name: 'ArgumentError' })
location
contains one or more NaN values.
See Also
Defined in
Adds a new port to the graph at the node using a location that is relative to the center of the node.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The owner of the port.
- relativeLocation - Point
- The offset of the port relative to the center of the layout.
Returns
- ↪IPort
- The newly added port instance.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.- Exception({ name: 'ArgumentError' })
relativeLocation
contains one or more NaN values.
See Also
Defined in
Uses the UndoEngine from the IGraph's ILookup to add a unit.
Parameters
A map of options to pass to the method.
- undoName - string
- The name of the undo operation.
- redoName - string
- The name of the redo operation.
- undo - function():void
- The undo action.
Signature Details
function()
Encapsulates a method that has no parameters and does not return a value.Parameters
- redo - function():void
- The redo action.
Signature Details
function()
Encapsulates a method that has no parameters and does not return a value.Parameters
Defined in
Method to adjust the size of a group node.
Remarks
groupNode
.Parameters
A map of options to pass to the method.
- groupNode - INode
- The group node to adjust the size of.
Throws
- Exception({ name: 'ArgumentError' })
groupNode
is not in this graph.
Examples
// create a group node
const group = graph.createGroupNode()
// add some child nodes
graph.createNode(group, new Rect(10, 10, 30, 30))
graph.createNode(group, new Rect(50, 10, 30, 30))
graph.createNode(group, new Rect(50, 50, 30, 30))
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(group)
AdjustGroupNodeLayout
only affects the node it is called for. To properly adjust all of its ancestors, too, one has to adjust all of them from the given node to the root:for (const nodeToAdjust of graph.groupingSupport.getAncestors(
innermostGroup,
)) {
graph.adjustGroupNodeLayout(nodeToAdjust)
}
See Also
Defined in
Adjusts the preferredSize property of a label to fit the suggested size of its ILabelStyleRenderer.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to adjust the size for.
See Also
Defined in
applyLayout
(layout: ILayoutAlgorithm, layoutData?: LayoutData<INode,IEdge,ILabel,ILabel>, stopDuration?: TimeSpan, cancelDuration?: TimeSpan, portAdjustmentPolicies?: ItemMapping<IPort,PortAdjustmentPolicy>, portPlacementPolicies?: ItemMapping<IPort,PortPlacementPolicy>, portLabelPolicies?: ItemMapping<ILabel,PortLabelPolicy>, anchoredItems?: ItemMapping<IModelItem,LayoutAnchoringPolicy>, labelPlacementPolicies?: ItemMapping<ILabel,LabelPlacementPolicy>, nodeComparator?: function(INode, INode):number, edgeComparator?: function(IEdge, IEdge):number)Runs an ILayoutAlgorithm synchronously on the given graph.
Remarks
Parameters
A map of options to pass to the method.
- layout - ILayoutAlgorithm
- The layout.
- layoutData - LayoutData<INode,IEdge,ILabel,ILabel>
- The layout data.
- stopDuration - TimeSpan
- the maximum runtime for the layout calculation before it is automatically stopped.
- cancelDuration - TimeSpan
- the maximum runtime for the layout calculation before it is automatically canceled.
- portAdjustmentPolicies - ItemMapping<IPort,PortAdjustmentPolicy>
- The policy that specifies how port locations should be adjusted after a layout has been calculated.
- portPlacementPolicies - ItemMapping<IPort,PortPlacementPolicy>
- The policy that specifies how ports should be placed by the layout algorithm.
- portLabelPolicies - ItemMapping<ILabel,PortLabelPolicy>
- anchoredItems - ItemMapping<IModelItem,LayoutAnchoringPolicy>
- Specifies which part of the items should be used to anchor the graph during layout.
- labelPlacementPolicies - ItemMapping<ILabel,LabelPlacementPolicy>
- Sets how ILabels should be placed by the layout algorithm.
- nodeComparator - function(INode, INode):number
- A comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations.
- edgeComparator - function(IEdge, IEdge):number
- A comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations.
See Also
LayoutExecutor
type is available at runtime.Defined in
beginEdit
<T>(undoName: string, redoName: string, items: IEnumerable<T>, provider?: function(T):IMementoSupport) : ICompoundEditStarts an ICompoundEdit that uses the memento design pattern to record changes to the items in the given items
collection.
Remarks
This method uses the IMementoSupport returned by the provider
to record the state of an item at the beginning of the edit and when commit is called to create an IUndoUnit that can revert the item to the recorded state and back. If no provider
is given, this method uses the IMementoSupport returned by the lookup implementation of the items to record the state of an item at the beginning of the edit and when commit is called to create an IUndoUnit that can revert the item to the recorded state and back.
Calling this method will immediately enqueue an IUndoUnit into the undo queue. Subsequent additions to the queue will be added after the created instance, even if they are added to the queue before the commit method has been called.
Type Parameters
- T
- The type of the items that will be modified subsequently.
Parameters
A map of options to pass to the method.
- undoName - string
- redoName - string
- items - IEnumerable<T>
- The items that will be changed after this call and before the call to commit.
- provider - function(T):IMementoSupport
- The provider for the IMementoSupport of the
items
. if the provider returnsnull
for a given item, changes to this item are not being recorded.Signature Details
function(item: T) : IMementoSupport
A function that is used to retrieve an IMementoSupport for any given object.Parameters
- item - T
- The item to provide the
for.
Returns
Returns
- ↪ICompoundEdit
- An implementation of the ICompoundEdit interface whose commit or cancel methods need to be called after the items have been modified.
Examples
The following is an example implementation of an item that is being managed using IMementoSupport:
class Employee extends BaseClass<ILookup>(ILookup) implements ILookup {
_name: string
position: string
age: number
constructor(name: string, position: string, age: number) {
super()
this._name = name
this.position = position
this.age = age
}
get name(): string {
return this._name
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
lookup<T extends any>(type: Constructor<any>): T | null {
if (type === IMementoSupport) {
return new EmployeeMementoSupport() as T
}
return null
}
}
A collection of items from this type can then be watched using the following code snippet:
const edit = graph.beginEdit(
undoName,
redoName,
listWithMyEmployeesToWatch,
)
// changes to the employees are done here
if (!success) {
// if we don't want the changes to be done after all, then we need to cancel the edit
edit.cancel()
}
Alternatively, when using a specific provider, consider the following examples. The following is an example implementation of an item that is being managed using IMementoSupport:
class SimpleEmployee {
private readonly _name: string
position: string
age: number
constructor(name: string, position: string, age: number) {
this._name = name
this.position = position
this.age = age
}
get name(): string {
return this._name
}
}
A collection of items from this type can then be watched using the following code snippet, using the provider
to return an appropriate IMementoSupport implementation:
const edit = graph.beginEdit(
undoName,
redoName,
listWithMyEmployeesToWatch,
(item) => new EmployeeMementoSupport(),
)
// changes to the employees are done here
if (!success) {
// if we don't want the changes to be done after all, then we need to cancel the edit
edit.cancel()
}
Implementing the IMementoSupport interface is quite unrestrained, the type of the state returned by getState method can by anything as long as the applyState and stateEquals methods can deal with it:
class EmployeeMementoSupport
extends BaseClass<IMementoSupport>(IMementoSupport)
implements IMementoSupport
{
getState(subject: any): EmployeeState | null {
if (subject instanceof Employee) {
return new EmployeeState(subject.position, subject.age)
}
return null
}
applyState(subject: any, state: any): void {
if (subject instanceof Employee && state instanceof EmployeeState) {
subject.position = state.position
subject.age = state.age
}
}
stateEquals(state1: any, state2: any): boolean {
if (
state1 instanceof EmployeeState &&
state2 instanceof EmployeeState
) {
return (
state1.position === state2.position && state1.age === state2.age
)
}
return state1 === state2
}
}
class EmployeeState {
_position: string
_age: number
constructor(position: string, age: number) {
this._position = position
this._age = age
}
get position(): string {
return this._position
}
get age(): number {
return this._age
}
}
In summary, use this concept when you want to track the state of items during certain operations for undo/redo. This is efficient if it's easier to handle an item's state than the changes to the item themselves. If you want to focus on the changes or on certain events, you should use custom IUndoUnit
See Also
Defined in
Starts an ICompoundEdit that records graph changes and custom undo units in a single compound unit.
Remarks
This method can be used to bracket several undo units. All edits added to the queue after this call and before a call to cancel or commit will be placed into the queue as a single block.
Client code needs to make sure that either the cancel or commit method is called on the returned instance.
Parameters
A map of options to pass to the method.
- undoName - string
- The undo name for the compound edit.
- redoName - string
- The redo name for the compound edit.
Returns
Defined in
calculateLabelPreferredSize
(owner: ILabelOwner, text: string, layoutParameter?: ILabelModelParameter, style?: ILabelStyle, tag?: ILabel['tag']) : SizeCalculates the preferred size of a label with the given properties.
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The item that will own the label.
- text - string
- The text.
- layoutParameter - ILabelModelParameter
- The label model parameter.
- style - ILabelStyle
- The label style.
- tag - ILabel['tag']
- The tag for the label.
Returns
- ↪Size
- The size as calculated by the ILabelStyleRenderer.
See Also
Defined in
Clears the graph, removing all items in proper order.
Removes all bends from the given edge.
Remarks
Parameters
A map of options to pass to the method.
- owner - IEdge
- the edge whose bends will be removed
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Removes all labels from the given ILabelOwner, which can be an INode, IEdge, or IPort.
Remarks
Parameters
A map of options to pass to the method.
- labelOwner - ILabelOwner
- the owner whose labels will be removed
Throws
- Exception({ name: 'ArgumentError' })
labelOwner
is not in this graph.
See Also
Defined in
Removes all ports from the given IPortOwner, which can be an INode or an IEdge.
Remarks
Parameters
A map of options to pass to the method.
- portOwner - IPortOwner
- the owner whose ports will be removed
Throws
- Exception({ name: 'ArgumentError' })
portOwner
is not in this graph.
See Also
Defined in
Determines whether this graph contains the specified item.
Parameters
A map of options to pass to the method.
- item - IModelItem
- The item.
Returns
- ↪boolean
true
if this graph contains the specified item; otherwise,false
.
Implements
createCompositeLayoutData
(items: LayoutData<INode,IEdge,ILabel,ILabel>…) : CompositeLayoutData<INode,IEdge,ILabel,ILabel>Returns an instance of CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that combines the given layout data instances.
Remarks
Parameters
A map of options to pass to the method.
- items - LayoutData<INode,IEdge,ILabel,ILabel>
- the layout data instances that should be combined into the created CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
Returns
- ↪CompositeLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of CompositeLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that combines the given layout data instances.
LayoutExecutor
type is available at runtime.Defined in
Creates the label layout parameter for a given ILabelOwner.
Remarks
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The item that is the owner of the label in question.
Returns
- ↪ILabelModelParameter
- The default label layout parameter to use for newly created labels at the item.
See Also
Defined in
createDefaultPortLocationParameter
(owner: IPortOwner, location?: Point) : IPortLocationModelParameterCreates a location model parameter for a newly created IPort at the owner
that matches the location
.
Remarks
location
is null
, this method uses the port defaults for the owner
to obtain the location parameter.Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner of the port.
- location - Point
- The location in the world coordinate system where the port should be added.
Returns
- ↪IPortLocationModelParameter
- Either a location model parameter that matches the location, or the default parameter to use for the IPortOwner as returned by getLocationParameterInstance.
Throws
- Exception({ name: 'ArgumentError' })
location
contains one or more NaN values.
See Also
Defined in
Creates and returns an edge that connects to the given node instances using the given style instance.
Remarks
Parameters
A map of options to pass to the method.
- source - INode
- The source node the created edge will connect to. This implementation queries the getNewSourcePort method to determine which port to use.
- target - INode
- The target node the created edge will connect to. This implementation queries the getNewSourcePort method to determine which port to use.
- style - IEdgeStyle
- The style instance that will be assigned to the newly created instance. This is done by reference.
- tag - IEdge['tag']
- the initial tag to assign.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- bends - Point[]
- An array of bends to add to the newly created edge. Each item will be passed to the addBend method.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- bends - Point[]
- An array of bends to add to the newly created edge. Each item will be passed to the addBend method.
Returns
- ↪IEdge
- the newly created edge instance
Throws
- Exception({ name: 'ArgumentError' })
- If
source
ortarget
is not in this graph.
See Also
Implements
Creates and returns an edge that connects to the given port instances.
Remarks
Parameters
A map of options to pass to the method.
- sourcePort - IPort
- The source port the created edge will connect to. To change the source port after the edge has been created, use setEdgePorts.
- targetPort - IPort
- The target port the created edge will connect to. To change the target port after the edge has been created, use setEdgePorts.
- style - IEdgeStyle
- The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set. To change the style after the edge has been created, use setStyle.
- tag - IEdge['tag']
- The initial value of the tag that will be assigned to the new edge.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- bends - Point[]
- An array of bends to add to the newly created edge. Each item will be passed to the addBend method.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- bends - Point[]
- An array of bends to add to the newly created edge. Each item will be passed to the addBend method.
Returns
- ↪IEdge
- the newly created edge instance
See Also
Implements
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to easily associate custom item-specific data with an IGraph.
Remarks
Returns
- ↪GenericLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of GenericLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to easily associate custom item-specific data with a
graph
.
LayoutExecutor
type is available at runtime.Defined in
Creates a new group node using the provided style and layout as a child of parent
.
Remarks
The group node will be a direct descendant of parent
.
To create group nodes interactively use the GraphEditorInputMode as input mode and enable the grouping operations.
Parameters
A map of options to pass to the method.
- parent - INode
- layout - Rect
- The initial layout to use for the new node. If omitted the node will be placed with its top left corner at 0,0 and the default size. To change the layout after the group node has been created, use setNodeLayout.
- style - INodeStyle
- The style to use for the new node. If omitted the default style will be set. To change the style after the group node has been created, use setStyle.
- tag - INode['tag']
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- children - Rect[]
- An array of nodes to create as child nodes of this group node. Each item will be passed to the createNode method.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- children - Rect[]
- An array of nodes to create as child nodes of this group node. Each item will be passed to the createNode method.
Returns
- ↪INode
- The newly created group node.
Throws
- Exception({ name: 'ArgumentError' })
- The
layout
contains one or more NaN values.
See Also
Implements
Creates and returns a node using the specified values for the initial geometry, style, and tag.
Remarks
Parameters
A map of options to pass to the method.
- layout - Rect
- The layout to use initially. The values will be copied to the node's layout field. To change the layout after the node has been created, use setNodeLayout.
- style - INodeStyle
- The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set. To change the style after the node has been added, use setStyle.
- tag - INode['tag']
- The initial value of the tag that will be assigned to the new node.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
Returns
- ↪INode
- A newly created node instance
Throws
- Exception({ name: 'ArgumentError' })
layout
contains one or more NaN values.
See Also
Implements
Creates a new ordinary node as a direct descendant of parent
using the given layout and style.
Parameters
A map of options to pass to the method.
- parent - INode
- The node to use as the parent in the grouping hierarchy or
null
if the new node should become a top-level node. To change the parent after the group node has been created, use setParent. - layout - Rect
- The layout to use initially. The values will be copied to the node's layout field. If omitted the default size will be set and the node's top left corner will be placed at 0,0. To change the layout after the group node has been created, use setNodeLayout.
- style - INodeStyle
- The style instance that will be assigned to the newly created instance. This is done by reference. If omitted the default style will be set.
- tag - INode['tag']
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
Returns
- ↪INode
- The newly created node.
Throws
- Exception({ name: 'ArgumentError' })
parent
is not in this graph, orlayout
contains one or more NaN values.
See Also
Implements
Creates and returns a node using the specified initial center location and style, as well as the tag.
Remarks
Parameters
A map of options to pass to the method.
- location - Point
- the initial coordinates of the center of the node's layout property
- style - INodeStyle
- The style instance that will be assigned to the newly created instance. This is done by reference.
- tag - INode['tag']
- The initial value of the tag that will be assigned to the new node.
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
Returns
- ↪INode
- A newly created node instance
Throws
- Exception({ name: 'ArgumentError' })
location
contains one or more NaN values.
See Also
Defined in
Creates an UndoEngine instance that automatically triggers invalidateDisplays upon each invocation of undo and redo
Returns
- ↪UndoEngine
- An UndoEngine instance.
Creates the edge reconnection undo unit for the given edge.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that has been reconnected to other ports.
- oldSource - IPort
- The old source port the edge connected to before the change.
- oldTarget - IPort
- The old target port the edge connected to before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the port change operation.
Creates the undo unit for changing the style of the given edge.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge whose style has been changed.
- oldStyle - IEdgeStyle
- The old style used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the style change.
Creates the undo unit for changing the tag of the given graph.
Creates the undo unit for changing whether the given node is a group node.
createUndoUnitForLabelModelParameterChange
(label: ILabel, oldParam: ILabelModelParameter) : IUndoUnitCreates the undo unit for changing the layout parameter of the given label.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose layout parameter has been changed.
- oldParam - ILabelModelParameter
- The old layout parameter used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the layout parameter change.
Creates the undo unit for changing the style of the given label.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose style has been changed.
- oldStyle - ILabelStyle
- The old style used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the style change.
Creates the undo unit for changing the tag of the given label.
Creates the undo unit for changing the text of the given label.
createUndoUnitForLocationParameterChange
(port: IPort, oldParameter: IPortLocationModelParameter) : IUndoUnitCreates the undo unit for changing the location parameter of the given port.
Parameters
A map of options to pass to the method.
- port - IPort
- The port whose location parameter has been changed.
- oldParameter - IPortLocationModelParameter
- The old location parameter used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the location parameter change.
Creates the node creation undo unit for the given node.
Creates the undo unit for changing the style of the given node.
Parameters
A map of options to pass to the method.
- node - INode
- The node whose style has been changed.
- oldStyle - INodeStyle
- The old style used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the style change.
Creates the parent change undo unit for the given node.
Creates the undo unit for changing the style of the given port.
Parameters
A map of options to pass to the method.
- port - IPort
- The port whose style has been changed.
- oldStyle - IPortStyle
- The old style used before the change.
Returns
- ↪IUndoUnit
- The unit that can be used to undo and redo the style change.
Creates the undo unit for changing the preferred size of the given label.
Calculates the number of edges at the given IPortOwner for this graph.
Remarks
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner to count the degree of.
Returns
- ↪number
- The number of edges that are incident to the port owner.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Calculates the number of edges at the given IPort for this graph.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- The port owner to count the degree of.
Returns
- ↪number
- The number of edges that are incident to the port.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.
See Also
Defined in
Returns an IListEnumerable<T> for the incoming, the outgoing, or all edges adjacent to the given port, depending on type
.
Remarks
If the given type
is ALL, adjacent self-loops will appear twice in the returned enumerable. For INCOMING or OUTGOING, self-loops will only appear once.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases, it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the adjacent edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- port - IPort
- The port to check. The returned edges will have this port as a sourcePort or targetPort.
- type - AdjacencyTypes
- The type of adjacency to consider. Default is ALL, which includes both incoming and outgoing edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumeration of all adjacent edges of the given
type
(incoming, outgoing, or both).
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.
See Also
Implements
Returns an IListEnumerable<T> for the incoming, the outgoing, or all edges adjacent to the given port owner, depending on type
.
Remarks
If the given type
is ALL, adjacent self-loops will appear twice in the returned enumerable. For INCOMING or OUTGOING, self-loops will only appear once.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases, it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the adjacent edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port to check. The returned edges will have one of the ports at this owner as a sourcePort or targetPort.
- type - AdjacencyTypes
- The type of adjacency to consider. Default is ALL, which includes both incoming and outgoing edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumeration of all adjacent edges of the given
type
(incoming, outgoing, or both).
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Implements
Returns an enumerable over the children of the provided node.
Remarks
This method returns the direct children, i.e. all nodes that have node
as their parent. To get all descendants method getDescendants can be used.
To make a node a child of node
, use setParent or create the node directly as a child with createNode
Parameters
A map of options to pass to the method.
- node - INode
- The node for which to return the children or
null
if the top-level nodes should be returned.
Returns
- ↪IListEnumerable<INode>
- All nodes that have
node
as their parent.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.
See Also
Implements
Finds an edge that connects from
and to
in the given graph.
Parameters
A map of options to pass to the method.
- from - IPortOwner
- The sourcePort owner of the edge to find.
- to - IPortOwner
- The targetPort owner of the edge to find.
Returns
- ↪IEdge?
- An edge that satisfies the constraints or
null
, if none was found.
Throws
- Exception({ name: 'ArgumentError' })
from
orto
are not in this graph.
See Also
Defined in
Finds an edge that connects sourcePort
and targetPort
in the given graph.
Parameters
A map of options to pass to the method.
- sourcePort - IPort
- The sourcePort of the edge to find.
- targetPort - IPort
- The targetPort of the edge to find.
Returns
- ↪IEdge?
- An edge that satisfies the constraints or
null
, if none was found.
Throws
- Exception({ name: 'ArgumentError' })
sourcePort
ortargetPort
are not in this graph.
See Also
Defined in
Returns the edges between the specified source and target owners.
Remarks
directed
to false.Parameters
A map of options to pass to the method.
- source - IPortOwner
- The owner from which the edges start.
- target - IPortOwner
- The owner at which the edges end.
- directed - boolean
- Specifies whether to return only directed edges (default) or all edges regardless of direction.
Returns
- ↪IEnumerable<IEdge>
- An enumerable collection of edges connecting the
source
to thetarget
.
Defined in
Returns the edges between the specified source and target ports.
Remarks
directed
to false.Parameters
A map of options to pass to the method.
- sourcePort - IPort
- The port from which the edges start.
- targetPort - IPort
- The port at which the edges end.
- directed - boolean
- Specifies whether to return only directed edges (default) or all edges regardless of direction.
Returns
- ↪IEnumerable<IEdge>
- An enumerable collection of edges connecting the
sourcePort
to thetargetPort
.
Defined in
Gets the ILabelDefaults for a given ILabelOwner in the context of the graph
.
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The item that the label defaults are returned for. If this is a group node, the groupNodeDefaults's label defaults will be returned, otherwise the nodeDefaults or edgeDefaults labels will be returned.
Returns
- ↪ILabelDefaults
- Appropriate ILabelDefaults for the provided
owner
.
Defined in
Determines a IPort instance to use for the creation of a new edge that starts at the given IPortOwner.
Remarks
Parameters
A map of options to pass to the method.
- source - IPortOwner
- The source node to find a port for.
Returns
- ↪IPort
- The port to use for a newly created edge.
See Also
Determines a IPort instance to use for the creation of a new edge that ends at the given IPortOwner.
Remarks
Parameters
A map of options to pass to the method.
- targetOwner - IPortOwner
- The target node to find a port for.
Returns
- ↪IPort
- The port to use for a newly created edge.
See Also
Returns the parent node of the node or null
if node
is a top-level node.
Gets the IPortDefaults for a given IPortOwner in the context of the graph
.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The item that the label defaults are returned for. If this is a group node, the groupNodeDefaults's port defaults will be returned, otherwise the nodeDefaults or edgeDefaults ports will be returned.
Returns
- ↪IPortDefaults
- Appropriate IPortDefaults for the provided
owner
.
Defined in
Groups the nodes in children
into the provided group node.
Remarks
parent
needs to be a group node at the time of the invocation. This operation is basically the same as calling setParent for each node in children
whose parent is not part of the set.// create some nodes
const children = []
for (let i = 0; i < 5; i++) {
children.push(graph.createNode())
}
// create a group node
const parent = graph.createGroupNode()
// add the nodes as children to the group
graph.groupNodes(parent, children)
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(parent)
Parameters
A map of options to pass to the method.
- parent - INode
- The node to use as the parent in the grouping hierarchy.
- children - IEnumerable<INode>
- The children to group into the group node.
Throws
- Exception({ name: 'ArgumentError' })
parent
or one ofchildren
is not in this graph.
See Also
Defined in
Groups the nodes in children
into a newly created group node.
Remarks
children
.// create some nodes
const children = []
for (let i = 0; i < 5; i++) {
children.push(graph.createNode())
}
// create a group node and add the given nodes as children
const group = graph.groupNodes(children)
// adjust the group node's layout to include all its children
graph.adjustGroupNodeLayout(group)
Parameters
A map of options to pass to the method.
- children - IEnumerable<INode>
- The children to group into the new group node.
- style - INodeStyle
- The style for the new group node
- tag - any
- The group node's tag
- labels - string[]
- An array of labels to add to the newly created node. Each item will be passed to the addLabel method.
- ports - IPortLocationModelParameter[]
- An array of ports to add to the newly created node. Each item will be passed to the addPort method.
Returns
- ↪INode
- The newly created group node.
Throws
- Exception({ name: 'ArgumentError' })
- One of
children
is not in this graph.
See Also
Defined in
Calculates the number of incoming edges at the given IPortOwner for this graph.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner to count the incoming edges of.
Returns
- ↪number
- The number of edges that have the port owner as their target port's owner.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Calculates the number of incoming edges at the given IPort for this graph.
Returns the incoming edges at the given owner.
Remarks
This method delegates to edgesAt using INCOMING.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the incoming edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner of the edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumerable for the edges.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Returns the incoming edges at the given port.
Remarks
This method delegates to edgesAt using INCOMING.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the incoming edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- port - IPort
- The port of the edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumerable for the edges.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.
See Also
Defined in
Triggers the displays-invalidated event.
Remarks
Implements
Returns whether the given node is a group node.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node to check.
Returns
- ↪boolean
- Whether the node is considered a group node.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.
See Also
Implements
Returns an instance that provides another aspect of this instance of the given type or null
.
Remarks
null
implementations for the types, nor does it have to return the same instance any time. Also, it depends on the type and context whether the instance returned stays up to date or needs to be re-obtained for subsequent use.Type Parameters
- T
Parameters
A map of options to pass to the method.
- type - Constructor<T>
- The type for which an instance shall be returned
Returns
- ↪T?
- An instance that is assignable to type or
null
Implements
Enumerates the neighbors of a given INode.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node.
Returns
- ↪IEnumerable<INode>
- An enumerable over all neighbors.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.
See Also
Defined in
Called when a port is going to be added to a node.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The node.
- port - IPort
- The port to be added.
Called after a bend location has changed.
Remarks
Parameters
A map of options to pass to the method.
Called just after a bend has been removed from its edge.
Called after a bend tag has changed.
Remarks
Parameters
A map of options to pass to the method.
- bend - IBend
- The bend whose tag has changed.
- oldTag - any
- The bend tag before the change.
Called before an edge style is being changed.
Parameters
A map of options to pass to the method.
- edge - IEdge
- An edge whose the style is going to be changed.
- newStyle - IEdgeStyle
- The new edge style.
Called before the layoutParameter of a label is being changed.
Parameters
A map of options to pass to the method.
- label - ILabel
- A label whose layoutParameter is to be changed.
- newLayoutParameter - ILabelModelParameter
- The new label model parameter.
Called before a label style is being changed.
Parameters
A map of options to pass to the method.
- label - ILabel
- A label whose style is going to be changed.
- newStyle - ILabelStyle
- The new label style.
Called before a node style is being changed.
Parameters
A map of options to pass to the method.
- node - INode
- A node whose the style is going to be changed.
- newStyle - INodeStyle
- The new node style.
onChangingPortLocationModelParameter
(port: IPort, newLocationParameter: IPortLocationModelParameter)Called before the locationParameter of a port is being changed.
Parameters
A map of options to pass to the method.
- port - IPort
- A port whose locationParameter is to be changed.
- newLocationParameter - IPortLocationModelParameter
- The new location model parameter.
Called before a port style is being changed.
Parameters
A map of options to pass to the method.
- port - IPort
- A port whose style is going to be changed.
- newStyle - IPortStyle
- The new port style.
Called before the edge is added to this graph's structure.
Triggers the edge-created event.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that has been created.
Called after a label has been added to an edge.
Remarks
This method triggers the label-added event.
When overriding this method it is mandatory to call the base implementation.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has just been added.
Called after an edge label has been removed from its edge.
Remarks
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The previous owner of the label.
- label - ILabel
- The label that has just been removed.
Called after the ports of an edge have changed.
Remarks
Parameters
A map of options to pass to the method.
Triggers the edge-removed event.
Called after the style of an edge has changed.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge whose style has changed.
- oldStyle - IEdgeStyle
- The edge style before the change.
Called after the tag of an edge has changed.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge whose tag has changed.
- oldTag - any
- The edge tag before the change.
Triggers the graph-tag-changed event.
Parameters
A map of options to pass to the method.
- oldTag - any
- The graph tag before the change.
Triggers the displays-invalidated event.
Parameters
A map of options to pass to the method.
- evt - EventArgs
- The event arguments.
Called after a label model parameter has changed.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose model parameter has changed.
- oldLayoutParameter - ILabelModelParameter
- The label model parameter before the change
Called after the preferred size of a label has changed.
Remarks
Parameters
A map of options to pass to the method.
Called after a label style has changed.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose style has changed.
- oldStyle - ILabelStyle
- The label style before the change.
Called after a label tag has changed.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose tag has changed.
- oldTag - any
- The label tag before the change.
Called after a label text has changed.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label whose text has changed.
- oldText - string
- The label text before the change.
Triggers the node-created event.
Parameters
A map of options to pass to the method.
- node - INode
- The node that has been created.
Called after a label has been added to a node.
Remarks
This method triggers the label-added event.
When overriding this method it is mandatory to call the base implementation.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has just been added.
Called after a label has been removed from its node.
Remarks
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The old owner of the label.
- label - ILabel
- The label that has just been removed.
Called after a node layout has changed.
Remarks
Parameters
A map of options to pass to the method.
Triggers the node-removed event.
Called after a node style has changed.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node whose style has changed.
- oldStyle - INodeStyle
- The node style before the change.
Called after a node tag has changed.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node whose tag has changed.
- oldTag - any
- The node tag before the change.
Called after a label has been added to a port.
Remarks
This method triggers the label-added event.
When overriding this method it is mandatory to call the base implementation.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that has just been added.
Called after a port label has been removed from its port.
Remarks
Parameters
A map of options to pass to the method.
- owner - ILabelOwner
- The old owner of the label.
- label - ILabel
- The label that has just been removed.
Called after a port location model parameter has changed.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- The port whose location model parameter has changed.
- oldLocationParameter - IPortLocationModelParameter
- The port location model parameter before the change.
Called just after a port has been removed from its owner.
Remarks
Parameters
A map of options to pass to the method.
- oldOwner - IPortOwner
- The previous owner of the port.
- port - IPort
- The port that has been removed.
Called after a port style has changed.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- The port whose style has changed.
- oldStyle - IPortStyle
- The port style before the change.
Called after a port tag has changed.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- The port whose tag has changed.
- oldTag - any
- The port tag before the change.
Calculates the number of outgoing edges at the given IPortOwner for this graph.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The port owner to count the outgoing edges of.
Returns
- ↪number
- The number of edges that have the port owner as their source port's owner.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Calculates the number of outgoing edges at the given IPort for this graph.
Returns the outgoing edges at the given owner.
Remarks
This method delegates to edgesAt using OUTGOING.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the outgoing edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- owner - IPortOwner
- The owner of the edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumerable for the edges.
Throws
- Exception({ name: 'ArgumentError' })
owner
is not in this graph.
See Also
Defined in
Returns the outgoing edges at the given port.
Remarks
This method delegates to edgesAt using OUTGOING.
Note that even though edges can be accessed via index, the underlying graph structure in the default IGraph implementation is a linked list and indexed access can be slow. In those cases it is recommended to store the edges in your own list, if possible. This is not necessary for the first or last element or when iterating over the outgoing edges via a foreach
loop.
Parameters
A map of options to pass to the method.
- port - IPort
- The owner of the edges.
Returns
- ↪IListEnumerable<IEdge>
- An enumerable for the edges.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.
See Also
Defined in
Enumerates the predecessors of a given INode.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node.
Returns
- ↪IEnumerable<INode>
- An enumerable over all predecessors.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.
Defined in
Removes the given item from this graph.
Remarks
The item must be a part of this graph.
If the item is a node, the node-removed event will be triggered. This will remove all adjacent edges and their corresponding ports in proper order before the node will be removed. Also, this will trigger the removal of all labels owned by this instance.
If the item is an edge, the edge-removed event will be triggered. Also, this will trigger the removal of all labels and bends owned by this instance. An implementation may decide to remove the corresponding ports from the node if no other edge connects to them after the given edge has been removed. The implementations provided by yFiles do so according to the value set to autoCleanUp in their IPortDefaults.
If the item is a bend, the bend-removed event will be triggered.
If the item is a port, the port-removed event will be triggered. This will also remove all edges that are currently connected to the port and all labels and bends owned by this instance.
If the item is a label, the label-removed event will be triggered.
Parameters
A map of options to pass to the method.
- item - IModelItem
- the item to be removed from this graph instance
Throws
- Exception({ name: 'ArgumentError' })
item
is not in this graph.
Implements
Removes a previously added lookup chain element from the lookup of this
.
Parameters
A map of options to pass to the method.
- lookup - IContextLookupChainLink
- The element to remove.
Reverses an edge by setting source and target port to targetPort and sourcePort.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to reverse.
Throws
- Exception({ name: 'ArgumentError' })
edge
is not in this graph.
See Also
Defined in
Modifies the location of the given bend.
Remarks
Parameters
A map of options to pass to the method.
- bend - IBend
- the bend whose location is to be modified
- location - Point
- the new coordinates of the bend
Throws
- Exception({ name: 'ArgumentError' })
- If
bend
is not in this graph.
See Also
Implements
Sets the ports of the given edge to the new values.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to change the ports.
- sourcePort - IPort
- The new source port instance.
- targetPort - IPort
- The new target port instance.
Throws
- Exception({ name: 'ArgumentError' })
- Either
edge
,sourcePort
, ortargetPort
are not in this graph.
See Also
Implements
Changes whether the given node is a group node or not.
Remarks
Group nodes are nodes which can have children. They may not necessarily have to, however.
Attempting to set a node to the non-group-node-status while it has children at the same time will result in an InvalidOperationError.
Parameters
A map of options to pass to the method.
- node - INode
- The node to set the group node status for.
- isGroupNode - boolean
- Whether to make the node a group node.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.- Exception({ name: 'InvalidOperationError' })
node
isnull
or currently has children andisGroupNode
isfalse
.
See Also
Implements
Sets the label model parameter for the given label.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label.
- layoutParameter - ILabelModelParameter
- The new parameter.
Throws
- Exception({ name: 'ArgumentError' })
label
is not in this graph, orlayoutParameter
cannot be used forlabel
.
See Also
Implements
Sets the preferred size of the label.
Remarks
Parameters
A map of options to pass to the method.
Throws
- Exception({ name: 'ArgumentError' })
label
is not in this graph orpreferredSize
contains one or more NaN values.
See Also
Implements
Sets the label text of the given label.
Remarks
Parameters
A map of options to pass to the method.
- label - ILabel
- The label to modify
- text - string
- The new text of the label
Throws
- Exception({ name: 'ArgumentError' })
- If
label
is not in this graph. - Exception({ name: 'ArgumentError' })
- If
text
isnull
.
See Also
Implements
Sets the center of a node to the given world coordinates.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node to recenter.
- center - Point
- The new center coordinates of the node in the world coordinate system.
Throws
- Exception({ name: 'ArgumentError' })
center
contains one or more NaN values.
See Also
Defined in
Sets the layout of the given node to the new values.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- a live node that belongs to this graph
- layout - Rect
- the new absolute layout in world coordinates of the node
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph, orlayout
contains one or more NaN values.
See Also
Implements
Sets the parent node for a given node.
Remarks
Use null
as parent
to make node
a top-level node for this graph.
This method does not move or enlarge the parent
to enclose its new node
. Developers have to take care to adjust the node layout after grouping, e.g. by calling adjustGroupNodeLayout.
If parent
is not a group node before the call it will be converted into one.
To query the parent of a node, use getParent.
Parameters
A map of options to pass to the method.
- node - INode
- The node to assign a new parent.
- parent - INode
- The parent group node to assign to
node
ornull
to makenode
a top-level node.
Throws
- Exception({ name: 'ArgumentError' })
- Either
node
orparent
is not in this graph.
See Also
Implements
Tries to set the absolute coordinates of the given port to the given values.
Remarks
Parameters
A map of options to pass to the method.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.- Exception({ name: 'ArgumentError' })
location
contains one or more NaN values.
See Also
Defined in
Sets a new IPortLocationModelParameter for the given port.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- The port to modify
- locationParameter - IPortLocationModelParameter
- The new parameter that determines the coordinates of the port
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph, orlocationParameter
cannot be used forport
.
See Also
Implements
Tries to set the location of the port relative to its owner if the owner is a node.
Remarks
Parameters
A map of options to pass to the method.
- port - IPort
- the port
- relativeLocation - Point
- the new coordinate offsets relative to the center of the node's layout's center.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph or has no owner.- Exception({ name: 'ArgumentError' })
relativeLocation
contains one or more NaN values.
See Also
Defined in
Assigns the given style instance by reference to the node.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node that will be assigned the new style
- style - INodeStyle
- The style instance that will be assigned to the node.
Throws
- Exception({ name: 'ArgumentError' })
- If
node
is not in this graph. - Exception({ name: 'ArgumentError' })
- If
style
isnull
.
See Also
Implements
Assigns the given style instance by reference to the label.
Remarks
Style instances can be shared.
This implementation will adjust the preferred size for the label if autoAdjustPreferredSize is enabled.
Parameters
A map of options to pass to the method.
- label - ILabel
- The label that will be assigned the new style
- style - ILabelStyle
- The style instance that will be assigned to the label.
Throws
- Exception({ name: 'ArgumentError' })
- If
label
is not in this graph. - Exception({ name: 'ArgumentError' })
- If
style
isnull
.
See Also
Implements
Assigns the given style instance by reference to the edge.
Remarks
Style instances can be shared.
To query the edge style, use style.
Styles are automatically converted between WebGL and SVG rendering modes. Due to differences in feature sets, conversion may not be exact. For better control, apply styles specific to the rendering mode or use a WebGLEdgeStyleDecorator style when switching render modes.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge that will be assigned the new style
- style - IEdgeStyle
- The style instance that will be assigned to the edge.
Throws
- Exception({ name: 'ArgumentError' })
edge
is not in this graph.
See Also
Implements
Assigns the given style instance by reference to the port.
Remarks
Style instances can be shared.
To query the port style, use style.
Parameters
A map of options to pass to the method.
- port - IPort
- The port that will be assigned the new style
- style - IPortStyle
- The style instance that will be assigned to the port.
Throws
- Exception({ name: 'ArgumentError' })
port
is not in this graph.
See Also
Implements
Enumerates the successors of a given INode.
Remarks
Parameters
A map of options to pass to the method.
- node - INode
- The node.
Returns
- ↪IEnumerable<INode>
- An enumerable over all successors.
Throws
- Exception({ name: 'ArgumentError' })
node
is not in this graph.
Defined in
Events
Occurs when a bend has been added to an edge in this graph.
Remarks
See Also
Overrides
Occurs when the location of a bend has been changed.
Remarks
See Also
Overrides
Occurs when a bend has been removed from an edge in this graph.
Remarks
This event will be triggered, too, if an edge has been removed from the graph, for each of the bends that belonged to the edge.
This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in bend removal events that result from user interaction.
See Also
Overrides
Occurs when the tag of a bend has been replaced.
Remarks
See Also
Overrides
Occurs when the graph has changed visually and the display should be updated to reflect the changes.
Occurs when an edge has been created.
Remarks
See Also
Overrides
Occurs when an edge had its sourcePort or targetPort changed.
Remarks
See Also
Overrides
Occurs when an edge has been removed.
Remarks
This event will be triggered, too, prior to a node removal.
This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in edge removal events that result from user interaction.
See Also
Overrides
Occurs when an edge style has been replaced.
Remarks
See Also
Overrides
Occurs when the tag of an edge has been replaced.
Remarks
See Also
Overrides
Occurs when the tag of the graph has been replaced.
Remarks
See Also
Overrides
Occurs if the group node status of a node has changed.
Overrides
Occurs when a label has been added to this graph instance.
Remarks
See Also
Overrides
'label-layout-parameter-changed'
: function(ItemChangedEventArgs<ILabel,ILabelModelParameter>, this):voidOccurs when the model parameter of a label has been changed.
Remarks
See Also
Overrides
Occurs when the preferred size of a label has been changed.
Remarks
See Also
Overrides
Occurs when a label has been removed from this graph instance.
Remarks
This event will also be triggered, prior to the removal of the owner of the label.
This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in label removal events that result from user interaction.
See Also
Overrides
Occurs when a label style has been replaced.
Remarks
See Also
Overrides
Occurs when the tag of a label has been replaced.
Remarks
See Also
Overrides
Occurs when the text of a label has been changed.
Remarks
See Also
Overrides
Occurs when a node has been created.
Remarks
See Also
Overrides
Occurs when a node layout has been changed.
Remarks
See Also
Overrides
Occurs when a node has been removed.
Remarks
See Also
Overrides
Occurs when a node style has been replaced.
Remarks
See Also
Overrides
Occurs when the tag of a node has been replaced.
Remarks
See Also
Overrides
Occurs if a node has been reparented in the model.
Overrides
Occurs when a port has been added to this graph instance.
Remarks
See Also
Overrides
'port-location-parameter-changed'
: function(ItemChangedEventArgs<IPort,IPortLocationModelParameter>, this):voidOccurs when the location model parameter of a port has been changed.
Remarks
See Also
Overrides
Occurs when a port has been removed from its owner.
Remarks
This event will also be triggered prior to the removal of the corresponding owner of the port.
This event is intended to provide notification of low level changes in the graph structure. Please use the deleted-item event if you are interested only in port removal events that result from user interaction.
See Also
Overrides
Occurs when a port style has been replaced.
Remarks
See Also
Overrides
Occurs when the tag of a port has been replaced.
Remarks
See Also
Overrides
Constants
Gets an IContextLookup that provides the default implementations returned by an IBend's lookup.
Remarks
Gets an IContextLookup that provides the default implementations returned by an IEdge's lookup.
Remarks
Gets an IContextLookup that provides the default implementations returned by an ILabel's lookup.
Remarks
Gets an IContextLookup that provides the default implementations returned by an INode's lookup.
Remarks
Gets an IContextLookup that provides the default implementations returned by an IPort's lookup.