Packageorg.un.flex.graphLayout.layout
Classpublic class ForceDirectedLayouter
InheritanceForceDirectedLayouter Inheritance IterativeBaseLayouter Inheritance BaseLayouter
ImplementsILayoutAlgorithm

This is an implementation of the ForceDirected/SpringGraph Layouting algorithm. The implementation took the general idea from Mark Shepherd's SpringGraph component implementation which is itself based on TouchGraph (Java). However, apart from the general idea and some variable names, the code is a rewrite.
Here is the copyright information that was part of the code. I add it just in case someone might feel offended if it is not there:

Copyright of the original TouchGraph LLC code: (c) 2001-2002 Alexander Shapiro. All rights reserved. Copyright of the adaption to Flex: (c) Mark Shepherd, Adobe FlexBuilder Engineering, 2006. Copyright of this reimplementation in Flex: (c) Daniel Lang, United Nations, 2007.

See license infortmation at the top.



Public Properties
 PropertyDefined by
 InheritedanimInProgress : Boolean
Indicator if currently an animation sequence is still in progress.
BaseLayouter
 InheritedautoFitEnabled : Boolean
BaseLayouter
  dampingActive : Boolean
This is a specific method for this layouter and specifies if damping should be used or not.
ForceDirectedLayouter
 InheriteddisableAnimation : Boolean
If set to true, animation is disabled and direct node location setting occurs (instantaneously).
BaseLayouter
 Inheritedgraph : IGraph
Assign a Graph datastructure object to the layouter, every layouter will need one to work and some may allow to set it in their constructor
BaseLayouter
 InheritedlayoutChanged : Boolean
BaseLayouter
  linkLength : Number
Access to a value that controls the length of links (or rather edges).
ForceDirectedLayouter
  rigidity : Number
[write-only] This is a local parameter specific to this layouter, that may be accessed from outside, if required.
ForceDirectedLayouter
 Inheritedvgraph : IVisualGraph
Assign a VisualGraph object to the layouter, every layouter will need one to work, some may also offer to set it in their constructor.
BaseLayouter
Protected Properties
 PropertyDefined by
 Inherited_autoFitEnabled : Boolean = false
The indicator if AutoFit should currently be used or not.
BaseLayouter
 InheritedcurrentDrawing : BaseLayoutDrawing
Allow to set the reference to the drawing object from derived classes.
BaseLayouter
 Inherited_disableAnimation : Boolean = false
If set to true, animation is disabled and direct node location setting occurs (instantaneously).
BaseLayouter
 Inherited_dragNode : IVisualNode = null
IterativeBaseLayouter
 Inherited_graph : IGraph = null
All layouters need access to the Graph.
BaseLayouter
 Inherited_layoutChanged : Boolean = false
This keeps track if the layout has changed and can be accessed by any derived layouter.
BaseLayouter
 Inherited_root : INode
The current root node of the layout.
BaseLayouter
 Inherited_stree : IGTree
A spanning tree of the graph, since probably every layout will work on a spanning tree, we keep this one in this base class.
BaseLayouter
 Inherited_vgraph : IVisualGraph = null
All layouters need access to the VisualGraph.
BaseLayouter
Public Methods
 MethodDefined by
  
The constructor only initialises the data structures and presets some parameters.
ForceDirectedLayouter
 Inherited
bgDragContinue(event:MouseEvent):void
This is a NOP for this layouter.
BaseLayouter
 Inherited
bgDragEvent(event:MouseEvent):void
This is a NOP for this layouter.
BaseLayouter
 Inherited
bgDropEvent(event:MouseEvent):void
This is a NOP for this layouter.
BaseLayouter
  
dragContinue(event:MouseEvent, vn:IVisualNode):void
Mouse Event Handling Methods
ForceDirectedLayouter
 Inherited
dragEvent(event:MouseEvent, vn:IVisualNode):void
This method notifies the layouter about a drag/drop operation.
IterativeBaseLayouter
  
dropEvent(event:MouseEvent, vn:IVisualNode):void
Notifies the layouter of a node drop event, in case it wants to react to that in special way.
ForceDirectedLayouter
 Inherited
layoutPass():Boolean
This is the actual method that does a layout pass.
IterativeBaseLayouter
  
refreshInit():void
In this implementation, this method resets the damper value.
ForceDirectedLayouter
  
resetAll():void
Reset all layouting parameters, which may be required during a significant layout change.
ForceDirectedLayouter
Protected Methods
 MethodDefined by
 Inherited
Sets the current absolute target coordinates of a node in the node's vnode.
BaseLayouter
 Inherited
applyTargetToNodes(vns:Dictionary):void
Applies the target coordinates to all nodes that are in the Dictionary object passed as argument.
BaseLayouter
  
Layout Methods - Computational Methods
ForceDirectedLayouter
  
isStable():Boolean
ForceDirectedLayouter
 Inherited
layoutIteration():Boolean
Do a full calculation iteration of the layout.
IterativeBaseLayouter
Public Constants
 ConstantDefined by
 InheritedDEFAULT_MARGIN : Number = 30
[static] The default margin to be considered when using autoFit.
BaseLayouter
 InheritedMINIMUM_NODE_HEIGHT : Number = 5
[static] The default minimum node height to be used if the exact node height cannot be determined yet.
BaseLayouter
 InheritedMINIMUM_NODE_WIDTH : Number = 5
[static] The default minimum node width to be used if the exact node height cannot be determined yet.
BaseLayouter
Property detail
dampingActiveproperty
dampingActive:Boolean  [read-write]

This is a specific method for this layouter and specifies if damping should be used or not.

Implementation
    public function get dampingActive():Boolean
    public function set dampingActive(value:Boolean):void
linkLengthproperty 
linkLength:Number  [read-write]

Access to a value that controls the length of links (or rather edges). It is up to the layouter what to do with it, and some may ignore this value under certain circumstances (like autoFit). The interface requires the value to be between 0 and 100;

Implementation
    public function get linkLength():Number
    public function set linkLength(value:Number):void
rigidityproperty 
rigidity:Number  [write-only]

This is a local parameter specific to this layouter, that may be accessed from outside, if required. It handles how flexible the springy edges are.

Implementation
    public function set rigidity(value:Number):void
Constructor detail
ForceDirectedLayouter()constructor
public function ForceDirectedLayouter(vg:IVisualGraph = null)

The constructor only initialises the data structures and presets some parameters.

Parameters
vg:IVisualGraph (default = null)
Method detail
calculateLayout()method
protected override function calculateLayout():void

Layout Methods - Computational Methods

dragContinue()method 
public override function dragContinue(event:MouseEvent, vn:IVisualNode):void

Mouse Event Handling Methods

Parameters
event:MouseEvent
 
vn:IVisualNode
dropEvent()method 
public override function dropEvent(event:MouseEvent, vn:IVisualNode):void

Notifies the layouter of a node drop event, in case it wants to react to that in special way.

Parameters
event:MouseEvent
 
vn:IVisualNode
isStable()method 
protected override function isStable():Boolean

Returns
Boolean
refreshInit()method 
public override function refreshInit():void

In this implementation, this method resets the damper value.

resetAll()method 
public override function resetAll():void

Reset all layouting parameters, which may be required during a significant layout change. This is particularily important in this layouter, as it constantly updates the layout (using the timer).