com.speckled.specksim.imp.motion
Class GridMovementModel

java.lang.Object
  extended by com.speckled.specksim.imp.motion.CacheingMovementModel
      extended by com.speckled.specksim.imp.motion.GridMovementModel
All Implemented Interfaces:
Configurable, PopulationListener, MovementModel

public class GridMovementModel
extends CacheingMovementModel
implements PopulationListener

Models a static grid of specks

Author:
ryanm

Constructor Summary
GridMovementModel()
           
 
Method Summary
protected  SpeckPosition computeLocation(Speck speck, float time)
          Override this to compute a speck's location
 Vector3d computeVelocity(Speck speck, float time)
          Override this to compute a speck's velocity
 void deInit()
          Called when this model is replaced as the current model
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 double getMaxSpeed()
          Gets the maximum possible speed that any Speck can move under this movement model.
 java.lang.String getName()
          Gets the name of this model
 SerializableState getState(float time)
          Gets a state object from this model.
 void init(SpeckSim simulator)
          Called when this model is set to be the current model, or when the simulator is reset.
 void removeSpeck(Speck speck)
          Called when a speck is removed from the simulator.
 void speckAdded(Speck speck)
          Notifies the listener that an arbitrary Speck has been added
 void speckPopulationSet(int pop)
          Notifies that the population of specks has changed size
 void speckRemoved(Speck speck)
          Notifies the listener that a speck has been removed
 
Methods inherited from class com.speckled.specksim.imp.motion.CacheingMovementModel
clearCache, getSpeckOrientation, getSpeckVelocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridMovementModel

public GridMovementModel()
Method Detail

computeLocation

protected SpeckPosition computeLocation(Speck speck,
                                        float time)
Description copied from class: CacheingMovementModel
Override this to compute a speck's location

Specified by:
computeLocation in class CacheingMovementModel
Parameters:
speck - The speck to locate
time - The time to locate at
Returns:
The location of the speck at the given time

computeVelocity

public Vector3d computeVelocity(Speck speck,
                                float time)
Description copied from class: CacheingMovementModel
Override this to compute a speck's velocity

Specified by:
computeVelocity in class CacheingMovementModel
Parameters:
speck - The speck to compute for
time - The time to compute at
Returns:
The velocity of the speck at the given time

getName

public java.lang.String getName()
Description copied from interface: MovementModel
Gets the name of this model

Specified by:
getName in interface MovementModel
Returns:
A String name for this model

init

public void init(SpeckSim simulator)
Description copied from interface: MovementModel
Called when this model is set to be the current model, or when the simulator is reset. As such, this method must clear any old state as well as set up the new state

Specified by:
init in interface MovementModel
Parameters:
simulator - The simulator that this model is current in.

deInit

public void deInit()
Description copied from interface: MovementModel
Called when this model is replaced as the current model

Specified by:
deInit in interface MovementModel

removeSpeck

public void removeSpeck(Speck speck)
Description copied from interface: MovementModel
Called when a speck is removed from the simulator. Could be useful if the model maintain any state for each speck.

Specified by:
removeSpeck in interface MovementModel

getMaxSpeed

public double getMaxSpeed()
Description copied from interface: MovementModel
Gets the maximum possible speed that any Speck can move under this movement model. Enables some performance optimisations when looking for broadcast recipients. If we cannot define a maximum speed, we should return -1. Also, if you cannot guarantee that specks will not leave the unit cube,-1 should be returned

Specified by:
getMaxSpeed in interface MovementModel
Returns:
The maximum possible speed of any speck, in units per second, or -1 if we cannot define a max speed, or if specks may possibly leave the unit cube

getState

public SerializableState getState(float time)
Description copied from interface: MovementModel
Gets a state object from this model. This will be placed in the SimulatorState object that is passed to the GUI, consequently, this is useful for providing some data to be visualised. For instance, SpeckledBodyModels use it to pass the vertices of their bodies for visualisation. Feel free to pass null if you want to. This implementation of this method should not assume that the init() method has been called, so return an empty instance of the state object if this is the case

Specified by:
getState in interface MovementModel
Parameters:
time - The time at which the state should be captured
Returns:
The interesting state of the movement model, or null if no state is needed

getConfigurator

public Configurator getConfigurator()
Description copied from interface: Configurable
Gets a Configurator object that describes and can manipulate the variables of this Configurable. This method must only return null if the Configurable object is Annotated such that an AnnotatedConfigurator can be built from it.

Specified by:
getConfigurator in interface Configurable
Returns:
A configurator object, or null if annotated

speckPopulationSet

public void speckPopulationSet(int pop)
Description copied from interface: PopulationListener
Notifies that the population of specks has changed size

Specified by:
speckPopulationSet in interface PopulationListener
Parameters:
pop - The new number of specks

speckAdded

public void speckAdded(Speck speck)
Description copied from interface: PopulationListener
Notifies the listener that an arbitrary Speck has been added

Specified by:
speckAdded in interface PopulationListener
Parameters:
speck - The new speck

speckRemoved

public void speckRemoved(Speck speck)
Description copied from interface: PopulationListener
Notifies the listener that a speck has been removed

Specified by:
speckRemoved in interface PopulationListener
Parameters:
speck - The ousted speck