org.miv.pherd
Class ParticleBox

java.lang.Object
  extended by org.miv.pherd.ParticleBox

public class ParticleBox
extends Object

Container, handler, and animator for the particles.

Since:
2007
Author:
Antoine Dutot

Field Summary
protected  ArrayList<ParticleBoxListener> listeners
          Set of listeners.
protected  HashMap<Object,Particle> particles
          The list of particles.
protected  int time
          Current step.
protected  NTree tree
          The n-tree.
 
Constructor Summary
ParticleBox(int pmax, CellSpace universe, CellData rootData)
          New particle box.
 
Method Summary
 void addParticle(Particle particle)
          Add a particle to the list of active particles.
 void addParticleBoxListener(ParticleBoxListener listener)
          Add a listener for all events coming from the particle box: when a particle is added, removed or moved and for each time step.
 NTree getNTree()
          The internal space representation, a n-tree.
 Particle getParticle(Object id)
          Access to a particle.
 int getParticleCount()
          Number of particles in the box.
 Iterator<Object> getParticleIdIterator()
          Iterator on the set of particles identifiers.
 void removeAllParticles()
          Remove all particles of this box.
 Particle removeParticle(Object id)
          Remove the particle identifier by the given identifier.
 void removeParticleBoxListener(ParticleBoxListener listener)
          Remove a listener from the particle box.
 void step()
          One step of the particle simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

particles

protected HashMap<Object,Particle> particles
The list of particles.


tree

protected NTree tree
The n-tree.


listeners

protected ArrayList<ParticleBoxListener> listeners
Set of listeners.


time

protected int time
Current step.

Constructor Detail

ParticleBox

public ParticleBox(int pmax,
                   CellSpace universe,
                   CellData rootData)
New particle box.

Parameters:
pmax - The maximum number of particles per cell before a subdivision occurs.
universe - The specific space defining the initial root node.
rootData - The data specific to the particle simulation.
Method Detail

getParticle

public Particle getParticle(Object id)
Access to a particle.

Parameters:
id - The particle unique identifier.

getNTree

public NTree getNTree()
The internal space representation, a n-tree.

Returns:
The n-tree.

getParticleCount

public int getParticleCount()
Number of particles in the box.

Returns:
The particle count.

getParticleIdIterator

public Iterator<Object> getParticleIdIterator()
Iterator on the set of particles identifiers.

Returns:
An object iterator.

addParticle

public void addParticle(Particle particle)
                 throws IdAlreadyInUseException
Add a particle to the list of active particles.

Parameters:
particle - The new particle.
Throws:
IdAlreadyInUseException - If a particle with the same identifier that is not the same particle is added.

removeParticle

public Particle removeParticle(Object id)
Remove the particle identifier by the given identifier.

Parameters:
id - The particle unique identifier.
Returns:
The removed particle (or null if not found).

removeAllParticles

public void removeAllParticles()
Remove all particles of this box.


step

public void step()
One step of the particle simulation. This method:
  1. move all particles according to their old positions;
  2. commit the newly computed position into the particles;
  3. appropriately subdivide or fusion the n-tree cells for the next computation;
  4. tell what it did to the listeners.


addParticleBoxListener

public void addParticleBoxListener(ParticleBoxListener listener)
Add a listener for all events coming from the particle box: when a particle is added, removed or moved and for each time step.

Parameters:
listener - The listener to add.

removeParticleBoxListener

public void removeParticleBoxListener(ParticleBoxListener listener)
Remove a listener from the particle box.

Parameters:
listener - The listener to remove.


Copyright © 2011. All Rights Reserved.