org.crwth.systems
Class Space

java.lang.Object
  |
  +--org.crwth.systems.Space
Direct Known Subclasses:
UniqueSpace

public class Space
extends Object

A generic Space container. Space holds Masses and Springs. Collectors add objects to a Space, Physics changes them, and Viewers observe.


Constructor Summary
Space()
           
Space(Mass root)
           
 
Method Summary
 void add(Object object)
          Adds an Object to Space.
 void addMass(Mass mass)
          Adds a Mass to Space.
 void addSpring(Spring spring)
          Adds a Spring to Space.
 int getDimension()
          Returns the dimension of the Space.
 Mass getMass(String name)
          Retrieves a Mass from Space based on the Mass's name.
 Iterator getMassIterator()
          Returns a Set of the Masses in the Space.
 Mass getRoot()
          Returns the Mass that is the root of the Space, if any.
 Spring getSpring(String name)
          Retrieves a Spring from Space based on the Spring's name.
 Iterator getSpringIterator()
          Returns a Set for the Springs in the Space.
 void setRoot(Mass mass)
          Sets the root object in the Space.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Space

public Space()

Space

public Space(Mass root)
Method Detail

add

public void add(Object object)
Adds an Object to Space. This method just calls the appropriate add<object>() method.

Parameters:
object - the Object to add.

addMass

public void addMass(Mass mass)
Adds a Mass to Space.

Parameters:
mass - the Mass to add.

getMass

public Mass getMass(String name)
Retrieves a Mass from Space based on the Mass's name.

Parameters:
name - the Mass's name.
Returns:
the Mass, if any, that matches the name, or null if none exists.

getMassIterator

public Iterator getMassIterator()
Returns a Set of the Masses in the Space. Use of this Set must be a synchronized task on the Set, preventing modification of the Space's objects by either Collectors or Physics.

Returns:
the Mass Set

addSpring

public void addSpring(Spring spring)
Adds a Spring to Space.

Parameters:
spring - the Spring to add.

getSpring

public Spring getSpring(String name)
Retrieves a Spring from Space based on the Spring's name.

Parameters:
name - the Spring's name.
Returns:
the Spring, if any, that matches the name, or null if none exists.

getSpringIterator

public Iterator getSpringIterator()
Returns a Set for the Springs in the Space. Use of this Set must be a synchronized task on the Set, preventing modification of the Space's objects by either Collectors or Physics.

Returns:
the Spring Iterator.

setRoot

public void setRoot(Mass mass)
Sets the root object in the Space. This object is considered the center of Space. It may or may not be an true Mass; that is, it may not represent any data, but is just used a Mass created as an anchor for the other objects. The root is usually stationary, but does not need to be so. The root may be invisible, in which case any Springs attached to it should probably also be invisible.

Parameters:
mass - the Mass to set as the root.

getRoot

public Mass getRoot()
Returns the Mass that is the root of the Space, if any.

Returns:
the root Mass if it exists, or null if not.

getDimension

public int getDimension()
Returns the dimension of the Space.

Returns:
the dimension of this object.

toString

public String toString()
Overrides:
toString in class Object