org.wilmascope.forcelayout
Class ForceLayout

java.lang.Object
  extended by org.wilmascope.graph.LayoutEngine<NodeForceLayout,EdgeForceLayout>
      extended by org.wilmascope.forcelayout.ForceLayout

public class ForceLayout
extends LayoutEngine<NodeForceLayout,EdgeForceLayout>

Main class force for calculating forces on all nodes and moving them incrementally.


Constructor Summary
ForceLayout()
           
 
Method Summary
 void addForce(Force force)
          Add a force to ForceLayout's list of forces to apply
 boolean applyLayout()
          apply the changes calculated by LayoutEngine.calculateLayout()
 void calculateLayout()
          calculate the changes required to move the graph to a nicer layout.
static ForceLayout createDefaultClusterForceLayout(Cluster root)
           
static ForceLayout createDefaultForceLayout(Cluster root)
           
 EdgeForceLayout createEdgeLayout(Edge e)
          Factory method to create a new EdgeLayout implementation compatible with the layout engine implementing this interface.
 NodeForceLayout createNodeLayout(Node n)
          Factory method to create a new NodeLayout implementation compatible with the layout engine implementing this interface.
 float getBalancedThreshold()
           
 javax.swing.JPanel getControls()
           
 Force getForce(java.lang.String name)
          Get a reference to one of our forces by name
 java.util.Vector getForces()
           
 int getLevels()
           
 float getLevelSeparation()
           
 java.lang.String getName()
          Return a string descriptor for the layout engine type.
 int getOrbits()
           
 float getOrbitSeparation()
           
 java.util.Properties getProperties()
          If you want custom properties for your layout you will need to override this method but be sure to super.getProperties()
 float getVelocityAttenuation()
           
 boolean isIterative()
          The iterationsPerFrameSlider should be enabled for iterative layouts (like force directed) and disabled for layouts that complete in a single step (sugiyama)
 void removeAllForces()
           
 void removeForce(Force force)
          Remove a force from ForceLayout's list of forces to apply
 void reset()
           
 void resetProperties()
          process your custom properties by overriding this method, but, again call super.resetProperties in your overriding implementation
 void setBalancedEventClient(BalancedEventClient c)
           
 void setBalancedThreshold(float threshold)
           
 void setConstrained()
           
 void setFrictionCoefficient(float friction)
           
 void setVelocityAttenuation(float va)
           
 
Methods inherited from class org.wilmascope.graph.LayoutEngine
getRoot, init, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForceLayout

public ForceLayout()
Method Detail

calculateLayout

public void calculateLayout()
Description copied from class: LayoutEngine
calculate the changes required to move the graph to a nicer layout. This method does not actually update the position of the nodes, rather this should be done by the LayoutEngine.applyLayout() method. Potentially, this means that the caller can calculate new positions (stored in the NodeLayouts), then opt not to apply the changes if it does not lead to an improvement. In practice this has not yet been utilised and such decisions are usually made internally to the layout engine.

Overrides:
calculateLayout in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

reset

public void reset()

applyLayout

public boolean applyLayout()
Description copied from class: LayoutEngine
apply the changes calculated by LayoutEngine.calculateLayout()

Specified by:
applyLayout in class LayoutEngine<NodeForceLayout,EdgeForceLayout>
Returns:
true when a stable state is reached

addForce

public void addForce(Force force)
Add a force to ForceLayout's list of forces to apply


removeForce

public void removeForce(Force force)
Remove a force from ForceLayout's list of forces to apply


removeAllForces

public void removeAllForces()

getForces

public java.util.Vector getForces()

getForce

public Force getForce(java.lang.String name)
Get a reference to one of our forces by name


setBalancedEventClient

public void setBalancedEventClient(BalancedEventClient c)

setBalancedThreshold

public void setBalancedThreshold(float threshold)

getBalancedThreshold

public float getBalancedThreshold()

getVelocityAttenuation

public float getVelocityAttenuation()

setVelocityAttenuation

public void setVelocityAttenuation(float va)

setConstrained

public void setConstrained()

createNodeLayout

public NodeForceLayout createNodeLayout(Node n)
Description copied from class: LayoutEngine
Factory method to create a new NodeLayout implementation compatible with the layout engine implementing this interface.

Specified by:
createNodeLayout in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

createEdgeLayout

public EdgeForceLayout createEdgeLayout(Edge e)
Description copied from class: LayoutEngine
Factory method to create a new EdgeLayout implementation compatible with the layout engine implementing this interface.

Specified by:
createEdgeLayout in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

setFrictionCoefficient

public void setFrictionCoefficient(float friction)

getControls

public javax.swing.JPanel getControls()
Specified by:
getControls in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

getName

public java.lang.String getName()
Description copied from class: LayoutEngine
Return a string descriptor for the layout engine type. Useful in GUI elements such as comboboxes

Specified by:
getName in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

getLevels

public int getLevels()

getLevelSeparation

public float getLevelSeparation()

getOrbits

public int getOrbits()

getOrbitSeparation

public float getOrbitSeparation()

getProperties

public java.util.Properties getProperties()
Description copied from class: LayoutEngine
If you want custom properties for your layout you will need to override this method but be sure to super.getProperties()

Overrides:
getProperties in class LayoutEngine<NodeForceLayout,EdgeForceLayout>
Returns:
properties of this layout

resetProperties

public void resetProperties()
Description copied from class: LayoutEngine
process your custom properties by overriding this method, but, again call super.resetProperties in your overriding implementation

Overrides:
resetProperties in class LayoutEngine<NodeForceLayout,EdgeForceLayout>

createDefaultForceLayout

public static ForceLayout createDefaultForceLayout(Cluster root)

createDefaultClusterForceLayout

public static ForceLayout createDefaultClusterForceLayout(Cluster root)

isIterative

public boolean isIterative()
Description copied from class: LayoutEngine
The iterationsPerFrameSlider should be enabled for iterative layouts (like force directed) and disabled for layouts that complete in a single step (sugiyama)

Overrides:
isIterative in class LayoutEngine<NodeForceLayout,EdgeForceLayout>
Returns:
false by default. Override to return true if layout engine is iterative.