org.crwth.systems
Class Mass

java.lang.Object
  |
  +--org.crwth.systems.Mass

public class Mass
extends Object

A generic class for a mass. A Mass is the basis for all objects within the Space. They all have a name, a color, a mass, a vector, and a force associated with them.


Constructor Summary
Mass()
           
Mass(double mass)
           
Mass(double mass, Vector vector)
           
Mass(Mass mass)
           
Mass(String name, double mass, Vector vector)
           
Mass(Vector vector)
           
 
Method Summary
 void addForce(Vector force)
          Add force to the object's current total of exerted force upon it.
 Color getColor()
          Returns the color of the object.
 int getDimension()
          Returns the dimension of the Mass.
 double getDistance(Mass mass)
          Returns the distance from the object to the given Mass.
 Vector getForce()
          Get the current force being exerted on the object.
 double getMass()
          Returns the mass of the object.
 String getName()
          Returns the name of the object.
 Vector getVector()
          Returns the vector of the object.
 Vector getVector(Mass mass)
          Returns a vector from the object to the given Mass.
 boolean isStationary()
          Returns whether an object is fixed in space.
 boolean isVisible()
          Returns whether an object is visible.
 void setColor(Color color)
          Sets the color of the object.
 void setForce(Vector force)
          Set the force exerted on the object.
 void setMass(double mass)
          Sets the mass of the object.
 void setName(String name)
          Sets the name of the object.
 void setStationary(boolean b)
          Sets whether the object is fixed in space.
 void setVector(Vector vector)
          Sets the vector of the object.
 void setVisible(boolean b)
          Sets whether the object is visible.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mass

public Mass()

Mass

public Mass(double mass)

Mass

public Mass(Vector vector)

Mass

public Mass(double mass,
            Vector vector)

Mass

public Mass(String name,
            double mass,
            Vector vector)

Mass

public Mass(Mass mass)
Method Detail

setMass

public void setMass(double mass)
Sets the mass of the object.

Parameters:
mass - the new mass.

getMass

public double getMass()
Returns the mass of the object.

Returns:
the object's mass.

setName

public void setName(String name)
Sets the name of the object.

Parameters:
name - the new name.

getName

public String getName()
Returns the name of the object.

Returns:
the object's name.

setStationary

public void setStationary(boolean b)
Sets whether the object is fixed in space.

Parameters:
b - true if the object should not move.

isStationary

public boolean isStationary()
Returns whether an object is fixed in space.

Returns:
true if the object cannot move.

setVisible

public void setVisible(boolean b)
Sets whether the object is visible.

Parameters:
b - true if the object should be visible.

isVisible

public boolean isVisible()
Returns whether an object is visible.

Returns:
true if the object is visible.

setColor

public void setColor(Color color)
Sets the color of the object.

Parameters:
color - the new color.

getColor

public Color getColor()
Returns the color of the object.

Returns:
the object's color.

getDimension

public int getDimension()
Returns the dimension of the Mass. The Vector is used to determine this value.

Returns:
the dimension of the Vector of the object.

getDistance

public double getDistance(Mass mass)
                   throws WrongDimensionException
Returns the distance from the object to the given Mass.

Parameters:
mass - The Mass to find the distance to.
Returns:
the distance to mass.
Throws:
WrongDimensionException - if masshas a mismatched dimension.

setVector

public void setVector(Vector vector)
Sets the vector of the object.

Parameters:
vector - the new vector.

getVector

public Vector getVector()
Returns the vector of the object.

Returns:
the object's vector.

getVector

public Vector getVector(Mass mass)
                 throws WrongDimensionException
Returns a vector from the object to the given Mass.

Parameters:
mass - the Mass to find the Vector to.
Returns:
the vector from the object to mass.
Throws:
WrongDimensionException - if mass has a mismatched dimension.

addForce

public void addForce(Vector force)
              throws WrongDimensionException
Add force to the object's current total of exerted force upon it.

Parameters:
force - the force to be added
Throws:
WrongDimensionException - if force has a mismatched dimension.

getForce

public Vector getForce()
Get the current force being exerted on the object.

Returns:
the current object's force.

setForce

public void setForce(Vector force)
              throws WrongDimensionException
Set the force exerted on the object.

Parameters:
force - the object's new force.
Throws:
WrongDimensionException - if force has a mismatched dimension.

toString

public String toString()
Overrides:
toString in class Object