com.cuspy.pathfinder
Class AbstractPathFinder

java.lang.Object
  |
  +--com.cuspy.pathfinder.AbstractPathFinder
All Implemented Interfaces:
PathFinder, java.lang.Runnable
Direct Known Subclasses:
AStar, DepthFirstSearch

public abstract class AbstractPathFinder
extends java.lang.Object
implements PathFinder

Basic functionality of path finders.


Field Summary
protected  boolean aborted
           
protected  java.util.Collection goals
           
protected  java.util.List listeners
           
protected  Node start
           
 
Constructor Summary
AbstractPathFinder(Node start, java.util.Collection goals)
          Create a new PathFinder.
AbstractPathFinder(Node start, Node goal)
          Create a new PathFinder.
 
Method Summary
 void abort()
          Abort the current path search.
 void addPathListener(PathListener l)
          Add a listener for PathEvents.
protected  void fireConsidered()
           
 void removePathListener(PathListener l)
          Remove a listener for PathEvents.
 void run()
          Execute the path finding algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cuspy.pathfinder.PathFinder
findPath, getConsideredPath
 

Field Detail

start

protected Node start

goals

protected java.util.Collection goals

listeners

protected java.util.List listeners

aborted

protected boolean aborted
Constructor Detail

AbstractPathFinder

public AbstractPathFinder(Node start,
                          Node goal)
Create a new PathFinder.

Parameters:
start - the Node to start with.
goal - the Node to end at.

AbstractPathFinder

public AbstractPathFinder(Node start,
                          java.util.Collection goals)
Create a new PathFinder.

Parameters:
start - the Node to start with.
goals - a Collection of Nodes to end at.
Method Detail

abort

public void abort()
Description copied from interface: PathFinder
Abort the current path search. This only makes sense if you are using the threaded approach. The state of the pathfinder will be reset such that it is okay to call findPath again to start over.

Specified by:
abort in interface PathFinder

run

public void run()
Execute the path finding algorithm.

Specified by:
run in interface java.lang.Runnable

fireConsidered

protected void fireConsidered()

addPathListener

public void addPathListener(PathListener l)
Description copied from interface: PathFinder
Add a listener for PathEvents.

Specified by:
addPathListener in interface PathFinder
Parameters:
l - the listener to add.

removePathListener

public void removePathListener(PathListener l)
Description copied from interface: PathFinder
Remove a listener for PathEvents.

Specified by:
removePathListener in interface PathFinder
Parameters:
l - the listener to remove.