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

Layout that positions graph items 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
  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
  mass : Function
Function for assigning mass values to particles.
ForceDirectedLayout
  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
 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
Strips all EdgeSprites in a visualization of any control points.
Layout
 Inherited
Removes any control points from a DataSprite instance.
Layout
 Inherited
Hides the axes.
Layout
  
operate(t:Transitioner = null):void
Performs an operation over the contents of a visualization.
ForceDirectedLayout
 Inherited
setup():void
Setup method invoked whenever this operator's visualization property is set.
Operator
 Inherited
Reveals the axes.
Layout
 Inherited
Updates all edges to be straight lines.
Layout
Protected Methods
 MethodDefined by
  
init():void
Initializes the Simulation for this ForceDirectedLayout
ForceDirectedLayout
  
Transfer the physics simulation results to an item's layout.
ForceDirectedLayout
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

operate()method 
public override function operate(t:Transitioner = null):void

Performs an operation over the contents of a visualization.

Parameters
t:Transitioner (default = null) — a Transitioner instance for collecting value updates.
update()method 
protected function update(d:DataSprite):void

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

Parameters
d:DataSprite — a DataSprite