UNPKG

@maxgraph/core

Version:

maxGraph is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.

148 lines (147 loc) 4.45 kB
import GraphLayout from './GraphLayout.js'; import type { AbstractGraph } from '../AbstractGraph.js'; import type Cell from '../cell/Cell.js'; /** * Extends {@link 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: * * ```javascript * const layout = new FastOrganicLayout(graph); * layout.execute(graph.getDefaultParent()); * ``` * * @category Layout */ declare class FastOrganicLayout extends GraphLayout { constructor(graph: AbstractGraph); /** * Specifies if the top left corner of the input cells should be the origin of the layout result. Default is true. */ useInputOrigin: boolean; /** * Specifies if all edge points of traversed edges should be removed. Default is true. */ resetEdges: boolean; /** * Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result. Default is true. */ disableEdgeStyle: boolean; /** * 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. */ forceConstant: number; /** * Cache of <forceConstant>^2 for performance. */ forceConstantSquared: any; /** * Minimal distance limit. Default is 2. Prevents of dividing by zero. */ minDistanceLimit: number; /** * Maximal distance limit. Default is 500. Prevents of * dividing by zero. */ maxDistanceLimit: number; /** * Cached version of minDistanceLimit squared. */ minDistanceLimitSquared: number; /** * Start value of temperature. Default is 200. */ initialTemp: number; /** * Temperature to limit displacement at later stages of layout. */ temperature: number; /** * Total number of iterations to run the layout though. */ maxIterations: number; /** * Current iteration count. */ iteration: number; /** * An array of all vertices to be laid out. */ vertexArray: Cell[]; /** * An array of locally stored X co-ordinate displacements for the vertices. */ dispX: number[]; /** * An array of locally stored Y co-ordinate displacements for the vertices. */ dispY: number[]; /** * An array of locally stored co-ordinate positions for the vertices. */ cellLocation: any[]; /** * The approximate radius of each cell, nodes only. */ radius: number[]; /** * The approximate radius squared of each cell, nodes only. */ radiusSquared: number[]; /** * Array of booleans representing the movable states of the vertices. */ isMoveable: boolean[]; /** * Local copy of cell neighbours. */ neighbours: { [key: number]: number[]; }; /** * Hashtable from cells to local indices. */ indices: { [key: string]: number; }; /** * 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. */ allowedToRun: boolean; /** * Returns a boolean indicating if the given <Cell> should be ignored as a * vertex. This returns true if the cell has no connections. * * @param vertex <Cell> whose ignored state should be returned. */ isVertexIgnored(vertex: Cell): boolean; /** * Implements {@link GraphLayout#execute}. This operates on all children of the * given parent where <isVertexIgnored> returns false. */ execute(parent: Cell): void; /** * Takes the displacements calculated for each cell and applies them to the * local cache of cell positions. Limits the displacement to the current * temperature. */ calcPositions(): void; /** * Calculates the attractive forces between all laid out nodes linked by * edges */ calcAttraction(): void; /** * Calculates the repulsive forces between all laid out nodes */ calcRepulsion(): void; /** * Reduces the temperature of the layout from an initial setting in a linear * fashion to zero. */ reduceTemperature(): void; } export default FastOrganicLayout;