prefuse.util.force
Class ForceSimulatorImpl

java.lang.Object
  extended by prefuse.util.force.ForceSimulatorImpl
All Implemented Interfaces:
ForceSimulator

public class ForceSimulatorImpl
extends java.lang.Object
implements ForceSimulator

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
ForceSimulatorImpl()
          Create a new, empty ForceSimulator.
ForceSimulatorImpl(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()
           
 java.util.List<ForceItem> getItems()
          Get an iterator over all registered ForceItems.
 float getSpeedLimit()
          Get the speed limit, or maximum velocity value allowed by this simulator.
 java.util.List<Spring> 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)
           
 void setSpeedLimit(float limit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForceSimulatorImpl

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


ForceSimulatorImpl

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

Parameters:
integr - the Integrator to use
Method Detail

getSpeedLimit

public float getSpeedLimit()
Description copied from interface: ForceSimulator
Get the speed limit, or maximum velocity value allowed by this simulator.

Specified by:
getSpeedLimit in interface ForceSimulator
Returns:
the "speed limit" maximum velocity value

setSpeedLimit

public void setSpeedLimit(float limit)

getIntegrator

public Integrator getIntegrator()

setIntegrator

public void setIntegrator(Integrator intgr)

clear

public void clear()
Description copied from interface: ForceSimulator
Clear this simulator, removing all ForceItem and Spring instances for the simulator.

Specified by:
clear in interface ForceSimulator

addForce

public void addForce(Force f)
Description copied from interface: ForceSimulator
Add a new Force function to the simulator.

Specified by:
addForce in interface ForceSimulator
Parameters:
f - the Force function to add

getForces

public Force[] getForces()
Description copied from interface: ForceSimulator
Get an array of all the Force functions used in this simulator.

Specified by:
getForces in interface ForceSimulator
Returns:
an array of Force functions

addItem

public void addItem(ForceItem item)
Description copied from interface: ForceSimulator
Add a ForceItem to the simulation.

Specified by:
addItem in interface ForceSimulator
Parameters:
item - the ForceItem to add

removeItem

public boolean removeItem(ForceItem item)
Description copied from interface: ForceSimulator
Remove a ForceItem to the simulation.

Specified by:
removeItem in interface ForceSimulator
Parameters:
item - the ForceItem to remove

getItems

public java.util.List<ForceItem> getItems()
Description copied from interface: ForceSimulator
Get an iterator over all registered ForceItems.

Specified by:
getItems in interface ForceSimulator
Returns:
an iterator over the ForceItems.

addSpring

public Spring addSpring(ForceItem item1,
                        ForceItem item2)
Description copied from interface: ForceSimulator
Add a Spring to the simulation.

Specified by:
addSpring in interface ForceSimulator
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)
Description copied from interface: ForceSimulator
Add a Spring to the simulation.

Specified by:
addSpring in interface ForceSimulator
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)
Description copied from interface: ForceSimulator
Add a Spring to the simulation.

Specified by:
addSpring in interface ForceSimulator
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.List<Spring> getSprings()
Description copied from interface: ForceSimulator
Get an iterator over all registered Springs.

Specified by:
getSprings in interface ForceSimulator
Returns:
an iterator over the Springs.

runSimulator

public void runSimulator(long timestep)
Description copied from interface: ForceSimulator
Run the simulator for one timestep.

Specified by:
runSimulator in interface ForceSimulator
Parameters:
timestep - the span of the timestep for which to run the simulator

accumulate

public void accumulate()
Description copied from interface: ForceSimulator
Accumulate all forces acting on the items in this simulation

Specified by:
accumulate in interface ForceSimulator


Copyright © 2008 Regents of the University of California