@graphty/graphty-element / index / LayoutManager
Class: LayoutManager ​
Defined in: graphty-element/src/managers/LayoutManager.ts:445
Manages layout engines and their lifecycle Coordinates layout updates and transitions
Implements ​
Constructors ​
Constructor ​
new LayoutManager(
eventManager,dataManager,styles):LayoutManager
Defined in: graphty-element/src/managers/LayoutManager.ts:701
Creates an instance of LayoutManager
Parameters ​
eventManager ​
Event manager for emitting layout events
dataManager ​
Data manager for accessing nodes and edges
styles ​
Styles
Styles instance for layout configuration
Returns ​
LayoutManager
Properties ​
graphWritesWaiting ​
graphWritesWaiting: () =>
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:567
Whether another command that writes the graph is dispatched and not finished. While one is, data arriving does not start a seeded layout over: the last write of the run does, once, so addEdge in a loop rebuilds the layout once rather than once per add.
Returns ​
boolean
True while one is.
onRest ​
onRest: (() =>
void) |null=null
Defined in: graphty-element/src/managers/LayoutManager.ts:541
Told when the layout comes to rest: it settled, was paused, or finished placing.
replacing ​
replacing: () =>
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:559
Whether a new layout has been asked for and is waiting its turn. While one is, the frame loop does not step the engine it will replace: the new engine starts from the arrangement it finds, so a frame that stepped the old one in between -- or paid the old one's owed pre-steps -- would make where the new layout starts, and so where it ends, depend on whether a frame happened to fall between a load landing and the layout being built.
Returns ​
boolean
True while one is.
restoring ​
restoring: () =>
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:549
Whether undo, redo or a restore is on its way to the position array. While it is, a new snapshot or accelerator reloads the engine without starting it, so nothing moves the arrangement being restored.
Returns ​
boolean
True while one is.
Accessors ​
building ​
Get Signature ​
get building():
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:604
Whether a layout is being built now, spending its own pre-steps.
Returns ​
boolean
True while one is.
dimension ​
Get Signature ​
get dimension():
2|3|undefined
Defined in: graphty-element/src/managers/LayoutManager.ts:1558
The dimension the current engine was built for.
Returns ​
2 | 3 | undefined
2 or 3, or undefined before any engine is built.
edges ​
Get Signature ​
get edges():
Iterable<Edge>
Defined in: graphty-element/src/managers/LayoutManager.ts:2000
Get edges from layout engine
Returns ​
Iterable<Edge>
Iterable of edges managed by the layout engine
isPaused ​
Get Signature ​
get isPaused():
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:1984
Whether the layout was stopped before it converged, so its positions are not final.
Returns ​
boolean
True when the layout is not running and has not settled.
isSettled ​
Get Signature ​
get isSettled():
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:1976
Whether the layout engine has converged: the positions are final.
A layout that was stopped part-way is NOT settled; it is LayoutManager.isPaused. A reader that only needs "positions are not moving right now" asks !running || isSettled.
Returns ​
boolean
True when the engine has converged, or when there is no engine.
layoutEngine ​
Get Signature ​
get layoutEngine():
LayoutEngine|undefined
Defined in: graphty-element/src/managers/LayoutManager.ts:464
The engine drawing the graph, read-only: choose a layout with session.layout.set.
Returns ​
LayoutEngine | undefined
The engine, or undefined before the first build.
layoutType ​
Get Signature ​
get layoutType():
string|undefined
Defined in: graphty-element/src/managers/LayoutManager.ts:2008
Get current layout type
Returns ​
string | undefined
Current layout type identifier or undefined if no layout is set
nodes ​
Get Signature ​
get nodes():
Iterable<Node>
Defined in: graphty-element/src/managers/LayoutManager.ts:1992
Get nodes from layout engine
Returns ​
Iterable<Node>
Iterable of nodes managed by the layout engine
running ​
Get Signature ​
get running():
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:612
Gets the running state of the layout
Returns ​
boolean
True if layout is running, false otherwise
Set Signature ​
set running(
value):void
Defined in: graphty-element/src/managers/LayoutManager.ts:629
Sets the running state of the layout.
Going false -> true is "play", and a simulation that had SETTLED does nothing when it is stepped, so a reader who pressed play -- or let go of a node they dragged -- would watch a still graph. Resuming therefore reheats a settled simulation: the settle count starts again and the next frame moves nodes. Going true -> false only stops step() being called; batches already in flight land in the position array by themselves, nothing is disposed and nothing is released.
While the consumer has paused the layout (see LayoutManager.setPaused) a true is ignored, so the element's own restarts cannot undo the pause.
Parameters ​
value ​
boolean
Returns ​
void
Methods ​
dispose() ​
dispose():
void
Defined in: graphty-element/src/managers/LayoutManager.ts:982
Disposes of the layout manager and cleans up resources
Returns ​
void
Implementation of ​
getNodePosition() ​
getNodePosition(
node): [number,number,number] |undefined
Defined in: graphty-element/src/managers/LayoutManager.ts:1960
Get node position from layout engine
Parameters ​
node ​
Node to get position for
Returns ​
[number, number, number] | undefined
Node position as [x, y, z] or undefined if not available
getStats() ​
getStats():
object
Defined in: graphty-element/src/managers/LayoutManager.ts:2016
Get layout statistics
Returns ​
object
Object containing layout statistics
edgeCount ​
edgeCount:
number
isPaused ​
isPaused:
boolean
isRunning ​
isRunning:
boolean
isSettled ​
isSettled:
boolean
layoutType ​
layoutType:
string|undefined
nodeCount ​
nodeCount:
number
hasLayoutEngine() ​
hasLayoutEngine():
boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:2041
Check if layout engine is currently set
Returns ​
boolean
True if layout engine is set, false otherwise
init() ​
init():
Promise<void>
Defined in: graphty-element/src/managers/LayoutManager.ts:974
Initializes the layout manager
Returns ​
Promise<void>
Promise that resolves when initialization is complete
Implementation of ​
isCurrent() ​
isCurrent(
choice):boolean
Defined in: graphty-element/src/managers/LayoutManager.ts:1419
Whether the engine is built, or being built, for exactly this value of the layout slice. Compared by identity: a layout.set writes a new value even for the same layout, which is how asking for the same layout again runs it again.
Parameters ​
choice ​
LayoutChoice
The value.
Returns ​
boolean
True when nothing needs building for it.
loadArrangement() ​
loadArrangement(
restoring,wrote?):void
Defined in: graphty-element/src/managers/LayoutManager.ts:1522
Hand the engine the coordinates the arrangement hook has just written. After a restore, the pre-steps of any build still computing from the coordinates it held before are dropped.
A 2D ENGINE THEN PUTS EVERY NODE BACK ON THE PLANE, for the reason replayPins does: a Z written while the view is 2D -- a script's positions.set, a restore -- is hidden by the camera but drawn by the node's edges. The engine publishes the flattened row like any move.
Parameters ​
restoring ​
boolean
Whether undo, redo, a restore or a rollback wrote them.
wrote? ​
boolean = false
Whether anything was written into the lane, which forward is a positions.set.
Returns ​
void
setGraphContext() ​
setGraphContext(
context):void
Defined in: graphty-element/src/managers/LayoutManager.ts:728
Set the GraphContext for error reporting
This is also where the acceleration controller first becomes reachable: the manager is built before the graph finishes constructing itself, so it cannot be handed one.
Parameters ​
context ​
GraphContext instance
Returns ​
void
setPaused() ​
setPaused(
paused):void
Defined in: graphty-element/src/managers/LayoutManager.ts:674
Pause or resume the layout on a consumer's behalf.
A pause holds until the consumer resumes it: internal restarts are refused while it is set. Resuming runs the layout, and reheats a simulation that had settled.
Parameters ​
paused ​
boolean
True to pause, false to resume.
Returns ​
void
step() ​
step():
void
Defined in: graphty-element/src/managers/LayoutManager.ts:1921
Step the layout engine forward
Returns ​
void
stepBatch() ​
stepBatch():
void
Defined in: graphty-element/src/managers/LayoutManager.ts:1951
Step the layout ONCE, whatever the frame loop's multiplier is.
The name is the difference a reader of UpdateManager needs: a simulation layout does its whole frame's work in one call -- the batch it submits computes iterationsPerStep iterations -- so stepping it stepMultiplier times a frame would queue work the device cannot retire.
Returns ​
void
updatePositions() ​
updatePositions(
nodes):Promise<void>
Defined in: graphty-element/src/managers/LayoutManager.ts:2054
Settle nodes that reached the graph after this layout was already running.
Still hands back a promise, because a plugin that has to fetch or recompute something to place a newcomer will need one and the element's callers already await it; the work the engines here do is synchronous.
Parameters ​
nodes ​
Node[]
The nodes that have just arrived.
Returns ​
Promise<void>
A promise that resolves once the newcomers have been placed.
updateStyles() ​
updateStyles(
styles):void
Defined in: graphty-element/src/managers/LayoutManager.ts:966
Update the styles reference when a new style template is loaded
Parameters ​
styles ​
Styles
New styles instance
Returns ​
void