This low-level helper class helps with the reading and writing layer constraints for nodes in a graph.
Remarks
Layer constraints affect the assignment of nodes to the layers.
Instead of using this class, it is highly recommended to define constraints more conveniently via the layout data property layerConstraints.
This class cannot be instantiated
Type Details
- yFiles module
- algorithms
Methods
Gets all the currently registered constraints as a tuple consisting of the source item, the constraint and the target item (can be null).
Returns
- ↪IEnumerable<any[]>
- A collection of tuples representing all registered constraints. The first item is the item for which the constraint is defined, the second item is the constraint itself and the third item is the relational other item. The other item can be null if the constraint is one that does not need such an item.
Returns whether any constraints are defined for the given item.
Parameters
A map of options to pass to the method.
- item - LayoutNode
The item to check for
Returns
- ↪boolean
true
if constraints are defined for the given item,false
otherwise
Adds a constraint that places the node
on the bottom layer.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node that should lie on the bottom layer
- priority - number
- The priority of the constraint. If multiple constraints conflict, the ones with lower priority will be discarded.
Adds a constraint that places the given node
on the topmost layer.
Parameters
A map of options to pass to the method.
- node - LayoutNode
- The node that should lie on the top layer
- priority - number
- The priority of the constraint. If multiple constraints conflict, the ones with lower priority will be discarded.
placeInOrder
(upperNode: LayoutNode, lowerNode: LayoutNode, minimumDistance?: number, weight?: number, priority?: number)Adds a constraint that forces the upperNode
to lie at least minimumDistance
layers above the lowerNode
with a given weight
penalty for larger layer differences.
Remarks
Parameters
A map of options to pass to the method.
- upperNode - LayoutNode
- The upper node
- lowerNode - LayoutNode
- The lower node that should lie below the upper node
- minimumDistance - number
- The minimum layer distance between the upper and lower node
- weight - number
- The weight penalty for larger layer differences
- priority - number
- The priority of the constraint. If multiple constraints conflict, the ones with lower priority will be discarded.
Adds a constraint that forces node1
to lie in the same layer as node2
.
Parameters
A map of options to pass to the method.
- node1 - LayoutNode
- the first node
- node2 - LayoutNode
- the second node that should lie in the same layer
- priority - number
- the priority of the constraint. If multiple constraints conflict, the ones with lower priority will be discarded.
removeConstraint
(sourceItem: LayoutNode, orderingConstraint: OrderingConstraint, targetItem: LayoutNode) : voidRemoves the constraint defined for the given source item, ordering constraint, and target item.
Remarks
This method does nothing if there is no constraint defined for the given combination of source item, target item, and ordering constraint.
Parameters
A map of options to pass to the method.
- sourceItem - LayoutNode
the source item
- orderingConstraint - OrderingConstraint
the ordering constraint
- targetItem - LayoutNode
the target item or
null
if there is none for this constraint
Disposes of all constraints modified via this instance (if it was created using createEmpty or createWritableCopy) and so restores the state of the constraints before creation of this instance.
Remarks
Restore should always be called at some point constraints were modified.
If this instance is a read-only one created via createReadonlyView, then this method has no effect.
Static Methods
Creates an empty, modifiable constraints instance and registers the constraints with the given graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph for which the newly created empty constraints instance is registered.
Returns
- ↪LayoutGraphLayerConstraints
- An empty, modifiable instance.
Factory that reads the current state from the given graph's context.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to read the data from.
Returns
- ↪LayoutGraphLayerConstraints
- A read-only, potentially empty instance that contains the constraints associated with this graph.
Factory that reads the current state from the given graph's context and copies it to a mutable instance.
Remarks
Newly created constraints on the writable copy are automatically registered for the given graph without destroying the old constraints (if some existed).
If no information was associated with the graph, the returned instance will be empty.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to read and copy the initial data from.
Returns
- ↪LayoutGraphLayerConstraints
- A potentially empty instance that contains the constraints associated with this graph.