de.cau.cs.kieler.klay.force.model
Class AbstractForceModel

java.lang.Object
  extended by de.cau.cs.kieler.core.alg.AbstractAlgorithm
      extended by de.cau.cs.kieler.klay.force.model.AbstractForceModel
All Implemented Interfaces:
IAlgorithm
Direct Known Subclasses:
EadesModel, FruchtermanReingoldModel

public abstract class AbstractForceModel
extends AbstractAlgorithm

Superclass for force models.

Rating red

Constructor Summary
AbstractForceModel()
           
 
Method Summary
static void avoidSamePosition(Random random, FParticle u, FParticle v)
          Avoid having nodes on the same position by moving them a little.
protected abstract  KVector calcDisplacement(FParticle forcer, FParticle forcee)
          Calculate a displacement for the given particles.
 FGraph getGraph()
          Return the graph for which the model was initialized.
protected  Random getRandom()
          Return the random number generator for this model.
protected  void initialize(FGraph fgraph)
          Initialize the force model with the given graph.
protected  void iterationDone()
          Perform all necessary calculations after a full iteration.
 void layout(FGraph fgraph)
          Perform layout on the given force graph.
protected abstract  boolean moreIterations(int count)
          Determine whether more iterations need to be performed.
 
Methods inherited from class de.cau.cs.kieler.core.alg.AbstractAlgorithm
getMonitor, reset, reset, setProgressMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractForceModel

public AbstractForceModel()
Method Detail

initialize

protected void initialize(FGraph fgraph)
Initialize the force model with the given graph. Subclasses that override this must call the superclass method first.

Parameters:
fgraph - a force graph

getGraph

public final FGraph getGraph()
Return the graph for which the model was initialized.

Returns:
the force graph

getRandom

protected final Random getRandom()
Return the random number generator for this model.

Returns:
the random number generator

layout

public void layout(FGraph fgraph)
Perform layout on the given force graph.

Parameters:
fgraph - a force graph

iterationDone

protected void iterationDone()
Perform all necessary calculations after a full iteration. Subclasses must call the superclass method first.


moreIterations

protected abstract boolean moreIterations(int count)
Determine whether more iterations need to be performed.

Parameters:
count - the current iterations count
Returns:
true if more iterations shall be done

calcDisplacement

protected abstract KVector calcDisplacement(FParticle forcer,
                                            FParticle forcee)
Calculate a displacement for the given particles.

Parameters:
forcer - the particle that is causing the force
forcee - the particle that is affected by the force
Returns:
a displacement vector for the forcee, or null if no force is applied

avoidSamePosition

public static void avoidSamePosition(Random random,
                                     FParticle u,
                                     FParticle v)
Avoid having nodes on the same position by moving them a little.

Parameters:
random - the random number generator
u - first node
v - second node