Adapter class that can be used to obtain a layoutGraph from an IGraph.
Remarks
Typically, this class is not used directly but through the LayoutExecutor or applyLayout and applyLayoutAnimated.
In addition, this class supports IGraphs with edge to edge connections, i.e., edges that are adjacent to other edges. Since such edges are not allowed in a layoutGraph, the property hideEdgesAtEdges specifies whether these edges shouldn't be converted into the layout graph at all or converted into a corresponding structure with helper nodes.
Related Reading in the Developer's Guide
Type Details
- yFiles module
- view-layout-bridge
Constructors
Properties
Gets or sets a comparison function that normalizes the order of the edges for the layout calculation to ensure the same order for multiple layout invocations.
Remarks
Among other factors, the results produced by layout algorithms usually depend on the order of the nodes and edges within a graph. Unfortunately, useful operations such as hiding or unhiding elements from a graph or simply invoking layout algorithms on a graph will have the potential side effect of changing that order.
With this comparison it is possible to establish a predefined order of edges within a graph to avoid non-deterministic layout behavior.
Signature Details
function(x: IEdge, y: IEdge) : number
Parameters
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
See Also
Gets or sets the size of the nodes that are inserted for the ports that are created for IEdges that are connected at other IEdges.
Remarks
3x3
.See Also
Gets or sets a value that controls whether edges at other edges will be hidden from the layout graph or included.
Gets or sets a mapping that specifies how ILabels should be placed by the layout algorithm.
Remarks
This setting only affects layout algorithms which support label placement. Also, if EdgeLabelPreferredPlacements are already defined for a label, all values other than KEEP_PARAMETER are ignored for that label.
Default is PREFER_MODEL.
See Also
Gets the layoutGraph instance.
Remarks
Gets or sets a comparison function that normalizes the order of the nodes for the layout calculation to ensure the same order for multiple layout invocations.
Remarks
Among other factors, the results produced by layout algorithms usually depend on the order of the nodes and edges within a graph. Unfortunately, useful operations such as hiding or unhiding elements from a graph or simply invoking layout algorithms on a graph will have the potential side effect of changing that order.
With this comparison it is possible to establish a predefined order of nodes within a graph to avoid non-deterministic layout behavior.
Signature Details
function(x: INode, y: INode) : number
Parameters
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
See Also
Gets or sets the mapping from ports to a policy that specifies how port locations should be adjusted after a layout has been calculated.
Remarks
This can be useful if the port assignment calculated by the layout algorithm is insufficient.
Layout algorithms only consider rectangular nodes even though the actual shape of a node is, for example, circular. Hence, the ports are usually placed at the border of the nodes' bounds (except for some layout algorithms that produce straight-line edge routes and place the ports at the nodes' center).
Based on this setting the edges will be shortened or lengthened in a way that their sourcePorts and targetPorts will be placed on the node's outline.
The default is a constant ItemMapping<TItem,TValue> returning LENGTHEN for all ports.
See Also
Gets or sets how ILabels at IPorts (owned by an INode) should be treated by the layout algorithm.
Remarks
See Also
Gets or sets a mapping that specifies how IPorts should be placed by the layout algorithm.
Remarks
This setting only affects layout algorithms which support PortCandidates. Also, if PortCandidates are already defined for an edge, they override the current port positions.
Default is PREFER_MODEL.
See Also
Methods
Registers a single value data for the adapted layout graph with the specified ValueDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a context layer before and remove it afterward.Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - ValueDataKey<T>
- The ValueDataKey<TValue> the data should be registered for.
- value - T
- The data to register.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<T>
- The NodeDataKey<TValue> the data should be registered for.
- provider - IMapper<INode,T>
- The data to be registered at the graph.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<T>
- The EdgeDataKey<TValue> the data should be registered for.
- provider - IMapper<IEdge,T>
- The data to be registered at the graph.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<T>
- The NodeLabelDataKey<TValue> the data should be registered for.
- provider - IMapper<ILabel,T>
- The data to be registered at the graph.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
Remarks
dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<T>
- The EdgeLabelDataKey<TValue> the data should be registered for.
- provider - IMapper<ILabel,T>
- The data to be registered at the graph.
addItemData
<T>(dataKey: NodeDataKey<T>, getter: function(INode):T, setter?: function(INode, T):void)Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeDataKey<T>
- The NodeDataKey<TValue> the data should be registered for.
- getter - function(INode):T
- A callback to get the data for an edge in the created mapper.
- setter - function(INode, T):void
- A callback to set the data for an edge in the created mapper.
Signature Details
function(key: INode, value: T)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - INode
- The key of the mapping.
- value - T
- The new value of the mapping.
addItemData
<T>(dataKey: EdgeDataKey<T>, getter: function(IEdge):T, setter?: function(IEdge, T):void)Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeDataKey<T>
- The EdgeDataKey<TValue> the data should be registered for.
- getter - function(IEdge):T
- A callback to get the data for an edge in the created mapper.
- setter - function(IEdge, T):void
- A callback to set the data for an edge in the created mapper.
Signature Details
function(key: IEdge, value: T)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - IEdge
- The key of the mapping.
- value - T
- The new value of the mapping.
addItemData
<T>(dataKey: NodeLabelDataKey<T>, getter: function(ILabel):T, setter?: function(ILabel, T):void)Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - NodeLabelDataKey<T>
- The NodeLabelDataKey<TValue> the data should be registered for.
- getter - function(ILabel):T
- A callback to get the data for an edge in the created mapper.
- setter - function(ILabel, T):void
- A callback to set the data for an edge in the created mapper.
Signature Details
function(key: ILabel, value: T)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - ILabel
- The key of the mapping.
- value - T
- The new value of the mapping.
addItemData
<T>(dataKey: EdgeLabelDataKey<T>, getter: function(ILabel):T, setter?: function(ILabel, T):void)Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.
Remarks
The IMapper<K,V> is created from the given getter
and optional setter
callbacks.
If an IMapper<K,V> is already registered with the same dataKey
, it will be replaced. To only temporarily replace an existing value, you should add a layer before and remove it afterward.
Type Parameters
- T
- The type of the data to register.
Parameters
A map of options to pass to the method.
- dataKey - EdgeLabelDataKey<T>
- The EdgeLabelDataKey<TValue> the data should be registered for.
- getter - function(ILabel):T
- A callback to get the data for an edge in the created mapper.
- setter - function(ILabel, T):void
- A callback to set the data for an edge in the created mapper.
Signature Details
function(key: ILabel, value: T)
A delegate that mimics IMapper<K,V>'s indexer write-access.Parameters
- key - ILabel
- The key of the mapping.
- value - T
- The new value of the mapping.
Applies an ILayoutAlgorithm to an IGraph, optionally applying some LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>.
Parameters
A map of options to pass to the method.
- layout - ILayoutAlgorithm
- The layout algorithm to apply.
- layoutData - LayoutData<INode,IEdge,ILabel,ILabel>
- The layout data.
Helper method that applies a given LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> for IGraph elements onto the layoutGraph using the mapping between the elements established by this instance.
Remarks
Parameters
A map of options to pass to the method.
- layoutData - LayoutData<INode,IEdge,ILabel,ILabel>
- The data to apply to the layoutGraph
Sets the layout information of all graph items of the originalGraph to the current values of the corresponding items in the layoutGraph.
Remarks
Creates a copy of an IEdgeStyle instance that is used during the layout for path calculations and the like.
Remarks
style
for the following IEdgeStyle implementations: PolylineEdgeStyle, ArcEdgeStyle, BezierEdgeStyle, and VOID_EDGE_STYLE. All other style implementations are replaced by instances of PolylineEdgeStyle. If you use a custom style where the edge path calculation depends on the style, you should overwrite this method and create a copy of your style instance.Parameters
A map of options to pass to the method.
- style - IEdgeStyle
- The style to copy.
Returns
- ↪IEdgeStyle
- A replacement of
style
that is used during layout calculation.
Creates a copy of an INodeStyle instance that is used during the layout.
Remarks
style
for the following INodeStyle implementations: ShapeNodeStyle, GeneralPathNodeStyle, RectangleNodeStyle, ArrowNodeStyle, and GroupNodeStyle. All other style implementations are replaced by instances of ShapeNodeStyle. If you use a custom style where the layout calculation depends on the style, you should overwrite this method and create a copy of your style instance.Parameters
A map of options to pass to the method.
- style - INodeStyle
- The style to copy.
Returns
- ↪INodeStyle
- A replacement of
style
that is used during layout calculation.
createEdgeLabelCandidate
(originalLabel: ILabel, helperLabel: ILabel, layoutParameter: ILabelModelParameter, edgeLabel: LayoutEdgeLabel) : LabelCandidateCreates the LabelCandidate for a given label and ILabelModelParameter combination.
Parameters
A map of options to pass to the method.
- originalLabel - ILabel
- The original label.
- helperLabel - ILabel
- The helper label that describes the current laid out label.
- layoutParameter - ILabelModelParameter
- The parameter to create a candidate for.
- edgeLabel - LayoutEdgeLabel
- The LayoutEdgeLabel of the label to pass to the candidate.
Returns
- ↪LabelCandidate?
- A candidate to yield for the labeling algorithms or
null
.
createNodeLabelCandidate
(originalLabel: ILabel, helperLabel: ILabel, layoutParameter: ILabelModelParameter, ownerLayout: LayoutNodeLabel) : LabelCandidateCreates a LabelCandidate for a given label and ILabelModelParameter combination.
Parameters
A map of options to pass to the method.
- originalLabel - ILabel
- The original label.
- helperLabel - ILabel
- The helper label that describes the current laid out label.
- layoutParameter - ILabelModelParameter
- The parameter to create a candidate for.
- ownerLayout - LayoutNodeLabel
- The LayoutNodeLabel of the label to pass to the candidate.
Returns
- ↪LabelCandidate?
- A candidate to yield for the labeling algorithms or
null
.
Returns the layout graph edge that corresponds to the given original edge.
Parameters
A map of options to pass to the method.
- edge - IEdge
- an edge of the originalGraph whose copy resides in the layoutGraph
Returns
- ↪LayoutEdge?
- an edge in the layoutGraph that is the copy of the given original edge
Returns the layout graph edge label that corresponds to the given original label.
Parameters
A map of options to pass to the method.
- label - ILabel
- an edge label of the originalGraph whose copy resides in the layoutGraph
Returns
- ↪LayoutEdgeLabel?
- an edge label in the layoutGraph that is the copy of the given original label
Returns the layout graph node that corresponds to the given original node.
Parameters
A map of options to pass to the method.
- node - INode
- a node of the originalGraph whose copy resides in the layoutGraph
Returns
- ↪LayoutNode?
- a node in the layoutGraph that is the copy of the given original node
Returns the temporary node that represents the given original port.
Parameters
A map of options to pass to the method.
- port - IPort
- an edge port of the originalGraph whose representing node resides in the layoutGraph
Returns
- ↪LayoutNode?
- a node in the layoutGraph that represents the given original port
Returns the layout graph node label that corresponds to the given original label.
Parameters
A map of options to pass to the method.
- label - ILabel
- A node label of the originalGraph whose copy resides in the layoutGraph
Returns
- ↪LayoutNodeLabel?
- A node label in the layoutGraph that is the copy of the given original label
Returns the original edge that corresponds to the given layout graph edge.
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- the edge in the layoutGraph that is a copy of the returned edge
Returns
- ↪IEdge?
- the edge in the originalGraph whose copy is the given edge
Returns the original node label that corresponds to the given layout graph label.
Parameters
A map of options to pass to the method.
- label - LayoutNodeLabel
- the label in the layoutGraph that is a copy of the returned label
Returns
- ↪ILabel?
- the node label in the originalGraph whose copy is the given label
Returns the original edge label that corresponds to the given layout graph label.
Parameters
A map of options to pass to the method.
- label - LayoutEdgeLabel
- the label in the layoutGraph that is a copy of the returned edge label
Returns
- ↪ILabel?
- the edge label in the originalGraph whose copy is the given label
Returns the original node that corresponds to the given layout graph node.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- the node in the layoutGraph that is a copy of the returned node
Returns
- ↪INode?
- the node in the originalGraph whose copy is the given node
Returns the original port that corresponds to the given temporary node.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- the node in the layoutGraph that represents the returned port.
Returns
- ↪IPort?
- the port in the originalGraph whose represent is the given node
Initializes the layoutGraph instance by taking the current state of the originalGraph and the settings of this adapter.
Callback method that assigns a new location that matches newLocation
to the edge port
.
Remarks
newLocation
is the position of the helper node center after the layout.Parameters
A map of options to pass to the method.
Callback method that assigns a new location that matches newLocation
to the node port
.
Remarks
newLocation
is the position of the source/target location after the layout.Parameters
A map of options to pass to the method.
Constants
A data provider key that can be used to look up the original IEdge of an LayoutEdge.
Remarks
A data provider key that can be used to look up the original ILabel of an LayoutEdgeLabel.
Remarks
A data provider key that can be used to look up the original INode of a LayoutNode.
Remarks
A data provider key that can be used to look up the original ILabel of an LayoutNodeLabel.
Remarks
A data provider key that can be used to look up the source port of the original IEdge of an LayoutEdge.
Remarks
A data provider key that can be used to look up the target port of the original IEdge of an LayoutEdge.
Remarks
This key is used to provide information about helper nodes that have been inserted into the graph to model edges at edges.
A data provider key that can be used to look up the original unconnected ports of the original IPortOwner of an LayoutEdge in the case of edge-to-edge connections.
Remarks
You can access all (connected and unconnected) ports through the ports property of the original IGraph elements, which can be retrieved through the ORIGINAL_NODE_DATA_KEY and ORIGINAL_EDGE_DATA_KEY data providers. The information about whether a port is connected or not is not readily accessible from there, though. You can use this data provider to specifically find these ports, e.g. to create additional LayoutPortCandidates or just reserve space for them.
This data provider is created automatically for the layoutGraph of this LayoutGraphAdapter. Especially, it is available if the layout is run with a LayoutExecutor or methods applyLayoutAnimated and applyLayout.
A data provider key that can be used to look up the original unconnected ports of the original IPortOwner of an LayoutNode.
Remarks
You can access all (connected and unconnected) ports through the ports property of the original IGraph elements, which can be retrieved through the ORIGINAL_NODE_DATA_KEY and ORIGINAL_EDGE_DATA_KEY data providers. The information about whether a port is connected or not is not readily accessible from there, though. You can use this data provider to specifically find these ports, e.g. to create additional LayoutPortCandidates or just reserve space for them.
This data provider is created automatically for the layoutGraph of this LayoutGraphAdapter. Especially, it is available if the layout is run with a LayoutExecutor or methods applyLayoutAnimated and applyLayout.