Specifies custom data for the EdgeRouter.
Examples
The following example shows how to create a new instance of EdgeRouterData and use it with an EdgeRouter:
In many cases the complete initialization of EdgeRouterData can also be done in a single object initializer:
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.router.EdgeRouterData
See Also
Constructors
Creates a new instance of EdgeRouterData which helps configuring EdgeRouter.
Parameters
A map of options to pass to the method.
- affectedEdges - DpKeyItemCollection<IEdge>
The collection of affected edges. This option sets the affectedEdges property on the created object.
- affectedNodes - DpKeyItemCollection<INode>
The collection of affected nodes. This option sets the affectedNodes property on the created object.
- ignoredLabels - ItemCollection<ILabel>
The collection of labels of nodes or fixed edges that are ignored by the router. This option sets the ignoredLabels property on the created object.
- edgeLayoutDescriptors - ItemMapping<IEdge,EdgeRouterEdgeLayoutDescriptor>
The mapping of edges to their EdgeRouterEdgeLayoutDescriptor This option sets the edgeLayoutDescriptors property on the created object.
- labelCrossingPenaltyFactors - ItemMapping<ILabel,number>
A mapping from labels to a crossing penalty factor. This option sets the labelCrossingPenaltyFactors property on the created object.
- nodeHalos - ItemMapping<INode,NodeHalo>
- sourcePortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their source PortConstraint. This option sets the sourcePortConstraints property on the created object.
- targetPortConstraints - ItemMapping<IEdge,PortConstraint>
A mapping from edges to their target PortConstraint. This option sets the targetPortConstraints property on the created object.
- sourcePortCandidates - ItemMapping<IEdge,ICollection<PortCandidate>>
A mapping from edges to a collection of their source port candidates. This option sets the sourcePortCandidates property on the created object.
- targetPortCandidates - ItemMapping<IEdge,ICollection<PortCandidate>>
A mapping from edges to a collection of their target port candidates. This option sets the targetPortCandidates property on the created object.
- nodePortCandidateSets - ItemMapping<INode,PortCandidateSet>
A mapping from nodes to their PortCandidateSet. This option sets the nodePortCandidateSets property on the created object.
- sourceGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their source edge group. This option sets the sourceGroupIds property on the created object.
- sourcePortGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their source port group. This option sets the sourcePortGroupIds property on the created object.
- targetGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their target edge group. This option sets the targetGroupIds property on the created object.
- targetPortGroupIds - ItemMapping<IEdge,Object>
A mapping from edges to an object representing their target port group. This option sets the targetPortGroupIds property on the created object.
- buses - ItemCollectionMapping<IEdge,EdgeRouterBusDescriptor>
The mapping from edges to their bus descriptor. This option sets the buses property on the created object.
- abortHandler - AbortHandler
The AbortHandler used during the layout. This option sets the abortHandler property on the created object.
- partitionGridData - PartitionGridData
The partition grid layout data. This option sets the partitionGridData property on the created object.
- edgeLabelPreferredPlacement - ItemMapping<ILabel,PreferredPlacementDescriptor>
The mapping that provides a PreferredPlacementDescriptor instance for edge ILabels. This option sets the edgeLabelPreferredPlacement property on the created object.
Properties
Gets or sets the AbortHandler used during the layout.
Remarks
An AbortHandler can be used to gracefully stop or cancel a running layout and offers options for automatically doing so after a predetermined time.
An AbortHandler configured or set here overrides the one on LayoutExecutor.
Examples
The most common use case would be to just configure the AbortHandler here, e.g. to set timeouts for a graceful stop or canceling the running layout:
layoutData.abortHandler.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler.cancelDuration = TimeSpan.fromSeconds(30)
layoutData.abortHandler!.stopDuration = TimeSpan.fromSeconds(10) layoutData.abortHandler!.cancelDuration = TimeSpan.fromSeconds(30)
If there's already an AbortHandler instance that's pre-configured or will be used in a different place to, e.g., cancel the layout when the user presses a button, you can also set one explicitly:
layoutData.abortHandler = abortHandler
See Also
Gets or sets the collection of affected edges.
Remarks
Examples
Defining the subset of edges that should be laid out can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
Alternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
A powerful option that doesn't use a collection is to use the delegate to set a custom delegate that returns for every edge whether it is contained in the set or not:
See Also
Gets or sets the collection of affected nodes.
Remarks
Examples
Defining the subset of nodes that should be laid out can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
Alternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
A powerful option that doesn't use a collection is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
See Also
Gets or sets the mapping from edges to their bus descriptor.
Remarks
All edges associated to the same bus descriptor are routed in a bus-like style, sharing a common backbone. A bus consist of segments that are shared by multiple edges to which shorter segments that connect to the actual nodes are attached to. Observe that using such a bus representation with multiple edges drawn on top of each other, information like the individual edge direction might be occluded. Bus routing can, for example, be very useful in parts of a diagram where each node is connected to each other node.
The EdgeRouterBusDescriptor instance allows to configure the bus formed by the associated edges. To conveniently define buses use the add method of this property. It takes the bus descriptor as parameter and allows to define the edges associated to the bus using the returned ItemCollection<TItem>.
Examples
// create a bus descriptor and, optionally, configure it
const busDescriptor = new EdgeRouterBusDescriptor({
minimumBackboneSegmentLength: 200
})
// retrieve an ItemCollection which defines the edges that should belong to the bus
const busEdgesCollection = edgeRouterData.buses.add(busDescriptor)
// busEdgesList is an ICollection which contains all edges that should be part of the bus
busEdgesCollection.items = busEdgesList
See Also
Gets or sets the mapping that provides a PreferredPlacementDescriptor instance for edge ILabels.
Examples
Depending on how much customization is needed, some ways of setting PreferredPlacementDescriptors are more convenient than others. For example, to set the same descriptor for all labels, you can just use the constant property:
If some labels should use custom placement or this has to be configured ahead of time, you can use the mapper instead:
When the preferred placement can be inferred from the label itself, a delegate is usually the easiest choice:
Note that the preferred placement can also be inferred from an arbitrary ILabelModelParameter:
See Also
Gets or sets the mapping of edges to their EdgeRouterEdgeLayoutDescriptor
Gets or sets the collection of labels of nodes or fixed edges that are ignored by the router.
Examples
Defining the subset of labels that should be ignored can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any .NET collection or IEnumerable<T>:
Alternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list and setting it to source:
A powerful option that doesn't use a collection is to use the delegate to set a custom delegate that returns for every label whether it should be ignored or not:
See Also
Gets or sets a mapping from labels to a crossing penalty factor.
Remarks
Examples
See Also
Gets or sets the mapping from nodes to their NodeHalo.
Remarks
Examples
The easiest option is to reserve the same space around all nodes, by setting a constant NodeHalo:
Handling only certain nodes differently can be done easily by using the mapper property:
In cases where the NodeHalo for each node can be determined by looking at the node itself it's often easier to just set a delegate instead of preparing a mapper:
See Also
Gets or sets a mapping from nodes to their PortCandidateSet.
Remarks
Examples
The simplest way to define node port candidate sets is to use the same PortCandidateSet for all nodes, if suitable for the use case:
The same effect can be achieved with a delegate as well, however, a more useful way to use a delegate would be to decide whether a node should get a port candidate set based on some data at the node, e.g., found in its tag:
If specific nodes should get a certain PortCandidateSet, it may sometimes be easier to use the mapper to set them:
See Also
Gets or sets the partition grid layout data.
See Also
Gets or sets a mapping from edges to an object representing their source edge group.
Remarks
Examples
One simple way to use source groups is to use the edge's source node as group ID which effectively groups all edges with the same source together:
Another useful way to use a delegate here would be grouping edges by some commonality, such as the same color:
If only certain edges should be grouped it may sometimes be easier to use the mapper to set the group IDs:
See Also
Gets or sets a mapping from edges to a collection of their source port candidates.
Remarks
Port constraints allow to define where an edge can connect to its source node and allow fine control over port placement.
If all that is needed is to fix the source port in its location or on a node side, port constraints are easier to work with, since they are a slightly simpler concept.
Examples
Source port candidates are effectively a collection of possible port placements with different costs and the layout algorithm is free to choose the candidate that fits best into the overall layout, while also preferring candidates with a lower cost. To set the same candidate list for all edges, it's easiest to use the constant property:
If certain edges need specific port candidates, it's usually convenient to use the mapper property:
For cases when the desired configuration of port candidates can be readily created from the edge itself, the delegate is often the most convenient option:
See Also
Sample Graphs
Gets or sets a mapping from edges to their source PortConstraint.
Remarks
Port constraints allow to define where an edge attaches to its source node and can either restrict that to one of the node's sides, or to a fixed port position.
A more general concept which allows finer control over where ports are placed, are port candidates.
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets a mapping from edges to an object representing their source port group.
Remarks
Examples
The simplest way to use source port groups is to use the same object as group ID for all edges. Since grouping is done per node, this has the effect of grouping all edges with the same source node together:
The same effect can be achieved with a delegate as well, by returning the source node as group ID for each edge. However, a more useful way to use a delegate here would be grouping edges by some commonality, such as the same color:
If only certain edges should be grouped it may sometimes be easier to use the mapper to set the group IDs:
See Also
Gets or sets a mapping from edges to an object representing their target edge group.
Remarks
Examples
One simple way to use source groups is to use the edge's target node as group ID which effectively groups all edges with the same target together:
Another useful way to use a delegate here would be grouping edges by some commonality, such as the same color:
If only certain edges should be grouped it may sometimes be easier to use the mapper to set the group IDs:
See Also
Gets or sets a mapping from edges to a collection of their target port candidates.
Remarks
Port constraints allow to define where an edge can connect to its target node and allow fine control over port placement.
If all that is needed is to fix the target port in its location or on a node side, port constraints are easier to work with, since they are a slightly simpler concept.
Examples
Target port candidates are effectively a collection of possible port placements with different costs and the layout algorithm is free to choose the candidate that fits best into the overall layout, while also preferring candidates with a lower cost. To set the same candidate list for all edges, it's easiest to use the constant property:
If certain edges need specific port candidates, it's usually convenient to use the mapper property:
For cases when the desired configuration of port candidates can be readily created from the edge itself, the delegate is often the most convenient option:
See Also
Sample Graphs
Gets or sets a mapping from edges to their target PortConstraint.
Remarks
Port constraints allow to define where an edge attaches to its target node and can either restrict that to one of the node's sides, or to a fixed port position.
A more general concept which allows finer control over where ports are placed, are port candidates.
Examples
If all edges should exit their source node on the same side, you can simply set a constant constraint for all edges:
To change the constraints for individual edges, it's usually easiest to use the mapper:
If a PortConstraint can readily be created from an edge, using a delegate is often easier:
See Also
Sample Graphs
Gets or sets a mapping from edges to an object representing their target port group.
Remarks
Examples
The simplest way to use target port groups is to use the same object as group ID for all edges. Since grouping is done per node, this has the effect of grouping all edges with the same target node together:
The same effect can be achieved with a delegate as well, by returning the target node as group ID for each edge. However, a more useful way to use a delegate here would be grouping edges by some commonality, such as the same color:
If only certain edges should be grouped it may sometimes be easier to use the mapper to set the group IDs:
See Also
Methods
Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData
- The LayoutData to combine this instance with.
Returns
- ↪LayoutData
- The combined layout data.