This low-level helper class helps with the reading and writing sequence constraints for elements in a graph.
Remarks
Sequence constraints affect the sequence of nodes and edges within a layer.
Instead of using this class, it is recommended to define sequence constraints more conveniently via the layout data property sequenceConstraints.
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 - LayoutGraphItem
The item to check for
Returns
- ↪boolean
true
if constraints are defined for the given item,false
otherwise
Adds a constraint that places the given item at the start of the sequence.
Parameters
A map of options to pass to the method.
- item - LayoutNode | LayoutEdge
- the node or edge that should be placed at the start
Adds a constraint that places the given item at the end of the sequence.
Parameters
A map of options to pass to the method.
- item - LayoutNode | LayoutEdge
- the node or edge that should be placed at the end
Adds a constraint that forces the firstItem
to lie before the secondItem
.
Parameters
A map of options to pass to the method.
- firstItem - LayoutNode | LayoutEdge
- the first item
- secondItem - LayoutNode | LayoutEdge
- the second item, which should be placed after the first item
removeConstraint
(sourceItem: LayoutGraphItem, orderingConstraint: OrderingConstraint, targetItem: LayoutGraphItem) : 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 - LayoutGraphItem
the source item
- orderingConstraint - OrderingConstraint
the ordering constraint
- targetItem - LayoutGraphItem
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 restores the state of the constraints before creation of this instance.
Remarks
Restore should always be called at some point where 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
- ↪LayoutGraphSequenceConstraints
- 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
- ↪LayoutGraphSequenceConstraints
- 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
- ↪LayoutGraphSequenceConstraints
- A writable, potentially empty instance that contains the constraints associated with this graph.