ballWorlds
Interface BallManager

All Known Subinterfaces:
World
All Known Implementing Classes:
BallManagerWorld, VisibleWorld, WorldWithManyThreads, WorldWithTwoOrThreeThreads

public interface BallManager

A BallManager manages the Balls in a World. It can add or remove Balls from its World, and it can return various lists of Balls in its World, e.g. the Balls in its World that intersect a given Ball.

Author:
David Mutchler, Salman Azhar, Curt Clifton and others, January 2005. Modified September 2008, September 2009.

Method Summary
 void addBall(Ball ballToAdd)
          Adds the given Ball to this World.
 List<Ball> allBallsInWorld()
          Returns a List that contains all the Balls in this World.
 Ball intersectingBall(Ball ballToCheckForIntersections)
          Returns a Ball that intersects the given Ball, or null if no Ball intersects the given Ball.
 List<Ball> intersectingBalls(Ball ballToCheckForIntersections)
          Returns a List that contains all the Balls in this World that intersect the given Ball
 Ball nearestBall(Point2D p)
          Returns the Ball in this World that is nearest the given point.
 void removeBall(Ball ballToRemove)
          Removes the given Ball from this World.
 

Method Detail

addBall

void addBall(Ball ballToAdd)
Adds the given Ball to this World.

Parameters:
ballToAdd - the Ball to add to this World.

removeBall

void removeBall(Ball ballToRemove)
Removes the given Ball from this World.

Parameters:
ballToRemove - the Ball to remove from this World.

nearestBall

Ball nearestBall(Point2D p)
Returns the Ball in this World that is nearest the given point. Returns null if there are no Balls at all in this World.

Parameters:
p - the point for which to find the nearest Ball.
Returns:
the Ball in this World that is nearest the given point.

intersectingBall

Ball intersectingBall(Ball ballToCheckForIntersections)
Returns a Ball that intersects the given Ball, or null if no Ball intersects the given Ball.

Parameters:
ballToCheckForIntersections - Ball to check for intersection with other Balls.
Returns:
a Ball that intersects this Ball, or null if no Ball intersects this Ball.

intersectingBalls

List<Ball> intersectingBalls(Ball ballToCheckForIntersections)
Returns a List that contains all the Balls in this World that intersect the given Ball

Each call to this method returns a fresh List object that contains all the Ball objects in this World that intersect the given Ball independently from any other List objects in use at the same time. This allows the caller to safely iterate through this List without fear of it being concurrently modified by other Threads (and possibly generating a ConcurrentModification exception).

Parameters:
ballToCheckForIntersections - Ball to check for intersection with other Balls.
Returns:
a List that contains all the Balls in this World that intersect the given Ball.

allBallsInWorld

List<Ball> allBallsInWorld()
Returns a List that contains all the Balls in this World.

Each call to this method returns a fresh List object that contains all the Ball objects in this World independently from any other List objects in use at the same time. This allows the caller to safely iterate through this List without fear of it being concurrently modified by other Threads (and possibly generating a ConcurrentModification exception).

Returns:
a List that contains all of the Balls in this World.