Class FastOrganicLayout

Extends GraphLayout to implement a fast organic layout algorithm. The vertices need to be connected for this layout to work, vertices with no connections are ignored.

Example:

const layout = new FastOrganicLayout(graph);
layout.execute(graph.getDefaultParent());

Hierarchy (view full)

Constructors

Properties

allowedToRun: boolean = true

Boolean flag that specifies if the layout is allowed to run. If this is set to false, then the layout exits in the following iteration.

cellLocation: any[] = []

An array of locally stored co-ordinate positions for the vertices.

disableEdgeStyle: boolean = true

Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result. Default is true.

dispX: number[] = []

An array of locally stored X co-ordinate displacements for the vertices.

dispY: number[] = []

An array of locally stored Y co-ordinate displacements for the vertices.

forceConstant: number = 50

The force constant by which the attractive forces are divided and the replusive forces are multiple by the square of. The value equates to the average radius there is of free space around each node. Default is 50.

forceConstantSquared: any = 0

Cache of ^2 for performance.

graph: Graph

Reference to the enclosing Graph.

indices: {
    [key: string]: number;
} = {}

Hashtable from cells to local indices.

initialTemp: number = 200

Start value of temperature. Default is 200.

isMoveable: boolean[] = []

Array of booleans representing the movable states of the vertices.

iteration: number = 0

Current iteration count.

maxDistanceLimit: number = 500

Maximal distance limit. Default is 500. Prevents of dividing by zero.

maxIterations: number = 0

Total number of iterations to run the layout though.

minDistanceLimit: number = 2

Minimal distance limit. Default is 2. Prevents of dividing by zero.

minDistanceLimitSquared: number = 4

Cached version of minDistanceLimit squared.

neighbours: {
    [key: number]: number[];
} = {}

Local copy of cell neighbours.

parent: null | Cell = null

The parent cell of the layout, if any

null
radius: number[] = []

The approximate radius of each cell, nodes only.

radiusSquared: number[] = []

The approximate radius squared of each cell, nodes only.

resetEdges: boolean = true

Specifies if all edge points of traversed edges should be removed. Default is true.

temperature: number = 0

Temperature to limit displacement at later stages of layout.

useBoundingBox: boolean = true

Boolean indicating if the bounding box of the label should be used if it iss available.

true.
useInputOrigin: boolean = true

Specifies if the top left corner of the input cells should be the origin of the layout result. Default is true.

vertexArray: Cell[] = []

An array of all vertices to be laid out.

Methods

  • Takes the displacements calculated for each cell and applies them to the local cache of cell positions. Limits the displacement to the current temperature.

    Returns void

  • Returns the constraint for the given key and cell. The optional edge and source arguments are used to return inbound and outgoing routing- constraints for the given edge and vertex. This implementation always returns the value for the given key in the style of the given cell.

    Parameters

    • key: string

      Key of the constraint to be returned.

    • cell: Cell

      Cell whose constraint should be returned.

    • Optionaledge: Cell

      Optional Cell that represents the connection whose constraint should be returned. Default is null.

    • Optionalsource: boolean

      Optional boolean that specifies if the connection is incoming or outgoing. Default is null.

    Returns any

  • Returns true if the given parent is an ancestor of the given child.

    Parameters

    • parent: Cell

      Cell that specifies the parent.

    • child: null | Cell

      Cell that specifies the child.

    • OptionaltraverseAncestors: boolean

      boolean whether to

    Returns boolean

  • Returns a boolean indicating if the given Cell is movable or bendable by the algorithm. This implementation returns true if the given cell is movable in the graph.

    Parameters

    • cell: Cell

      Cell whose movable state should be returned.

    Returns boolean

  • Notified when a cell is being moved in a parent that has automatic layout to update the cell state (eg. index) so that the outcome of the layout will position the vertex as close to the point (x, y) as possible.

    Empty implementation.

    Parameters

    • cell: Cell

      Cell which has been moved.

    • x: number

      X-coordinate of the new cell location.

    • y: number

      Y-coordinate of the new cell location.

    Returns void

  • Sets the new position of the given cell taking into account the size of the bounding box if useBoundingBox is true. The change is only carried out if the new location is not equal to the existing location, otherwise the geometry is not replaced with an updated instance. The new or old bounds are returned (including overlapping labels).

    Parameters

    • cell: Cell

      Cell whose geometry is to be set.

    • x: number

      Integer that defines the x-coordinate of the new location.

    • y: number

      Integer that defines the y-coordinate of the new location.

    Returns null | Rectangle

  • Traverses the (directed) graph invoking the given function for each visited vertex and edge. The function is invoked with the current vertex and the incoming edge as a parameter. This implementation makes sure each vertex is only visited once. The function may return false if the traversal should stop at the given vertex.

    Example:

    GlobalConfig.logger.show();
    const cell = graph.getSelectionCell();
    graph.traverse(cell, false, function(vertex, edge)
    {
    GlobalConfig.logger.debug(graph.getLabel(vertex));
    });

    Parameters

    • __namedParameters: GraphLayoutTraverseArgs

    Returns void