This custom data provides several ways to modify the scope of the EdgeRouter with regard to the routed edges.
Remarks
The routed edges can be specified using the ItemCollection properties edges and incidentNodes. Any edges, or edges incident to the nodes in those collections, are considered to be in scope by the EdgeRouter. The Item Mapping properties edgeMapping and incidentNodeMapping can be used to specify a more differentiated EdgeRouterScope for (incident) edges.
When multiple scope properties are specified for the same edge, the most permissive property is prioritized, meaning PATH is always prioritized over PATH_AS_NEEDED, which is more permissive than SEGMENTS_AS_NEEDED. IGNORE is assigned to an edge if and only if no other property is specified.
This class cannot be instantiated
Type Parameters
- TNode
- TEdge
- TNodeLabel
- TEdgeLabel
Type Details
- yFiles module
- algorithms
Properties
Gets or sets a mapping from edges to a value describing the edges' behavior with respect to the scope.
Examples
Specifying a constant scope policy for all edges is the simplest option:
scopeData.edgeMapping = EdgeRouterScope.PATH_AS_NEEDED
Additionally, specifying different policies for affected edges can be accomplished by using the mapper property to set an existing mapping from edges to policies:
scopeData.edgeMapping = scopePolicyMapper
Finally, in cases where the scope policy can be determined by looking at the edge itself it's often easier to set a delegate instead of preparing a mapper:
scopeData.edgeMapping = (edge) => {
if (edge === edge1) {
//edge1 is always routed
return EdgeRouterScope.PATH
}
if (edge === edge2) {
//edge2 is only routed if necessary
return EdgeRouterScope.PATH_AS_NEEDED
}
if (edge === edge3) {
//only segments of edge3 are routed if necessary
return EdgeRouterScope.SEGMENTS_AS_NEEDED
}
//other edges are not affected
return EdgeRouterScope.IGNORE
}
A collection of edges that should be considered to be in scope, that is, routed by EdgeRouter.
Examples
The affected edges can be specified using the items property when only a few known edges should be affected:
scopeData.edges.items.add(edge1)
scopeData.edges.items.add(edge2)
It's also possible to pass an existing collection of affected edges:
scopeData.edges = graphComponent.selection.edges
In cases where looking at the edge itself is sufficient to determine whether an edge is in scope, it's often easier to just set a delegate instead:
// We assume here that all edges have a CustomData instance as their tag,
// which then has a boolean property 'IncludeInLayout'.
scopeData.edges = (edge) => (edge.tag as CustomData).includeInLayout
Gets or sets a mapping from nodes to a value describing their incident edges with respect to the scope.
Examples
Specifying a constant scope policy for all edges is the simplest option:
scopeData.incidentNodeMapping = EdgeRouterScope.PATH_AS_NEEDED
Additionally, specifying different policies for edges incident to affected nodes can be accomplished by using the mapper property to set an existing mapping from nodes to policies:
scopeData.incidentNodeMapping = scopePolicyMapper
Finally, in cases where the scope policy can be determined by looking at the node itself it's often easier to set a delegate instead of preparing a mapper:
scopeData.incidentNodeMapping = (node: INode) => {
if (node == node1) {
//edges incident to node1 are always routed
return EdgeRouterScope.PATH
}
if (node == node2) {
//edges incident to node2 are only routed if necessary
return EdgeRouterScope.PATH_AS_NEEDED
}
if (node == node3) {
//only segments of edges incident to node3 are routed if necessary
return EdgeRouterScope.SEGMENTS_AS_NEEDED
}
//edges incident to other nodes are not affected
return EdgeRouterScope.IGNORE
}
A collection of nodes whose incident edges should be considered in scope, that is, routed by EdgeRouter.
Examples
The incident nodes can be specified using the items property when only the edges of a few known nodes should be affected:
scopeData.incidentNodes.items.add(node1)
scopeData.incidentNodes.items.add(node2)
It's also possible to pass an existing collection of incident nodes:
scopeData.incidentNodes = graphComponent.selection.nodes
In cases where looking at the node itself is sufficient to determine whether its incident edges are in scope, it's often easier to just set a delegate instead:
// We assume here that all nodes have a CustomData instance as their tag,
// which then has a boolean property 'IncludeInLayout'.
scopeData.incidentNodes = (node) =>
(node.tag as CustomData).includeInLayout
Methods
combineWith
(data: LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>…) : LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> to combine this instance with.
Returns
- ↪LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The combined layout data.