The OrganicLayoutConstraintFactory allows to define additional constraints on subsets of a graph that will be applied by the OrganicLayout during the layout calculation.
Remarks
Constraints modify the behavior of the organic layout algorithm for subsets of a graph, in order to introduce structures, relative positioning, or area restrictions on the positions of the nodes in the layout.
The constraints are defined on IDs registered to the nodes with a IDataProvider with the key NODE_ID_DP_KEY
A OrganicLayoutConstraintFactory has to be disposed of after use. Disposing of the factory will also remove all constraints previously specified for the factory's associated graph.
Type Details
- yfiles module
- layout-organic
- yfiles-umd modules
- layout-multipage, layout-organic, layout
- Legacy UMD name
- yfiles.organic.OrganicLayoutConstraintFactory
- If the graph is partitioned, constraints that are not compatible with the partition grid can be broken.
- If a partial layout is applied to chains, cycles, stars, trees, parallel structures or groups, constraints that include the affected nodes will be ignored.
- If the graph contains fixed nodes, those nodes will remain fixed. Constraints affecting those nodes will be enforced if possible, which may decrease the quality of the resulting layout. If the constraints are impossible to enforce without moving the fixed nodes, they can break.
- An edge orientation that contradicts constraints specified here, may lead to undefined behaviour w.r.t. the orientation of the edge and the affected constraints.
Methods
Adds constraints that cause the given nodes to align parallel to the specified axis.
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be aligned.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to align the nodes parallel to the x-axis, VERTICAL to align them parallel to the y-axis.
Throws
addAlignmentConstraint
(nodeIds: IList<Object>, axis: OrganicLayoutConstraintOrientation, alignmentRange: number)Adds constraints that cause the given nodes to align parallel to the specified axis.
Remarks
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be aligned.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to align the nodes parallel to the x-axis, VERTICAL to align them parallel to the y-axis.
- alignmentRange - number
- The maximum axis distance between the centers of any two aligned nodes.
Throws
- Exception({ name: 'ArgumentError' })
- if the given alignment range is negative
Adds constraints that cause the specified nodes to be arranged on the border of an ellipse with the given aspect ratio.
Remarks
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- the IDs of the nodes that should be placed on the border of an ellipse.
- regularPlacement - boolean
true
if the nodes should be placed in regular intervals along the border of the ellipse,false
otherwise.- aspectRatio - number
- a positive ratio between the horizontal and vertical diameter of the ellipse, or
0
, if the ratio should be calculated automatically.
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is negative
Adds constraints to fix the positions of the specified nodes in relation to one another along one coordinate axis.
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be fixed in relation to one another.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to fix the distances along the x-axis, VERTICAL to fix the distances along the y-axis or BOTH to fix the node's positions relative to each other.
Adds constraints that prevent the specified nodes from occupying an area larger than the defined bounding box.
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes whose bounding box should be limited.
- width - number
- The maximum width of the bounding box containing all specified nodes.
- height - number
- The maximum height of the bounding box containing all specified nodes.
Throws
- Exception({ name: 'ArgumentError' })
- if width or height is negative.
addMaximumDistanceConstraint
(nodeId1: Object, nodeId2: Object, maximumDistance: number, axis: OrganicLayoutConstraintOrientation)Adds constraints that enforce a maximum vertical or horizontal distance between the given nodes.
Parameters
A map of options to pass to the method.
- nodeId1 - Object
- The ID representing the first of the two nodes that are constrained with respect to their maximum distance.
- nodeId2 - Object
- The ID representing the second of the two nodes that are constrained with respect to their maximum distance.
- maximumDistance - number
- The largest allowed horizontal resp. vertical distance between both nodes. The distance is measured between the boundaries of the nodes.
- axis - OrganicLayoutConstraintOrientation
- The axis that is used for measuring the distance. HORIZONTAL to restrict the horizontal distance, VERTICAL to restrict the vertical distance or BOTH to restrict both.
Throws
- Exception({ name: 'ArgumentError' })
- if the maximum distance is negative.
Adds constraints that enforce a minimum distance between the given nodes.
Parameters
A map of options to pass to the method.
- nodeId1 - Object
- The ID representing the first of the two nodes that are constrained with respect to their minimum distance.
- nodeId2 - Object
- The ID representing the second of the two nodes that are constrained with respect to their minimum distance.
- minimumDistance - number
- The minimum required distance between the two nodes. The distance is measured between the boundaries of the nodes.
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum distance is negative.
Adds constraints that cause the given nodes to be placed along the specified axis in the order they are given.
Parameters
A map of options to pass to the method.
- orderedNodeIds - IList<Object>
- The IDs of the nodes to be placed in the order of their appearance in this list.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to order the nodes along the x-axis, VERTICAL to order them along the y-axis or BOTH to order them along both axes.
addPinnedBoundingBox
(nodeIds: IList<Object>, left: number, top: number, width: number, height: number)Adds constraints that prevent the given nodes from being placed outside the specified rectangle.
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be placed in the specified rectangle.
- left - number
- The coordinate of the bounding rectangle's left boundary.
- top - number
- The coordinate of the bounding rectangle's top boundary.
- width - number
- The width of the bounding rectangle.
- height - number
- The height of the bounding rectangle.
Throws
- Exception({ name: 'ArgumentError' })
- if width or height is negative.
Adds constraints that cause the specified nodes to be arranged on the border of a rectangle with the given aspect ratio.
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- the IDs of the nodes that should be placed on the border of a rectangle.
- aspectRatio - number
- a positive ratio between the width and height of the rectangle, or
0
, if the ratio should be calculated automatically.
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is negative
Adds constraints that cause the given nodes to be aligned parallel to the specified axis.
Remarks
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be aligned
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to align the nodes parallel to the x-axis, VERTICAL to align them parallel to the y-axis.
Throws
addRegularAlignmentConstraint
(nodeIds: IList<Object>, axis: OrganicLayoutConstraintOrientation, distance: number)Adds constraints that cause the given nodes to be aligned parallel to the specified axis.
Remarks
Parameters
A map of options to pass to the method.
- nodeIds - IList<Object>
- The IDs of the nodes that should be aligned.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to align the nodes parallel to the x-axis, VERTICAL to align them parallel to the y-axis.
- distance - number
- The distance between neighbouring nodes along the alignment.
Throws
addSeparationConstraint
(idSetA: IList<Object>, idSetB: IList<Object>, axis: OrganicLayoutConstraintOrientation, minimumDistance: number)Adds constraints that enforce a minimum distance between two sets of nodes.
Remarks
Parameters
A map of options to pass to the method.
- idSetA - IList<Object>
- The IDs of the nodes on the left/top side of the division.
- idSetB - IList<Object>
- The IDs of the nodes on the right/bottom side of the division.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to separate the nodes along the x-axis, VERTICAL to separate them along the y-axis, BOTH to separate them along both axes.
- minimumDistance - number
- The minimum distance by which the two sets are separated.
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum distance is negative.