Skip to main content

Home > @jsplumbtoolkit/core > AbstractLayout

AbstractLayout class

Base class for all layouts.

Signature:

export declare abstract class AbstractLayout<P extends LayoutParameters> 

Constructors

ConstructorModifiersDescription
(constructor)(params)Constructs a new instance of the AbstractLayout class

Properties

PropertyModifiersTypeDescription
_locationFunctionLocationFunction
_maxxnumber
_maxynumber
_minxnumber
_minynumber
_vertexMapRecord<string, Node | Group>
_verticesArray<Node | Group>
adapterAbstractLayoutAdapter<any>
containerany
containerSizeSize
defaultMagnetizedboolean
doneboolean
entriesRecord<string, LayoutEntry>
heightnumber
magnetizerMagnetizer<string>
magnetizerIterationsnumber
negativeValuesAllowedboolean
paddingPointXY
parametersP
positionArrayArray<any>
positionsMap<string, PointXY>
sizesMap<string, Size>
toolkitJsPlumbToolkit
typestring
widthnumber
xmaxArray<any>
xminArray<any>
ymaxArray<any>
yminArray<any>

Methods

MethodModifiersDescription
_getRandomPosition(id, w, h, doNotCalculateExtents)
_getSize(id)Gets the size of the vertex with the given id, retrieving from the viewport and caching it for later use if not found locally. It is cached only for the duration of one run of the layout.
_magnetizerFilter(id)Subclasses that use defaultMagnetized may wish to override this to filter out candidates for the magnetizer.
_reset()
begin(toolkit, parameters)This is an abstract function that subclasses may implement if they wish. It will be called at the beginning of a layout.
canMagnetize(id)
dumpPos()
end(toolkit, parameters, wasMagnetized)This is an abstract function that subclasses may implement if they wish. It will be called at the end of a layout.
getDefaultParameters()
getPosition(id)Get the current position for the vertex with the given ID.
getPositions()Gets the current positions held by the layout.
getSizes()
layout(onComplete, magnetizeAfterLayout)Runs the layout, without resetting calculated or user-provided positions beforehand. If the subclass has defined a begin method, that will be called first. Then, the subclass's step method will be called repeatedly, until the subclass makes a call to _super.setDone.
magnetize(params, internal)Run the magnetizer.
relayout(newParameters, onComplete, magnetizeAfterLayout)Runs the layout, first doing a reset of element positions. Next, if the subclass has defined a begin method, that will be called first. Then, the subclass's step method will be called repeatedly, until the subclass makes a call to _super.setDone. Use the layout method to run the layout incrementally without first resetting everything.
reset()
setPosition(id, x, y, doNotCalculateExtents)Sets the position of the node/group with the given id, and recalculates the extents.
setSize(id, s)Sets what the layout considers to be the size of the node with the given id. This method is not generally necessary if you use the layout methods on the surface widget.
snapToGrid(grid, elementId)Uses the magnetizer to snap either all the elements in the layout, or a single element, to a grid.
step(toolkit, parameters)Step through the layout. For some layouts there is only a single step, but others continue stepping until some condition is met. Once the condition is met, the subclass must set this.done = true, or the layout will continue looping indefinitely.
vertexAdded(params, eventInfo)

Called by components to inform a layout that a new Node was added. You should never call this method directly. Also, you should not override this method in a custom layout: if your layout needs to track Node addition, implement _nodeAdded instead.

This method is only ever called after a layout has been run and some change has been made to the data model. When the layout is run again, the layout's list of vertices is completely refreshed.

vertexRemoved(vertex, doNotCalculateExtents)Called by components to inform a layout that a given vertex was removed. You should never call this method directly.