/*
 * ForceField.java
 *
 * Created on 14 styczeń 2005, 00:58
 */

package JSciDraw.physics;

import JSci.maths.*;
import JSci.physics.*;
import JSciDraw.interfaces.*;
import JSciDraw.physics.*;
import java.util.*;
/**
 *
 * @author  Przemek
 */
public abstract class CentralForceField extends ForceField{
    public ClassicalParticleV2D center;
    /** Creates a new instance of ForceField */
    public CentralForceField(ClassicalParticleV2D centralPoint) {
        super();
      center=centralPoint;
    }   
    
    public void applyField(ArrayList a){
        Iterator i=a.iterator();
        while (i.hasNext()) {
          Object tmp = i.next();
           if (tmp instanceof ClassicalParticleV2D){
              ClassicalParticleV2D part =(ClassicalParticleV2D)tmp;
              if (part!=center)
               part.addExtForce(getForce(part));
              if (part.moveableObjects.size()>0){
                   Iterator j=part.moveableObjects.iterator();
                     while (j.hasNext())
                         ((MoveableObject)j.next()).applyForceField(this);
                   }
               }
        }
        
    }
}
