org.crwth.systems
Class UniqueSpace

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

public class UniqueSpace
extends Space

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


Field Summary
protected  Set masses
           
protected  Mass r
           
protected  Set springs
           
 
Constructor Summary
UniqueSpace()
           
UniqueSpace(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
 

Field Detail

masses

protected Set masses

springs

protected Set springs

r

protected Mass r
Constructor Detail

UniqueSpace

public UniqueSpace()

UniqueSpace

public UniqueSpace(Mass root)
Method Detail

add

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

Overrides:
add in class Space
Parameters:
object - the Object to add.

addMass

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

Overrides:
addMass in class Space
Parameters:
mass - the Mass to add.

getMass

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

Overrides:
getMass in class Space
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.

Overrides:
getMassIterator in class Space
Returns:
the Mass Set

addSpring

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

Overrides:
addSpring in class Space
Parameters:
spring - the Spring to add.

getSpring

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

Overrides:
getSpring in class Space
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.

Overrides:
getSpringIterator in class Space
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.

Overrides:
setRoot in class Space
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.

Overrides:
getRoot in class Space
Returns:
the root Mass if it exists, or null if not.

getDimension

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

Overrides:
getDimension in class Space
Returns:
the dimension of this object.

toString

public String toString()
Overrides:
toString in class Space