C

LayoutGraphAdapter

Adapter class that can be used to obtain a layoutGraph from an IGraph.
Inheritance Hierarchy

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.

See Also

The chapter Applying an Automatic Layout describes how to apply automatic layout algorithms.

Members

Show:

Constructors

Creates a new adapter using the given originalGraph.

Parameters

originalGraph: IGraph
The graph to build this adapter for.

Throws

Exception ({ name: 'ArgumentError' })
originalGraph is null.

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.

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.

final

See Also

API
nodeComparator
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.
If this instance is configured to create helper nodes for ports at edges, this will be the initial size of the helper nodes with the center of the node always being the location of the port. The default is 3x3.
conversionfinal

See Also

API
hideEdgesAtEdges
Gets or sets a value that controls whether edges at other edges will be hidden from the layout graph or included.
If this property is set to true, edges at other edges are simply ignored and not part of the layout graph. The default is false in which case helper nodes are inserted into the layout graph for each source and target port of an IEdge that is owned by an IEdge.
final

See Also

API
edgePortNodeSize
Gets or sets a mapping that specifies how ILabels should be placed by the layout algorithm.

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.

conversionfinal

See Also

API
EDGE_LABEL_PREFERRED_PLACEMENT_DATA_KEY, labelPlacementPolicies
Gets the layoutGraph instance.
If initialize was not explicitly called earlier, it will be called on the first access to this property.
readonlyfinal
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.

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.

final

See Also

API
edgeComparator
Gets the original IGraph instance.
readonlyfinal
Gets or sets the mapping from ports to a policy that specifies how port locations should be adjusted after a layout has been calculated.

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.

The coordinates of a port will not be changed if the port is associated with a fixed port candidate, e.g. by setting portPlacementPolicies to KEEP_PARAMETER for the port.
conversionfinal

See Also

API
portAdjustmentPolicies
Gets or sets how ILabels at IPorts (owned by an INode) should be treated by the layout algorithm.
This mapping is queried for each ILabel at an IPort and should return a PortLabelPolicy value indicating how the label should appear to the layout algorithms. The default is a constant ItemMapping<TItem, TValue> returning NODE_LABEL for all labels.
Note that only IPorts whose owner is an INode are considered, others are not, i.e. those of IEdges.
conversionfinal

See Also

API
PortLabelPolicy, portLabelPolicies
Gets or sets a mapping that specifies how IPorts should be placed by the layout algorithm.

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.

conversionfinal

See Also

API
SOURCE_PORT_CANDIDATES_DATA_KEY, TARGET_PORT_CANDIDATES_DATA_KEY, portPlacementPolicies

Methods

Registers a single value data for the adapted layout graph with the specified ValueDataKey<TValue>.
If a value is already registered with the same dataKey, it will be replaced. To only temporarily replace an existing value, you should add a context layer before and remove it afterward.
final

Parameters

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>.
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.
final

Parameters

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>.
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.
final

Parameters

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>.
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.
final

Parameters

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>.
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.
final

Parameters

dataKey: EdgeLabelDataKey<T>
The EdgeLabelDataKey<TValue> the data should be registered for.
provider: IMapper<ILabel, T>
The data to be registered at the graph.
Registers data for individual nodes at the graph with the specified NodeDataKey<TValue>.

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.

final

Parameters

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.
Registers data for individual edges at the graph with the specified EdgeDataKey<TValue>.

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.

final

Parameters

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.
Registers data for individual node labels at the graph with the specified NodeLabelDataKey<TValue>.

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.

final

Parameters

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.
Registers data for individual edge labels at the graph with the specified EdgeLabelDataKey<TValue>.

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.

final

Parameters

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.
final

Parameters

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.
This method is called implicitly by applyLayout and does not normally need to be called manually.
final

Parameters

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.
This method is typically called after running a layout algorithm on the layoutGraph to apply the result to the originalGraph.
final
Creates a copy of an IEdgeStyle instance that is used during the layout for path calculations and the like.
This method creates suitable copies of 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.
protected

Parameters

style: IEdgeStyle
The style to copy.

Return Value

IEdgeStyle
A replacement of style that is used during layout calculation.
Creates a copy of an INodeStyle instance that is used during the layout.
This method creates suitable copies of 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.
protected

Parameters

style: INodeStyle
The style to copy.

Return Value

INodeStyle
A replacement of style that is used during layout calculation.
Creates the LabelCandidate for a given label and ILabelModelParameter combination.
protected

Parameters

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.

Return Value

LabelCandidate
A candidate to yield for the labeling algorithms or null.
Creates a LabelCandidate for a given label and ILabelModelParameter combination.
protected

Parameters

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.

Return Value

LabelCandidate
A candidate to yield for the labeling algorithms or null.
Initializes the layoutGraph instance by taking the current state of the originalGraph and the settings of this adapter.
This method can be called only once. After the call, changes to all properties (portPlacementPolicies, hideEdgesAtEdges etc.) have no effect anymore. It is important to call this method before using methods mapping from the original to the copied item and vice-versa (getOriginalNode, getLayoutNode etc.)
final
Callback method that assigns a new location that matches newLocation to the edge port.
This method is called only for ports which are owned by edges. These are represented by helper nodes during the layout, and newLocation is the position of the helper node center after the layout.
protected

Parameters

port: IPort
The edge port that should be placed.
newLocation: Point
The new location of the port as calculated by the layout algorithm.
Callback method that assigns a new location that matches newLocation to the node port.
This method is called only for ports which are owned by nodes. These are not represented as individual items during the layout but as source and end of an edge, and newLocation is the position of the source/target location after the layout.
protected

Parameters

port: IPort
The node port that should be placed.
newLocation: Point
The new location of the port as calculated by the layout algorithm.

Constants

A data provider key that can be used to look up the original IEdge of an LayoutEdge.
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.
static
A data provider key that can be used to look up the original ILabel of an LayoutEdgeLabel.
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.
static
A data provider key that can be used to look up the original INode of a LayoutNode.
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.
static
A data provider key that can be used to look up the original ILabel of an LayoutNodeLabel.
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.
static
A data provider key that can be used to look up the source port of the original IEdge of an LayoutEdge.
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.
static
A data provider key that can be used to look up the target port of the original IEdge of an LayoutEdge.
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.
static
This key is used to provide information about helper nodes that have been inserted into the graph to model edges at edges.
This key can be used to query an IMapper<K, V> that yields true for get for nodes that are actually representatives of IPorts at IEdges. Also, the get method will yield the corresponding original IEdge.
static
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.

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.

static
A data provider key that can be used to look up the original unconnected ports of the original IPortOwner of an LayoutNode.

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.

static