Skip to content

core/ShapeStore

Classes

ShapeStore

Defined in: core/ShapeStore.ts:93

ShapeStore - name-indexed storage for simulation shapes (polygons, polylines) with change notification. The StateManager facade delegates here. Shapes belong to the simulation, so they are cleared on node switches and resets rather than persisted like user preferences.

Constructors

Constructor
new ShapeStore(): ShapeStore;
Returns

ShapeStore

Accessors

size
Get Signature
get size(): number;

Defined in: core/ShapeStore.ts:254

Get shape count

Returns

number

Methods

subscribe()
subscribe(listener): () => void;

Defined in: core/ShapeStore.ts:101

Subscribe to shape changes Returns unsubscribe function

Parameters
listener

ShapeChangeListener

Returns

() => void

notifyListeners()
notifyListeners(): void;

Defined in: core/ShapeStore.ts:111

Notify all shape listeners of changes

Returns

void

add()
add(shape, notify?): void;

Defined in: core/ShapeStore.ts:126

Add or update a shape

Parameters
shape

Shape

notify?

boolean = true

If false, don't notify listeners (for batch updates)

Returns

void

addBatch()
addBatch(shapes): void;

Defined in: core/ShapeStore.ts:138

Add multiple shapes in a batch (only notifies once)

Parameters
shapes

Shape[]

Returns

void

addPolyData()
addPolyData(data, nodeId?): void;

Defined in: core/ShapeStore.ts:147

Add or update shape from server PolyData format

Parameters
data

PolyData

nodeId?

string

Returns

void

addPolylineData()
addPolylineData(data, nodeId?): void;

Defined in: core/ShapeStore.ts:158

Add or update shape from server PolylineData format

Parameters
data

PolylineData

nodeId?

string

Returns

void

delete()
delete(name): boolean;

Defined in: core/ShapeStore.ts:169

Delete a shape by name

Parameters
name

string

Returns

boolean

get()
get(name): Shape | undefined;

Defined in: core/ShapeStore.ts:181

Get a shape by name

Parameters
name

string

Returns

Shape | undefined

getAll()
getAll(): Map<string, Shape>;

Defined in: core/ShapeStore.ts:188

Get all shapes

Returns

Map\<string, Shape>

getByType()
getByType<T>(type): Shape[];

Defined in: core/ShapeStore.ts:195

Get shapes by type

Type Parameters
T

T extends "polygon" | "polyline" | "circle" | "rectangle"

Parameters
type

T

Returns

Shape[]

getByNode()
getByNode(nodeId): Shape[];

Defined in: core/ShapeStore.ts:204

Get shapes for a specific node

Parameters
nodeId

string

Returns

Shape[]

clear()
clear(): void;

Defined in: core/ShapeStore.ts:214

Clear all shapes Called when switching nodes or resetting simulation

Returns

void

clearForNode()
clearForNode(nodeId): void;

Defined in: core/ShapeStore.ts:223

Clear shapes for a specific node

Parameters
nodeId

string

Returns

void

setVisibility()
setVisibility(name, visible): void;

Defined in: core/ShapeStore.ts:243

Update shape visibility

Parameters
name

string

visible

boolean

Returns

void

Type Aliases

ShapeChangeListener

type ShapeChangeListener = (shapes) => void;

Defined in: core/ShapeStore.ts:5

Parameters

shapes

Map\<string, Shape>

Returns

void

Functions

polyDataToShape()

function polyDataToShape(data, nodeId?): PolygonShape;

Defined in: core/ShapeStore.ts:11

Convert server PolyData ({name, lat[], lon[], color?, fill?}) to a client PolygonShape ({type, name, coordinates: {lat, lng}[], ...styling}).

Parameters

data

PolyData

nodeId?

string

Returns

PolygonShape


polylineDataToShape()

function polylineDataToShape(data, nodeId?): PolylineShape;

Defined in: core/ShapeStore.ts:54

Convert server PolylineData ({name, lat[], lon[], color?, width?}) to a client PolylineShape ({type, name, coordinates: {lat, lng}[], ...styling}).

Parameters

data

PolylineData

nodeId?

string

Returns

PolylineShape