Adapter class that can be used to obtain an LayoutGraph from an IGraph.
Remarks
Typically, this class is not used directly but through the LayoutExecutor or applyLayout and morphLayout
This class will use the provided selectionModel to register corresponding IDataProviders for the data provider keys AFFECTED_NODES_DP_KEY and AFFECTED_EDGES_DP_KEY to the layout graph. Moreover, it will automatically convert IMapper<K,V> instances registered with the IMapperRegistry of the adaptedGraph into corresponding IDataProvider instances of the layout graph.
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 an 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 dummy nodes.
Related Reading in the Developer's Guide
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.layout.LayoutGraphAdapter
See Also
Constructors
Creates the adapter using a given IGraph and ISelectionModel<T>.
Parameters
A map of options to pass to the method.
- adaptedGraph - IGraph
- The graph to build an adapter for.
- selectionModel - ISelectionModel<IModelItem>
- The optional selection model to use by the AFFECTED_NODES_DP_KEY and AFFECTED_EDGES_DP_KEY IDataProvider instances that are automatically bound to this adapter.
- labelPreferredPlacementPolicy - LabelPreferredPlacementPolicy
How ILabels at IEdges should be placed by the layout algorithm. This option sets the labelPreferredPlacementPolicy property on the created object.
- portLabelPolicies - ItemMapping<ILabel,PortLabelPolicy>
How ILabels at IPorts should be treated by the layout algorithm. This option sets the portLabelPolicies property on the created object.
- edgePortNodeSize - Size
The size of the nodes that are inserted for the ports that are created for IEdges that are connected at other IEdges. This option sets the edgePortNodeSize property on the created object.
- hideEdgesAtEdges - boolean
A value that controls whether edges at other edges will be hidden from the layout graph or included. This option sets the hideEdgesAtEdges property on the created object.
- automaticEdgeGrouping - boolean
A value that controls whether edge groups are automatically created for edges that are connected to the same port. This option sets the automaticEdgeGrouping property on the created object.
- fixPorts - boolean
A value that controls whether strong port constraints are automatically created. This option sets the fixPorts property on the created object.
- portAdjustmentPolicy - PortAdjustmentPolicy
The policy that specifies how port locations should be adjusted after a layout has been calculated. This option sets the portAdjustmentPolicy property on the created object.
Properties
Sets or yields the original IGraph instance that is adapted by this instance.
Remarks
null
.Throws
- Exception({ name: 'ArgumentError' })
- if the value of this property is already non
null
Gets or sets a value that controls whether edge groups are automatically created for edges that are connected to the same port.
Remarks
If this property is enabled and no edge groups are explicitly created (SOURCE_GROUP_ID_DP_KEY and TARGET_GROUP_ID_DP_KEY), for all ports with multiple outgoing resp. incoming edges these edges will be assigned to the same edge group. The necessary IDataProviders will be created automatically.
This features requires edge group support from the ILayoutAlgorithm.
Default value is true
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 strong port constraints are automatically created.
Remarks
If this property is enabled and no port constraints have been added explicitly (no IMapper<K,V> are registered for the keys SOURCE_PORT_CONSTRAINT_DP_KEY and TARGET_PORT_CONSTRAINT_DP_KEY), strong source and target port constraints are created automatically. The necessary IDataProviders will be created automatically. The PortSide is inferred from the location of the port relative to the node.
This ensures that view IPorts are not moved during the layout, if the ILayoutAlgorithm supports port constraints.
The default value is false
.
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 how ILabels at IEdges should be placed by the layout algorithm.
Remarks
This setting only affects layout algorithms which support label placement. Also, if PreferredPlacementDescriptors are already defined this setting is ignored.
Default is FROM_DESCRIPTOR.
See Also
Gets or sets the 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' bounding boxes (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 value is NEVER.
See Also
true
.Gets or sets how ILabels at IPorts should be treated by the layout algorithm.
Remarks
See Also
Gets or sets the ISelectionModel<T> to use for the automatically registered IDataProvider instances for the keys AFFECTED_NODES_DP_KEY and AFFECTED_EDGES_DP_KEY.
Methods
addDataProvider
<K,V>(keyType: Class, valueType: Class, dataKey: Object, mapper: IMapper<K,V>) : IDataProviderRegisters a data provider with the graph using the given look-up key and wrapping the given mapper.
Remarks
Type Parameters
- K
- The type of the key to use.
- V
- The type of the value to use.
Parameters
A map of options to pass to the method.
- keyType - Class
- The type of the key to use.
- valueType - Class
- The type of the value to use.
- dataKey - Object
- The look-up key to register the data provider with.
- mapper - IMapper<K,V>
- The mapper wrapped as data provider.
Applies a layout algorithm to an IGraph, optionally applying some LayoutData.
Parameters
A map of options to pass to the method.
- layout - ILayoutAlgorithm
- The layout algorithm to apply.
- layoutData - LayoutData
- The layout data.
Creates a CopiedLayoutGraph for this instance.
Returns
- ↪CopiedLayoutGraph
- An instance whose commitLayoutToOriginalGraph will update this instance.
createEdgeLabelCandidate
(originalLabel: ILabel, dummyLabel: ILabel, layoutParameter: ILabelModelParameter, labelLayout: IEdgeLabelLayout) : EdgeLabelCandidateCreates the EdgeLabelCandidate for a given label and ILabelModelParameter combination.
Parameters
A map of options to pass to the method.
- originalLabel - ILabel
- The original label.
- dummyLabel - ILabel
- The dummy label that describes the current laid out label.
- layoutParameter - ILabelModelParameter
- The parameter to create a candidate for.
- labelLayout - IEdgeLabelLayout
- The IEdgeLabelLayout of the label to pass to the candidate.
Returns
- ↪EdgeLabelCandidate
- A candidate to yield for the labeling algorithms or
null
.
Factory method that creates an IEdgeLayout implementation that wraps the given IEdge
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to wrap.
Returns
- ↪IEdgeLayout
- A wrapper instance.
Callback factory method that creates the INodeLayout for the given IPort that is used as a dummy to represent the port at the IEdge that owns port
.
Parameters
A map of options to pass to the method.
- port - IPort
- The port to create the layout for.
Returns
- ↪INodeLayout
- A suitable implementation of INodeLayout that uses the port's location as the center of the node.
See Also
createNodeLabelCandidate
(originalLabel: ILabel, dummyLabel: ILabel, layoutParameter: ILabelModelParameter, ownerLayout: INodeLabelLayout) : NodeLabelCandidateCreates a NodeLabelCandidate for a given label and ILabelModelParameter combination.
Parameters
A map of options to pass to the method.
- originalLabel - ILabel
- The original label.
- dummyLabel - ILabel
- The dummy label that describes the current laid out label.
- layoutParameter - ILabelModelParameter
- The parameter to create a candidate for.
- ownerLayout - INodeLabelLayout
- The INodeLabelLayout of the label to pass to the candidate.
Returns
- ↪NodeLabelCandidate
- A candidate to yield for the labeling algorithms or
null
.
Factory method that creates a INodeLayout implementation that wraps the given INode
Parameters
A map of options to pass to the method.
- node - INode
- The node to wrap.
Returns
- ↪INodeLayout
- A wrapper instance.
Returns an IEnumerable<T> that provides access to all edges residing in the graph.
Returns the data provider that is registered with the graph using the given look-up key.
Remarks
Returns the layout information for all edge labels belonging to the given edge.
Remarks
Parameters
A map of options to pass to the method.
- edge - Object
- the edge that owns the labels
Returns
- ↪IEdgeLabelLayout[]
- the array of all labels that belong to the given edge
Returns the layout information associated with the given edge.
Remarks
Parameters
A map of options to pass to the method.
- edge - Object
- the edge
Returns
- ↪IEdgeLayout
- the layout information for the edge
getLabelCandidateDescriptor
(originalLabel: ILabel, dummyLabel: ILabel, layoutParameter: ILabelModelParameter) : ILabelCandidateDescriptorCallback that retrieves the label candidate descriptor for the given label and parameter.
Parameters
A map of options to pass to the method.
- originalLabel - ILabel
- The original label to which a parameter will be applied.
- dummyLabel - ILabel
- The dummy label to which the parameter will be applied.
- layoutParameter - ILabelModelParameter
- The parameter to apply.
Returns
- ↪ILabelCandidateDescriptor
- A descriptor or
null
.
See Also
Callback method that gets the label candidate descriptor provider for the given IGraph.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph.
Returns
Returns the layout information for all node labels belonging to the given node.
Remarks
Parameters
A map of options to pass to the method.
- node - Object
- the node that owns the labels
Returns
- ↪INodeLabelLayout[]
- the array of all labels that belong to the given node
Returns the layout information associated with the given node.
Remarks
Parameters
A map of options to pass to the method.
- node - Object
- the node
Returns
- ↪INodeLayout
- the layout information for the node
Returns an IEnumerable<T> that provides access to all nodes residing in the graph.
Callback method that assigns a new location that matches newLocation
to port
.
Remarks
newLocation
is the position of the dummy node after the layout.Parameters
A map of options to pass to the method.
Callback method that assigns a new relative location to port
.
Remarks
newRelativeLocation
. Depending on the port location model, the actual resulting port location may be different.Parameters
A map of options to pass to the method.
Constants
EDGE_LABEL_LAYOUT_PREFERRED_PLACEMENT_DESCRIPTOR_DP_KEY
: IEdgeLabelLayoutDpKey<PreferredPlacementDescriptor>An IMapperRegistry tag for an IMapper<K,V> that provides for the edge ILabels in the adaptedGraph a PreferredPlacementDescriptor instance.
Remarks
See Also
A data provider key that can be used to look up the original IEdge of an Edge.
Remarks
A data provider key that can be used to look up the original ILabel of an IEdgeLabelLayout.
Remarks
A data provider key that can be used to look up the original INode of a YNode.
Remarks
A data provider key that can be used to look up the original ILabel of an INodeLabelLayout.
Remarks
A data provider key that can be used to look up the source port of the original IEdge of an Edge.
Remarks
A data provider key that can be used to look up the tag of an original INode, IEdge or ILabel.
Remarks
When used within layout code, the provider registered with this key can query the tag when providing layout graph elements of type YNode, Edge, INodeLabelLayout or IEdgeLabelLayout as key to its get method.
This data provider is created automatically for a CopiedLayoutGraph that is created as a copy of an IGraph with the help of a LayoutGraphAdapter. Especially, it is available if the layout is run with a LayoutExecutor or methods morphLayout and applyLayout.
A data provider key that can be used to look up the target port of the original IEdge of an Edge.
Remarks
This key is used to provide information about dummy nodes that have been inserted into the graph to model edges at edges.
Remarks
true
for getBoolean for nodes that are actually representatives of IPorts at IEdges. Also the get method will yield the corresponding original IEdge.A data provider key that can be used to look up the original unconnectedports of the original IPortOwner of an YNode or, in the case of edge-to-edge connections, an Edge.
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_DP_KEY and ORIGINAL_EDGE_DP_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 port, e.g. to create additional PortCandidates or just reserve space for them.
This data provider is created automatically for a CopiedLayoutGraph that is created as a copy of an IGraph with the help of a LayoutGraphAdapter. Especially, it is available if the layout is run with a LayoutExecutor or methods morphLayout and applyLayout.