This class allows to define additional constraints on nodes of a graph that will be applied by the OrganicLayout during the layout calculation.
Remarks
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.organic.OrganicConstraintData
Constructors
Creates a new instance of OrganicConstraintData which helps configuring additional constraints on nodes of a graph that will be applied by the OrganicLayout during the layout calculation.
Methods
addAlignmentConstraint
(axis: OrganicLayoutConstraintOrientation, range?: number) : ItemCollection<INode>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.
- axis - OrganicLayoutConstraintOrientation
- HORIZONTAL to align the nodes parallel to the x-axis, VERTICAL to align them parallel to the y-axis.
- range - number
- The maximum horizontal distance between the centers of any two aligned nodes if the nodes are aligned vertically, and otherwise the maximum vertical distance between the centers of any two aligned nodes.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Throws
- Exception({ name: 'ArgumentError' })
- if the given alignment range is negative
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
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.
- 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 determined automatically.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is negative
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
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.
- 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.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
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.
- 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.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Throws
- Exception({ name: 'ArgumentError' })
- if width or height is negative.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
addMaximumDistance
(node1: INode, node2: INode, distance: 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.
- node1 - INode
- The first node that is constrained with respect to their maximum distance.
- node2 - INode
- The second node that is constrained with respect to their maximum distance.
- distance - 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.
Examples
Adds constraints that enforce a minimum distance between the given nodes.
Parameters
A map of options to pass to the method.
- node1 - INode
- The first of the two nodes that are constrained with respect to their minimum distance.
- node2 - INode
- 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.
Examples
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.
- 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.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
addPinnedBoundingBox
(left: number, top: number, width: number, height: number) : ItemCollection<INode>Adds constraints that prevent the given nodes from being placed outside the specified rectangle.
Parameters
A map of options to pass to the method.
- 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.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Throws
- Exception({ name: 'ArgumentError' })
- if width or height is negative.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
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.
- aspectRatio - number
- a positive ratio between the width and height of the rectangle, or
0
, if the ratio should be calculated automatically.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Throws
- Exception({ name: 'ArgumentError' })
- if the given aspect ratio is negative
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
addRegularAlignmentConstraint
(axis: OrganicLayoutConstraintOrientation, distance?: number) : ItemCollection<INode>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.
- 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. If the value is negative, the distance is determined automatically.
Returns
- ↪ItemCollection<INode>
- An ItemCollection<TItem> that is used to define the nodes affected by this constraint.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
addSeparationConstraint
(axis: OrganicLayoutConstraintOrientation, minimumDistance: number) : OrganicLayoutSeparationConstraintAdds constraints that enforce a minimum distance between two sets of nodes.
Remarks
Parameters
A map of options to pass to the method.
- 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.
Returns
- ↪OrganicLayoutSeparationConstraint
- An OrganicLayoutSeparationConstraint that is used to define the two sets of nodes that should be separated.
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum distance is negative.
Examples
The nodes that are affected by this constraint can be defined using the property source of ItemCollection<TItem>.
Nodes can be also added one by one. This can be more convenient than defining an own list and setting it to source.
Alternatively, a powerful option is to use the delegate to set a custom delegate that returns for every node whether it is contained in the set or not:
Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData
- The LayoutData to combine this instance with.
Returns
- ↪LayoutData
- The combined layout data.