Skip to content

@graphty/graphty-element / layout/LayoutEngine / SimpleLayoutEngine

Abstract Class: SimpleLayoutEngine

Defined in: src/layout/LayoutEngine.ts:194

Base class for simple static layout engines that compute positions synchronously

Extends

Constructors

Constructor

new SimpleLayoutEngine(opts): SimpleLayoutEngine

Defined in: src/layout/LayoutEngine.ts:206

Create a simple layout engine

Parameters

opts

SimpleLayoutOpts = {}

Configuration options including scalingFactor

Returns

SimpleLayoutEngine

Overrides

LayoutEngine.constructor

Properties

config?

optional config: Record<string, unknown>

Defined in: src/layout/LayoutEngine.ts:39

Inherited from

LayoutEngine.config


isSettled

readonly isSettled: true = true

Defined in: src/layout/LayoutEngine.ts:341

Overrides

LayoutEngine.isSettled


maxDimensions

static maxDimensions: number

Defined in: src/layout/LayoutEngine.ts:38

Inherited from

LayoutEngine.maxDimensions


positions

positions: Record<string | number, number[]> = {}

Defined in: src/layout/LayoutEngine.ts:199


scalingFactor

scalingFactor: number = 100

Defined in: src/layout/LayoutEngine.ts:200


stale

stale: boolean = true

Defined in: src/layout/LayoutEngine.ts:198


type

static type: string

Defined in: src/layout/LayoutEngine.ts:195

Overrides

LayoutEngine.type


zodOptionsSchema?

static optional zodOptionsSchema: OptionsSchema

Defined in: src/layout/LayoutEngine.ts:47

NEW: Zod-based options schema for unified validation and UI metadata

Subclasses should override this to define their configurable options using the new Zod-based schema system.

Inherited from

LayoutEngine.zodOptionsSchema

Accessors

edges

Get Signature

get edges(): Iterable<Edge>

Defined in: src/layout/LayoutEngine.ts:337

Get all edges in the layout

Returns

Iterable<Edge>

Iterable of edges

Overrides

LayoutEngine.edges


nodes

Get Signature

get nodes(): Iterable<Node>

Defined in: src/layout/LayoutEngine.ts:329

Get all nodes in the layout

Returns

Iterable<Node>

Iterable of nodes

Overrides

LayoutEngine.nodes


type

Get Signature

get type(): string

Defined in: src/layout/LayoutEngine.ts:89

Get the type identifier for this layout engine

Returns

string

The layout engine type string

Inherited from

LayoutEngine.type

Methods

addEdge()

addEdge(e): void

Defined in: src/layout/LayoutEngine.ts:251

Add an edge to the layout and mark positions as stale

Parameters

e

Edge

The edge to add

Returns

void

Overrides

LayoutEngine.addEdge


addEdges()

addEdges(edges): void

Defined in: src/layout/LayoutEngine.ts:79

Add multiple edges to the layout engine

Parameters

edges

Edge[]

Array of edges to add

Returns

void

Inherited from

LayoutEngine.addEdges


addNode()

addNode(n): void

Defined in: src/layout/LayoutEngine.ts:242

Add a node to the layout and mark positions as stale

Parameters

n

Node

The node to add

Returns

void

Overrides

LayoutEngine.addNode


addNodes()

addNodes(nodes): void

Defined in: src/layout/LayoutEngine.ts:69

Add multiple nodes to the layout engine

Parameters

nodes

Node[]

Array of nodes to add

Returns

void

Inherited from

LayoutEngine.addNodes


doLayout()

abstract doLayout(): void

Defined in: src/layout/LayoutEngine.ts:343

Returns

void


get()

static get(type, opts): LayoutEngine | null

Defined in: src/layout/LayoutEngine.ts:111

Get a layout engine instance by type

Parameters

type

string

The layout engine type identifier

opts

object = {}

Configuration options for the layout engine

Returns

LayoutEngine | null

A new layout engine instance or null if type not found

Inherited from

LayoutEngine.get


getClass()

static getClass(type): LayoutEngineClass & LayoutEngineStatics | null

Defined in: src/layout/LayoutEngine.ts:180

Get a layout class by type

Parameters

type

string

The layout engine type identifier

Returns

LayoutEngineClass & LayoutEngineStatics | null

The layout engine class or null if not found

Inherited from

LayoutEngine.getClass


getEdgePosition()

getEdgePosition(e): EdgePosition

Defined in: src/layout/LayoutEngine.ts:284

Get the position of an edge based on its endpoints

Parameters

e

Edge

The edge to get position for

Returns

EdgePosition

The edge's source and destination positions

Overrides

LayoutEngine.getEdgePosition


getNodePosition()

getNodePosition(n): Position

Defined in: src/layout/LayoutEngine.ts:261

Get the position of a node, computing layout if stale

Parameters

n

Node

The node to get position for

Returns

Position

The node's position coordinates

Overrides

LayoutEngine.getNodePosition


getOptionsForDimension()

static getOptionsForDimension(dimension): object | null

Defined in: src/layout/LayoutEngine.ts:217

Get dimension-specific options for simple layouts

Parameters

dimension

The desired dimension (2 or 3)

2 | 3

Returns

object | null

Options object with dim parameter or null if unsupported

Overrides

LayoutEngine.getOptionsForDimension


getOptionsForDimensionByType()

static getOptionsForDimensionByType(type, dimension): object | null

Defined in: src/layout/LayoutEngine.ts:142

Get dimension-specific options for a layout by type

Parameters

type

string

The layout engine type identifier

dimension

The desired dimension (2 or 3)

2 | 3

Returns

object | null

Options object for the dimension or null if type not found or unsupported

Inherited from

LayoutEngine.getOptionsForDimensionByType


getRegisteredTypes()

static getRegisteredTypes(): string[]

Defined in: src/layout/LayoutEngine.ts:171

Get a list of all registered layout types

Returns

string[]

Array of registered layout type identifiers

Inherited from

LayoutEngine.getRegisteredTypes


getZodOptionsSchema()

static getZodOptionsSchema(): OptionsSchema

Defined in: src/layout/LayoutEngine.ts:155

Get the Zod-based options schema for this layout

Returns

OptionsSchema

The options schema, or an empty object if no schema defined

Inherited from

LayoutEngine.getZodOptionsSchema


hasZodOptions()

static hasZodOptions(): boolean

Defined in: src/layout/LayoutEngine.ts:163

Check if this layout has a Zod-based options schema

Returns

boolean

true if the layout has options defined

Inherited from

LayoutEngine.hasZodOptions


init()

init(): Promise<void>

Defined in: src/layout/LayoutEngine.ts:234

Initialize the layout engine

Simple layouts compute positions synchronously and don't require initialization.

Returns

Promise<void>

Overrides

LayoutEngine.init


pin()

pin(): void

Defined in: src/layout/LayoutEngine.ts:311

Pin a node in place

Simple layouts are static and don't support interactive node pinning.

Returns

void

Overrides

LayoutEngine.pin


register()

static register<T>(cls): T

Defined in: src/layout/LayoutEngine.ts:98

Register a layout engine class in the global registry

Type Parameters

T

T extends LayoutEngineClass

Parameters

cls

T

The layout engine class to register

Returns

T

The registered class for chaining

Inherited from

LayoutEngine.register


setNodePosition()

setNodePosition(): void

Defined in: src/layout/LayoutEngine.ts:275

Set node position

Simple layouts are static and recompute all positions from scratch, so individual position setting is not supported.

Returns

void

Overrides

LayoutEngine.setNodePosition


step()

step(): void

Defined in: src/layout/LayoutEngine.ts:302

Step the layout animation

Simple layouts are static and don't animate, so stepping has no effect.

Returns

void

Overrides

LayoutEngine.step


unpin()

unpin(): void

Defined in: src/layout/LayoutEngine.ts:320

Unpin a node

Simple layouts are static and don't support interactive node pinning.

Returns

void

Overrides

LayoutEngine.unpin