noope.core
Class Physics

java.lang.Object
  |
  +--noope.core.Physics

public class Physics
extends java.lang.Object

This is the main wrapper class around Laws and Entities. It initialises itself from the supplied BlockReader, and constructs all Entity and Law objects, which are stored in private Entities and Laws list objects.

Version:
11-May-2001: changed != on Strings to !String.equals(...) because didn't work, Miklos Reiter 28-Apr-2001: removed ListIterator because not supported before Java 1.2
Author:
James Kermode

Constructor Summary
Physics(BlockReader brPhysics)
          Construct a Physics object from the supplied BlockReader, and initialise the Laws and Entities lists.
Physics(BlockReader brPhysics, LawLoader lawL, EntityLoader entL, LawPropertyRecordLoader lawPRL)
          Constructs a new Physics object, just as the other constructor, but you can specify the XXXXLoader objects to use.
 
Method Summary
 void dispose()
          Disposes of resources by calling dispose() on the list of entities and the list of laws.
 Entities getEntities()
          Provide access to the list of Entities
 EntityLoader getEntityLoader()
          Returns the EntityLoader object used by this Physics object.
 LawLoader getLawLoader()
          Returns the LawLoader object used by this Physics object.
 LawPropertyRecordLoader getLawPropertyRecordLoader()
          Returns the LawPropertyRecordLoader object used by this Physics object.
 Laws getLaws()
          Provide access to the list of Laws
 double getTime()
          Provide access to the current universal time
 void run(double duration, double deltaTime)
          Run the simulation for a time duration, in intervals of deltaTime This method resets the internal time to zero, then calls step(deltaTime) repeatedly.
 void step(double deltaTime)
          Run the simulation for a single step of deltaTime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Physics

public Physics(BlockReader brPhysics)
        throws BRLoadingException
Construct a Physics object from the supplied BlockReader, and initialise the Laws and Entities lists. This constructor creates passes DynamicXXXXLoader objects to what it constructs.
Parameters:
brPhysics - the BlockReader used to initialise private Laws and Entities objects
Throws:
BRLoadingException - if it finds anything wrong with the format of the data in the BlockReader passed to it.

Physics

public Physics(BlockReader brPhysics,
               LawLoader lawL,
               EntityLoader entL,
               LawPropertyRecordLoader lawPRL)
        throws BRLoadingException
Constructs a new Physics object, just as the other constructor, but you can specify the XXXXLoader objects to use.
Method Detail

getLaws

public Laws getLaws()
Provide access to the list of Laws

getEntities

public Entities getEntities()
Provide access to the list of Entities

getTime

public double getTime()
Provide access to the current universal time

step

public void step(double deltaTime)
Run the simulation for a single step of deltaTime. This method is the main interface between Physics and the program using the library. Calling step runs the simulation forward in time by a period deltaTime, causing all the Laws to act on all the Entities, and update all their positions and velocities. Rewritten by Miklos Reiter so this method does not use ListIterator any more, for compatibility with Java 1.1.
Parameters:
deltaTime - amount of time to run the simulation for
See Also:
Entity.step(double)

run

public void run(double duration,
                double deltaTime)
Run the simulation for a time duration, in intervals of deltaTime This method resets the internal time to zero, then calls step(deltaTime) repeatedly. Use it when you want to run a simulation for a specific amount of time without doing any processing at each step.
Parameters:
duration - total time to run simulation for
deltaTime - amount of time by step by at each iteration

dispose

public void dispose()
Disposes of resources by calling dispose() on the list of entities and the list of laws. You should call this, not only to release resources more quickly than they would be by the garbage collector, but also, in order to tell output laws that they can close output devices, such as files, windows, etc.

getLawLoader

public LawLoader getLawLoader()
Returns the LawLoader object used by this Physics object. Used by the Laws constructor.

getEntityLoader

public EntityLoader getEntityLoader()
Returns the EntityLoader object used by this Physics object. Used by the Entities constructor.

getLawPropertyRecordLoader

public LawPropertyRecordLoader getLawPropertyRecordLoader()
Returns the LawPropertyRecordLoader object used by this Physics object. Used by certain Laws wanting to create LawPropertyRecords.