org.crwth.systems
Class Spring

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

public class Spring
extends Object

A generic class for a spring. A Spring is the connector betweem all Mass objects. They all have a name, a color, a strength, a visibility and two Masses.


Constructor Summary
Spring()
           
Spring(Mass m1, Mass m2)
           
Spring(Mass m1, Mass m2, double strength)
           
Spring(Spring spring)
           
 
Method Summary
 Color getColor()
          Returns the color of the spring.
 int getDimension()
          Returns the dimension of the Spring.
 Mass getMass1()
          Returns the first mass on the spring.
 Mass getMass2()
          Returns the second mass on the spring.
 String getName()
          Returns the name of the spring.
 double getStrength()
          Returns the strength of the spring.
 Vector getVector()
          Returns the vector from the first mass to the second mass.
 boolean isVisible()
          Returns whether the spring is visible or not.
 void setColor(Color color)
          Sets the color of the Spring.
 void setMass1(Mass mass)
          Sets the first mass on the spring.
 void setMass2(Mass mass)
          Sets the second mass on the spring.
 void setStrength(double strength)
          Sets the strength of the spring.
 void setVisible(boolean b)
          Sets whether the spring is visible or not.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Spring

public Spring()

Spring

public Spring(Mass m1,
              Mass m2)
       throws WrongDimensionException

Spring

public Spring(Mass m1,
              Mass m2,
              double strength)
       throws WrongDimensionException

Spring

public Spring(Spring spring)
Method Detail

setMass1

public void setMass1(Mass mass)
              throws WrongDimensionException
Sets the first mass on the spring.

Parameters:
mass - new first mass.
Throws:
WrongDimensionException - if mass has a mismatched dimension from the second mass.

getMass1

public Mass getMass1()
Returns the first mass on the spring.

Returns:
the first mass.

setMass2

public void setMass2(Mass mass)
              throws WrongDimensionException
Sets the second mass on the spring.

Parameters:
mass - new second mass.
Throws:
WrongDimensionException - if mass has a mismatched dimension from the first mass.

getMass2

public Mass getMass2()
Returns the second mass on the spring.

Returns:
the second mass.

getVector

public Vector getVector()
Returns the vector from the first mass to the second mass.

Returns:
the vector between the two masses.

setStrength

public void setStrength(double strength)
Sets the strength of the spring.

Parameters:
strength - the new strength.

getStrength

public double getStrength()
Returns the strength of the spring.

Returns:
the spring's strength.

setVisible

public void setVisible(boolean b)
Sets whether the spring is visible or not.

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

isVisible

public boolean isVisible()
Returns whether the spring is visible or not.

Returns:
true if the spring is visible.

setColor

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

Parameters:
color - the new color.

getColor

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

Returns:
the spring's color.

getName

public String getName()
Returns the name of the spring. This is a generated name based on the names of the two masses attached, and is therefore not settable.

Returns:
the spring's name.

getDimension

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

Returns:
the dimension of this object.

toString

public String toString()
Overrides:
toString in class Object