Packageflare.vis.operator.layout
Classpublic class ForceDirectedLayout
InheritanceForceDirectedLayout Inheritance Layout Inheritance Operator

Layout that places nodes based on a physics simulation of interacting forces. By default, nodes repel each other, edges act as springs, and drag forces (similar to air resistance) are applied. This algorithm can be run for multiple iterations for a run-once layout computation or repeatedly run in an animated fashion for a dynamic and interactive layout (set Visualization.continuousUpdates = true ).

The running time of this layout algorithm is the greater of O(N log N) and O(E), where N is the number of nodes and E the number of edges. The addition of custom forces to the simulation may affect this.

The force directed layout is implemented using the physics simulator provided by the flare.physics package. The Simulation used to drive this layout can be set explicitly, allowing any number of custom force directed layouts to be created through the selection of IForce modules. Each node in the layout is mapped to a Particle instance and each edge to a Spring in the simulation. Once the simulation has been initialized, you can retrieve these instances through the node.props.particle and edge.props.spring properties, respectively.

See also

flare.physics


Public Properties
 PropertyDefined by
  damping : Function
Function for assigning damping constant values to springs.
ForceDirectedLayout
  defaultParticleMass : Number
The default mass value for node/particles.
ForceDirectedLayout
  defaultSpringLength : Number
The default spring rest length for edge/springs.
ForceDirectedLayout
  defaultSpringTension : Number
The default spring tension for edge/springs.
ForceDirectedLayout
 Inheritedenabled : Boolean
Indicates if the operator is enabled or disabled.
Operator
  enforceBounds : Boolean
Flag indicating if the layout bounds should be enforced.
ForceDirectedLayout
  iterations : int
The number of iterations to run the simulation per invocation (default is 1, expecting continuous updates).
ForceDirectedLayout
 InheritedlayoutAnchor : Point
The layout anchor, used by some layout instances to place an initial item or determine a focal point.
Layout
 InheritedlayoutBounds : Rectangle
The layout bounds for the layout.
Layout
 InheritedlayoutRoot : DataSprite
The layout root, the root node for tree layouts.
Layout
 InheritedlayoutType : String = "null"
The type of layout and axes.
Layout
  mass : Function
Function for assigning mass values to particles.
ForceDirectedLayout
 Inheritedparameters : Object
Sets parameter values for this operator.
Operator
  restLength : Function
Function for assigning rest length values to springs.
ForceDirectedLayout
  simulation : Simulation
[read-only] The physics simulation driving this layout.
ForceDirectedLayout
  tension : Function
Function for assigning tension values to springs.
ForceDirectedLayout
  ticksPerIteration : int
The number of time ticks to advance the simulation on each iteration (default is 1).
ForceDirectedLayout
 Inheritedvisualization : Visualization
The visualization processed by this operator.
Operator
Protected Properties
 PropertyDefined by
 Inherited_anchor : Point
Layout
 Inherited_setAnchor : Boolean = false
Layout
 Inherited_t : Transitioner = null
A transitioner for storing value updates.
Layout
 InheritedxyAxes : CartesianAxes
Returns the visualization's axes as a CartesianAxes instance.
Layout
Public Methods
 MethodDefined by
  
ForceDirectedLayout(enforceBounds:Boolean = false, iterations:int = 1, sim:Simulation = null)
Creates a new ForceDirectedLayout.
ForceDirectedLayout
 Inherited
applyParameters(op:IOperator, params:Object):void
[static] Static method that applies parameter settings to an operator.
Operator
 Inherited
Strips all EdgeSprites in a visualization of any control points.
Layout
 Inherited
Hides the axes.
Layout
 Inherited
operate(t:Transitioner = null):void
Performs an operation over the contents of a visualization.
Layout
 Inherited
setup():void
Setup method invoked whenever this operator's visualization property is set.
Operator
 Inherited
Reveals the axes.
Layout
 Inherited
[static] Updates all edges to be straight lines.
Layout
Protected Methods
 MethodDefined by
 Inherited
autoAnchor():void
Automatically-generate an anchor point.
Layout
  
init():void
Initializes the Simulation for this ForceDirectedLayout
ForceDirectedLayout
  
layout():void
Calculates the spatial layout of visualized items.
ForceDirectedLayout
 Inherited
minAngle(a1:Number, a2:Number):Number
Returns an angle value that minimizes the angular distance between a reference angle and a target angle.
Layout
  
Transfer the physics simulation results to an item's layout.
ForceDirectedLayout
Public Constants
 ConstantDefined by
 InheritedCARTESIAN : String = "cartesian"
[static] Constant indicating Cartesian (x, y) coordinates.
Layout
 InheritedPOLAR : String = "polar"
[static] Constant indicating polar (radius, angle) coordinates.
Layout
Property detail
dampingproperty
public var damping:Function

Function for assigning damping constant values to springs. By default, this simply uses the spring's computed tension value divided by 10. This function can be replaced to perform custom damping assignment.

defaultParticleMassproperty 
defaultParticleMass:Number  [read-write]

The default mass value for node/particles.

Implementation
    public function get defaultParticleMass():Number
    public function set defaultParticleMass(value:Number):void
defaultSpringLengthproperty 
defaultSpringLength:Number  [read-write]

The default spring rest length for edge/springs.

Implementation
    public function get defaultSpringLength():Number
    public function set defaultSpringLength(value:Number):void
defaultSpringTensionproperty 
defaultSpringTension:Number  [read-write]

The default spring tension for edge/springs.

Implementation
    public function get defaultSpringTension():Number
    public function set defaultSpringTension(value:Number):void
enforceBoundsproperty 
enforceBounds:Boolean  [read-write]

Flag indicating if the layout bounds should be enforced. If true, the layoutBounds will limit node placement.

Implementation
    public function get enforceBounds():Boolean
    public function set enforceBounds(value:Boolean):void
iterationsproperty 
iterations:int  [read-write]

The number of iterations to run the simulation per invocation (default is 1, expecting continuous updates).

Implementation
    public function get iterations():int
    public function set iterations(value:int):void
massproperty 
public var mass:Function

Function for assigning mass values to particles. By default, this simply returns the default mass value. This function can be replaced to perform custom mass assignment.

restLengthproperty 
public var restLength:Function

Function for assigning rest length values to springs. By default, this simply returns the default rest length value. This function can be replaced to perform custom rest length assignment.

simulationproperty 
simulation:Simulation  [read-only]

The physics simulation driving this layout.

Implementation
    public function get simulation():Simulation
tensionproperty 
public var tension:Function

Function for assigning tension values to springs. By default, this method computes spring tension adaptively, based on the connectivity of the attached particles, to create more stable layouts. More specifically, the tension is computed as the default tension value divided by the square root of the maximum degree of the attached particles. This function can be replaced to perform custom tension assignment.

ticksPerIterationproperty 
ticksPerIteration:int  [read-write]

The number of time ticks to advance the simulation on each iteration (default is 1).

Implementation
    public function get ticksPerIteration():int
    public function set ticksPerIteration(value:int):void
Constructor detail
ForceDirectedLayout()constructor
public function ForceDirectedLayout(enforceBounds:Boolean = false, iterations:int = 1, sim:Simulation = null)

Creates a new ForceDirectedLayout.

Parameters
enforceBounds:Boolean (default = false) — the number of iterations to run the simulation per invocation
 
iterations:int (default = 1) — the physics simulation to use for the layout. If null (the default), default simulation settings will be used
 
sim:Simulation (default = null)
Method detail
init()method
protected function init():void

Initializes the Simulation for this ForceDirectedLayout

layout()method 
protected override function layout():void

Calculates the spatial layout of visualized items. Layout operators override this method with their layout implementations.

update()method 
protected function update(d:DataSprite):void

Transfer the physics simulation results to an item's layout.

Parameters
d:DataSprite — a DataSprite