Manages a collection of layout stages that can be executed in a stack-wise manner.
Remarks
The LayoutStageStack class manages a list of layout stages, enabling the composition of complex layout processes by stacking multiple stages together. The stages are executed in the order they are stacked.
It provides various methods to add, remove, and retrieve stages, such as append and prepend, which add stages to the end or beginning of the stack, respectively. The stack can be directly accessed via the stack property for more advanced manipulations, like reordering or clearing all stages.
Additionally, you can add preprocessing and post-processing steps to the stack using addPreprocessor and addPostprocessor, allowing you to inject custom logic before or after the core layout algorithm is applied.
Type Details
- yFiles module
- algorithms
See Also
Properties
Gets the raw list of stages in the stack.
Remarks
This property provides direct access to the underlying list of stages. You can use this to insert, remove, or reorder stages in the stack. Be cautious, as the list should not contain duplicate instances of stages.
Modifications to this list directly affect the execution order of the layout process.
Methods
Adds a layout algorithm as a post-processing stage to the stack.
Remarks
algorithm
in a layout stage and adds it to the stack. The algorithm
is executed after any other stages in the stack.Parameters
A map of options to pass to the method.
- algorithm - ILayoutAlgorithm
- The ILayoutAlgorithm to be used as the post-processing stage.
Returns
- ↪ILayoutStage
- The ILayoutStage that was created and added.
Adds a layout algorithm as a pre-processing stage to the stack.
Remarks
algorithm
in a layout stage and adds it to the stack. The algorithm
is executed before any other stages in the stack.Parameters
A map of options to pass to the method.
- algorithm - ILayoutAlgorithm
- The ILayoutAlgorithm to be used as the pre-processing stage.
Returns
- ↪ILayoutStage
- The ILayoutStage that was created and added.
Appends a new stage to the end of the stack.
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- The layout stage to append to the stack.
Returns
- ↪ILayoutStage
- The appended ILayoutStage instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if the stage instance is already present in the stack.
Appends a core layout algorithm to the stack.
Parameters
A map of options to pass to the method.
- algorithm - ILayoutAlgorithm
- The core layout algorithm to append.
Returns
- ↪ILayoutStage
- The created ILayoutStage instance wrapping the core layout.
Disables all stages in the stack by setting their enabled property to false
.
Retrieves the first instance of a layout stage of the specified type from the stack.
Type Parameters
- T
- The type of the layout stage to retrieve.
Parameters
A map of options to pass to the method.
- stageType - Constructor<T>
- The type of the layout stage to retrieve.
Returns
- ↪T?
- The first matching stage of the specified type, or
null
if none is found.
See Also
Prepends a new stage to the beginning of the stack.
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- The layout stage to prepend to the stack.
Returns
- ↪ILayoutStage
- The prepended ILayoutStage instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if the stage instance is already present in the stack.
Removes a specific stage from the stack.
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- The layout stage to remove.
Replaces an existing layout stage of a specified type on the stack with a new stage.
Type Parameters
- T
- The type of the layout stage to replace.
Parameters
A map of options to pass to the method.
- stageType - Constructor<T>
- The type of the layout stage to replace.
- stage - T
- The layout stage that should replace the current stage on the stack
Returns
- ↪ILayoutStage
- The added layout stage instance.
Throws
- Exception({ name: 'ArgumentError' })
- Thrown if no stage of the specified type is on the stack or if the given instance is already on the stack.
Static Methods
linkCoreLayouts
(stages: IEnumerable<ILayoutStage>, coreLayout?: function(LayoutGraph):void) : ILayoutAlgorithmChains a collection of ILayoutStage instances together and configures them into a stack.
Remarks
coreLayout
is added as the final element in the stack. The method returns the top-most stage, which represents the entry point for the applyLayout call.Parameters
A map of options to pass to the method.
- stages - IEnumerable<ILayoutStage>
- The collection of stages to chain together.
- coreLayout - function(LayoutGraph):void
- An optional callback to be used as the final core layout stage in the stack.
Signature Details
function(obj: LayoutGraph)
Encapsulates a method that has a single parameter and does not return a value.Parameters
- obj - LayoutGraph
- The parameter of the method that this delegate encapsulates.
Returns
- ↪ILayoutAlgorithm
- A layout algorithm to apply the entire stack.