prefuse.util.force
Class ForceSimulator

java.lang.Object
  extended by prefuse.util.force.ForceSimulator

public class ForceSimulator
extends java.lang.Object

Manages a simulation of physical forces acting on bodies. To create a custom ForceSimulator, add the desired Force functions and choose an appropriate Integrator.

Author:
jeffrey heer

Constructor Summary
ForceSimulator()
          Create a new, empty ForceSimulator.
ForceSimulator(Integrator integr)
          Create a new, empty ForceSimulator.
 
Method Summary
 void accumulate()
          Accumulate all forces acting on the items in this simulation
 void addForce(Force f)
          Add a new Force function to the simulator.
 void addItem(ForceItem item)
          Add a ForceItem to the simulation.
 Spring addSpring(ForceItem item1, ForceItem item2)
          Add a Spring to the simulation.
 Spring addSpring(ForceItem item1, ForceItem item2, float length)
          Add a Spring to the simulation.
 Spring addSpring(ForceItem item1, ForceItem item2, float coeff, float length)
          Add a Spring to the simulation.
 void clear()
          Clear this simulator, removing all ForceItem and Spring instances for the simulator.
 Force[] getForces()
          Get an array of all the Force functions used in this simulator.
 Integrator getIntegrator()
          Get the Integrator used by this simulator.
 java.util.Iterator getItems()
          Get an iterator over all registered ForceItems.
 float getSpeedLimit()
          Get the speed limit, or maximum velocity value allowed by this simulator.
 java.util.Iterator getSprings()
          Get an iterator over all registered Springs.
 boolean removeItem(ForceItem item)
          Remove a ForceItem to the simulation.
 void runSimulator(long timestep)
          Run the simulator for one timestep.
 void setIntegrator(Integrator intgr)
          Set the Integrator used by this simulator.
 void setSpeedLimit(float limit)
          Set the speed limit, or maximum velocity value allowed by this simulator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForceSimulator

public ForceSimulator()
Create a new, empty ForceSimulator. A RungeKuttaIntegrator is used by default.


ForceSimulator

public ForceSimulator(Integrator integr)
Create a new, empty ForceSimulator.

Parameters:
integr - the Integrator to use
Method Detail

getSpeedLimit

public float getSpeedLimit()
Get the speed limit, or maximum velocity value allowed by this simulator.

Returns:
the "speed limit" maximum velocity value

setSpeedLimit

public void setSpeedLimit(float limit)
Set the speed limit, or maximum velocity value allowed by this simulator.

Parameters:
limit - the "speed limit" maximum velocity value to use

getIntegrator

public Integrator getIntegrator()
Get the Integrator used by this simulator.

Returns:
the Integrator

setIntegrator

public void setIntegrator(Integrator intgr)
Set the Integrator used by this simulator.

Parameters:
intgr - the Integrator to use

clear

public void clear()
Clear this simulator, removing all ForceItem and Spring instances for the simulator.


addForce

public void addForce(Force f)
Add a new Force function to the simulator.

Parameters:
f - the Force function to add

getForces

public Force[] getForces()
Get an array of all the Force functions used in this simulator.

Returns:
an array of Force functions

addItem

public void addItem(ForceItem item)
Add a ForceItem to the simulation.

Parameters:
item - the ForceItem to add

removeItem

public boolean removeItem(ForceItem item)
Remove a ForceItem to the simulation.

Parameters:
item - the ForceItem to remove

getItems

public java.util.Iterator getItems()
Get an iterator over all registered ForceItems.

Returns:
an iterator over the ForceItems.

addSpring

public Spring addSpring(ForceItem item1,
                        ForceItem item2)
Add a Spring to the simulation.

Parameters:
item1 - the first endpoint of the spring
item2 - the second endpoint of the spring
Returns:
the Spring added to the simulation

addSpring

public Spring addSpring(ForceItem item1,
                        ForceItem item2,
                        float length)
Add a Spring to the simulation.

Parameters:
item1 - the first endpoint of the spring
item2 - the second endpoint of the spring
length - the spring length
Returns:
the Spring added to the simulation

addSpring

public Spring addSpring(ForceItem item1,
                        ForceItem item2,
                        float coeff,
                        float length)
Add a Spring to the simulation.

Parameters:
item1 - the first endpoint of the spring
item2 - the second endpoint of the spring
coeff - the spring coefficient
length - the spring length
Returns:
the Spring added to the simulation

getSprings

public java.util.Iterator getSprings()
Get an iterator over all registered Springs.

Returns:
an iterator over the Springs.

runSimulator

public void runSimulator(long timestep)
Run the simulator for one timestep.

Parameters:
timestep - the span of the timestep for which to run the simulator

accumulate

public void accumulate()
Accumulate all forces acting on the items in this simulation



Copyright © 2007 Regents of the University of California