org.wilmascope.forcelayout
Class Spring

java.lang.Object
  extended by org.wilmascope.patterns.Prototype
      extended by org.wilmascope.forcelayout.Force
          extended by org.wilmascope.forcelayout.Spring
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Spring
extends Force

A Force for use by nodes connected by an edge. Attempts to restore the distance between nodes to the natural length of that edge.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.wilmascope.forcelayout.Force
strengthConstant
 
Constructor Summary
Spring(float strengthConstant)
          Creates a new Spring with the given strength
 
Method Summary
 void calculate()
          Calculate node deltas due to spring forces between all nodes connected by an edge
 void setCluster(Cluster root)
           
 
Methods inherited from class org.wilmascope.forcelayout.Force
getStrengthConstant, setStrengthConstant, toString
 
Methods inherited from class org.wilmascope.patterns.Prototype
clone, getTypeName, setTypeName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Spring

public Spring(float strengthConstant)
Creates a new Spring with the given strength

Parameters:
strengthConstant - k in Hooke's Law
Method Detail

setCluster

public void setCluster(Cluster root)
Specified by:
setCluster in class Force

calculate

public void calculate()
Calculate node deltas due to spring forces between all nodes connected by an edge

Specified by:
calculate in class Force