The LayoutGraphUtilities provides several helper and utility functions for LayoutGraph and the layout algorithms.
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.LayoutGraphUtilities
See Also
Static Methods
alignNodeLayouts
(graph: LayoutGraph, nodes: YNodeList, referenceNode: YNode, vertical: boolean, mode: NodeAlignment)Aligns the specified nodes either vertically or horizontally according to the specified node alignment mode.
Remarks
For vertical arrangements, nodes are either top-aligned, center-aligned, bottom-aligned, or vertically distributed.
For horizontal arrangements, nodes are either left-aligned, center-aligned, right-aligned, or horizontally distributed.
In this context, distributed means that the specified nodes are placed in such a way that the projections of their bounds onto the vertical or horizontal coordinate axis do not overlap. For example, after vertically distributing nodes, (n1.y + n1.height) <= n2.y
for two consecutively placed nodes n1
and n2
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the specified nodes
- nodes - YNodeList
- the subset of the specified graph's nodes that is arranged
- referenceNode - YNode
- if
null
, the common coordinate for aligning the specified nodes is calculated as the the vertical minimum (top-aligned), the vertical center, the vertical maximum (bottom-aligned), the horizontal minimum (left-aligned), the horizontal center, or the horizontal maximum (right-aligned) of the bounds of the specified nodes; otherwise the appropriate coordinate of the given reference node's bounds is used as common coordinate for aligning the specified nodes. The reference node is ignored when distributing nodes. - vertical - boolean
true
if nodes should be aligned (or distributed) according to their y-coordinates; otherwise nodes are aligned (or distributed) according to their x-coordinates.- mode - NodeAlignment
- one of the valid alignment modes
arrangeRectangleGrid
(rectangles: Rectangle2D[], finalRect: Rectangle2D, aspectRatio: number) : YDimensionReassigns the bounds of the rectangles in a grid to fit in a large rectangle with an aspect ratio close to the specified aspect ratio.
Remarks
0
.Parameters
A map of options to pass to the method.
- rectangles - Rectangle2D[]
- the rectangles whose coordinates will be modified
- finalRect - Rectangle2D
- the exact dimension will be placed in this rectangle
- aspectRatio - number
- the preferred aspect ratio of the grid
Returns
- ↪YDimension
- the dimension of the grid
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is less than or equal to zero
arrangeRectangleMultiRows
(rectangles: Rectangle2D[], finalRect: Rectangle2D, preferredWidth: number, preferredHeight: number, compaction: boolean, constraintMode: MultiRowConstraint, alignment?: RowAlignment) : numberReassigns the bounds of the rectangles in multiple rows to fit the preferred width and height.
Remarks
The rectangles will be placed within this bound, arranged in rows, where each row may be split into more sub-rows. This often leads to more compact results than provided by the procedure used in arrangeRectangleRows. A row will be subdivided into more rows, if two successive rectangles to be placed in the row could be placed stacked within this row without making the row larger in height.
The preferred width and height should be greater than 0
, otherwise the nodes are not arranged.
Parameters
A map of options to pass to the method.
- rectangles - Rectangle2D[]
- the rectangles to arrange (coordinates will be assigned)
- finalRect - Rectangle2D
- the exact resulting dimension will be stored in this rectangle
- preferredWidth - number
- the preferred width of the result rectangle
- preferredHeight - number
- the preferred height of the result rectangle
- compaction - boolean
true
if the algorithm tries to always minimize the resulting dimension, whilst respecting the given constraints,false
otherwise- constraintMode - MultiRowConstraint
- the width or height constraints to consider
- alignment - RowAlignment
- the alignment inside a row
Returns
- ↪number
- the number of rows used
See Also
arrangeRectangleRows
(rectangles: Rectangle2D[], finalRect: Rectangle2D, aspectRatio: number, alignment?: RowAlignment) : numberReassigns the bounds of the rectangles to fit in a large rectangle with an aspect ratio close to the specified aspect ratio.
Remarks
This is achieved by arranging the rectangles in rows.
The aspect ratio must be greater than 0
.
Parameters
A map of options to pass to the method.
- rectangles - Rectangle2D[]
- the rectangles whose coordinates will be modified
- finalRect - Rectangle2D
- the exact dimension of the resulting rectangle
- aspectRatio - number
- the preferred aspect ratio of the resulting rectangle
- alignment - RowAlignment
- one of the valid row alignments
Returns
- ↪number
- the number of used rows
Throws
- Exception({ name: 'ArgumentError' })
- if the aspect ratio is
0
or less
Applies the reversed layout of the first edge to the second edge.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which both edges belong
- edge1 - Edge
- the edge which adopts the points
- edge2 - Edge
- the template
Flips the orientation of a given rectangle, if its up vector points downward (
upY > 0)
.
Remarks
180
degrees without changing the rectangle's center.Parameters
A map of options to pass to the method.
- rect - YOrientedRectangle
- the given rectangle
Returns
- ↪boolean
true
if the given rectangle was flipped,false
otherwise
Clips the path of the given edge on the bounding box of the source and target points.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge to clip
Returns the path of an edge clipped on the bounding box of the source and target node.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the clipped edge
Returns
- ↪YPointPath
- the clipped path of the edge
clipEdgePathOnBounds
(edge: IEdgeLayout, source: INodeLayout, target: INodeLayout, inset?: number) : YPointPathReturns the path of an edge clipped on insets of the bounding box of the source and target node.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdgeLayout
- the clipped edge
- source - INodeLayout
- the source of the edge
- target - INodeLayout
- the target of the edge
- inset - number
- the inset of the node
Returns
- ↪YPointPath
- the clipped path of the edge
Clips the path of all edges in the graph on the bounding box of their source and target points.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
See Also
Returns the path of a given edge path clipped on the given bounding boxes of the source and target node.
Parameters
A map of options to pass to the method.
- path - YPointPath
- the path that will be clipped
- sourceBox - YRectangle
- the box of the source node that the given path should be clipped at
- targetBox - YRectangle
- the box of the target node that the given path should be clipped at
Returns
- ↪YPointPath
- the path clipped on the given nodes boxes
Determines the main direction of the edge flow by analyzing the current layout of the graph.
Remarks
null
, all edges are considered.Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the underlying graph
- considerEdges - IDataProvider
- the edges to consider
Domain Edge Values boolean true
if the edge should be considered,false
otherwise
Returns
- ↪EdgeFlow
- one of the predefined flow directions
Returns a string representation of the path of the given edge.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge
Returns
- ↪string
- the string that contains all control points of the edge
Returns the bounding box of the nodes and edges accessible through the given cursors.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the nodes and edges
- nodes - INodeCursor
- the nodes to include in the bounding box
- edges - IEdgeCursor
- the edges to include in the bounding box
Returns
- ↪Rectangle2D
- the bounding box containing the given nodes and edges
See Also
Returns the bounding box of the given node.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the node
- node - YNode
- the node
Returns
- ↪Rectangle2D
- the bounding box of the node
See Also
Returns the bounding box of the given edge.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the edge
- edge - Edge
- the edge
Returns
- ↪Rectangle2D
- the bounding box of the edge
See Also
getBoundingBox
(graph: LayoutGraph, nodes: INodeCursor, edges: IEdgeCursor, includeLabels: boolean) : Rectangle2DReturns the bounding box of the nodes and edges accessible through the given cursors, optionally including node labels and edge labels.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the given nodes and edges
- nodes - INodeCursor
- the nodes to include in the bounding box
- edges - IEdgeCursor
- the edges to include in the bounding box
- includeLabels - boolean
true
if labels of nodes and edges should be included,false
otherwise
Returns
- ↪Rectangle2D
- the bounding box of the given nodes and edges
See Also
getBoundingBox
(graph: LayoutGraph, nodes: INodeCursor, edges: IEdgeCursor, includeNodeLabels: boolean, includeEdgeLabels: boolean, includeHalos?: boolean) : Rectangle2DReturns the bounding box of the nodes and edges accessible through the given cursors, optionally including node labels, edge labels or NodeHalos.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the given nodes and edges
- nodes - INodeCursor
- the nodes to include in the bounding box
- edges - IEdgeCursor
- the edges to include in the bounding box
- includeNodeLabels - boolean
true
if labels of nodes should be included,false
otherwise- includeEdgeLabels - boolean
true
if labels of edges should be included,false
otherwise- includeHalos - boolean
Returns
- ↪Rectangle2D
- the bounding box of the given nodes and edges
Returns the bounding box of the edges accessible through the given cursor.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the edges
- edges - IEdgeCursor
- the edges to include in the bounding box
Returns
- ↪Rectangle2D
- the bounding box containing the given edges
See Also
Returns the bounding box of the nodes accessible through the given cursor.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the nodes
- nodes - INodeCursor
- the nodes to include in the bounding box
Returns
- ↪Rectangle2D
- the bounding box containing the given nodes
See Also
Returns the ILabelLayoutFactory for the given graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
Returns
- ↪ILabelLayoutFactory
- the label factory of the graph
See Also
getLabelPlacement
(model: INodeLabelLayoutModel, labelSize: YDimension, nodeLayout: INodeLayout, param: Object) : YPointReturns the upper-left corner of the paraxial bounding box of the given node label as encoded by the specified model parameter.
Remarks
Parameters
A map of options to pass to the method.
- model - INodeLabelLayoutModel
- the INodeLabelLayoutModel used for placing the label
- labelSize - YDimension
- the size of the label
- nodeLayout - INodeLayout
- the layout of the node to which the label belongs
- param - Object
- the model parameter
Returns
- ↪YPoint
- the upper-left corner of the label's bounding box
See Also
getLabelPlacement
(model: IEdgeLabelLayoutModel, labelSize: YDimension, edgeLayout: IEdgeLayout, sourceLayout: INodeLayout, targetLayout: INodeLayout, param: Object) : YPointReturns the upper-left corner of the paraxial bounding box of the given edge label as encoded by the specified model parameter.
Remarks
Parameters
A map of options to pass to the method.
- model - IEdgeLabelLayoutModel
- the IEdgeLabelLayoutModel used for placing the label
- labelSize - YDimension
- the size of the label that should be placed
- edgeLayout - IEdgeLayout
- the layout of the edge to which the label belongs
- sourceLayout - INodeLayout
- the layout of the edge's source node
- targetLayout - INodeLayout
- the layout of the edge's target node
- param - Object
- the model parameter
Returns
- ↪YPoint
- the upper-left corner of the label's bounding box
See Also
Returns the distance between the centers of the two given nodes.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the nodes belong
- node1 - YNode
- the first node
- node2 - YNode
- the second node
Returns
- ↪number
- the distance between the nodes' centers
Returns a string representation of all node positions in the graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
Returns
- ↪string
- the string containing all node locations
See Also
Returns the length of the path of the given edge.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge
Returns
- ↪number
- the length of the edge's path
Checks whether or not the path of an edge is outside the bounding box of the source and target node.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge
Returns
- ↪boolean
true
if the edge is outside the nodes,false
otherwise
isEdgeOutsideNodes
(edge: IEdgeLayout, source: INodeLayout, target: INodeLayout, halo: number) : booleanChecks whether or not the path of an edge is outside the bounding box of the source and target node, considering the given halo.
Remarks
The edge is outside the nodes if its control points as well as the source and target point are not inside the nodes' bounding boxes.
The nodes can be enlarged by a halo to check if the edge keeps some distance to the nodes.
Parameters
A map of options to pass to the method.
- edge - IEdgeLayout
- the edge
- source - INodeLayout
- the source of the edge
- target - INodeLayout
- the target of the edge
- halo - number
- the halo for the nodes
Returns
- ↪boolean
true
if the edge is outside the nodes,false
otherwise
Determines whether or not most of the edges of the graph are routed octilinear.
Remarks
null
, all edges are considered.Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the underlying graph
- considerEdges - IDataProvider
- the edges to consider
Domain Edge Values boolean true
if the edge should be considered,false
otherwise
Returns
- ↪boolean
true
if most of the edges in the graph are routed octilinear,false
otherwise
true
for orthogonal layouts.Determines whether or not most of the edges of the graph are routed orthogonally.
Remarks
null
, all edges are considered.Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the underlying graph
- considerEdges - IDataProvider
- the edges to consider
Domain Edge Values boolean true
if the edge should be considered,false
otherwise
Returns
- ↪boolean
true
if most of the edges in the graph are routed orthogonally,false
otherwise
Moves all control points of the given edge by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- edge - Edge
- the edge
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Moves the control points of all edges accessible through the given IEdgeCursor by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- edges - IEdgeCursor
- the edges to be moved
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Moves the given node by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- node - YNode
- the node
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Moves all nodes accessible through the given INodeCursor by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- nodes - INodeCursor
- the nodes to be moved
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Moves the subgraph induced by the nodes accessible through the given INodeCursor by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the subgraph
- nodes - INodeCursor
- the nodes that induce the subgraph
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Moves the subgraph induced by the edges accessible through the given IEdgeCursor by the vector (dx,dy)
.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that contains the subgraph
- edges - IEdgeCursor
- the edges that induce the subgraph
- dx - number
- the horizontal distance to move
- dy - number
- the vertical distance to move
Checks whether or not the path of the given edge intersects the interior of a given rectangular area.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge
- rect - Rectangle2D
- the rectangular area to check for intersection
Returns
- ↪boolean
true
if the edge path intersects with the given rectangle,false
otherwise
Removes successive bends that have the same coordinates from all edges in the graph.
Removes successive bends that have the same coordinates from the given edge.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- edge - Edge
- the edge
Assigns a trivial path which has no control points to the specified edge.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- edge - Edge
- the edge
- resetPorts - boolean
true
if the ports of the edge should be set to the center of the corresponding nodes,false
otherwise
Assigns a trivial path which has no control points to all edges in the specified graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- resetPorts - boolean
true
if the ports of the edges should be set to the center of the corresponding nodes,false
otherwise
Sets the ports of all edges in the graph to the center of the nodes.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
See Also
Reverses the layout of an edge.
Remarks
Parameters
A map of options to pass to the method.
- el - IEdgeLayout
- the layout information of an edge
Rounds the locations of the control points and ports of the given edge to integer values.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the edge whose values are rounded
Rounds coordinates and sizes in the layout of an entire graph to integer values.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
See Also
Rounds the location and size of the given node to integer values.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the node belongs
- node - YNode
- the node whose values are rounded
routeEdgesParallel
(graph: LayoutGraph, leadingEdge: Edge, edge: Edge, lineDistance: number, joinEnds?: boolean, absJoinDistance?: number, relJoinDistance?: number)Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- leadingEdge - Edge
- the leading edge
- edge - Edge
- the edge to be adjusted
- lineDistance - number
- the distance between the two edges
- joinEnds - boolean
true
if the edges should share their end points (the ones of the leading edge),false
otherwise- absJoinDistance - number
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joined
- relJoinDistance - number
- the relative distance, measured relative to the length of the first/last segments if the ends are joined
routeEdgesParallel
(graph: LayoutGraph, leadingEdge: Edge, edges: EdgeList, lineDistance: number, adjustLeadingEdge?: boolean, joinEnds?: boolean, absJoinDistance?: number, relJoinDistance?: number)Routes a list of edges which are incident to the same nodes in parallel, optionally joining the end points.
Remarks
All edges get a path that is parallel to the path of the first (leading) edge.
The position of the leading edge may be adjusted if there is an odd number of parallel edges. It will be moved from the center to achieve a more symmetric port assignment.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph
- leadingEdge - Edge
- the leading edge
- edges - EdgeList
- the list of edges that will be aligned with the leading edge
- lineDistance - number
- the distance between two edges
- adjustLeadingEdge - boolean
true
if the leading edge should be adjusted if the size of list is odd,false
otherwise- joinEnds - boolean
true
if the edges should share their end points (the ones of the leading edge),false
otherwise- absJoinDistance - number
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joined
- relJoinDistance - number
- the relative distance, measured relative to the length of the first/last segments if the ends are joined
Routes a self-loop.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph to which the edge belongs
- edge - Edge
- the self-loop