jfreerails.controller
Class TrackPathFinder

java.lang.Object
  extended by jfreerails.controller.TrackPathFinder
All Implemented Interfaces:
IncrementalPathFinder

public class TrackPathFinder
extends java.lang.Object
implements IncrementalPathFinder

Finds the best route to build track between two points.

Author:
Luke

Field Summary
private static java.util.logging.Logger logger
           
private  SimpleAStarPathFinder pathFinder
           
private  FreerailsPrincipal principal
           
private  ImPoint startPoint
           
private  ReadOnlyWorld world
           
 
Fields inherited from interface jfreerails.controller.IncrementalPathFinder
PATH_FOUND, PATH_NOT_FOUND, SEARCH_NOT_STARTED, SEARCH_PAUSED
 
Constructor Summary
TrackPathFinder(ReadOnlyWorld world, FreerailsPrincipal principal)
           
 
Method Summary
 void abandonSearch()
           
private  java.util.List<ImPoint> convertPath2Points(IntArray path)
           
private  int[] findTargets(ImPoint targetPoint)
           
 java.util.List generatePath(ImPoint start, ImPoint targetPoint, BuildTrackStrategy bts)
           
 int getStatus()
           
 java.util.List<ImPoint> pathAsPoints()
           
 Step[] pathAsVectors()
           
 void search(long maxDuration)
           
 void setupSearch(ImPoint startPoint, ImPoint targetPoint, BuildTrackStrategy bts)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

pathFinder

private SimpleAStarPathFinder pathFinder

world

private final ReadOnlyWorld world

startPoint

private ImPoint startPoint

principal

private final FreerailsPrincipal principal
Constructor Detail

TrackPathFinder

public TrackPathFinder(ReadOnlyWorld world,
                       FreerailsPrincipal principal)
Method Detail

abandonSearch

public void abandonSearch()
Specified by:
abandonSearch in interface IncrementalPathFinder

convertPath2Points

private java.util.List<ImPoint> convertPath2Points(IntArray path)

findTargets

private int[] findTargets(ImPoint targetPoint)

generatePath

public java.util.List generatePath(ImPoint start,
                                   ImPoint targetPoint,
                                   BuildTrackStrategy bts)
                            throws PathNotFoundException
Throws:
PathNotFoundException

getStatus

public int getStatus()
Specified by:
getStatus in interface IncrementalPathFinder

pathAsPoints

public java.util.List<ImPoint> pathAsPoints()

pathAsVectors

public Step[] pathAsVectors()

search

public void search(long maxDuration)
            throws PathNotFoundException
Specified by:
search in interface IncrementalPathFinder
Throws:
PathNotFoundException

setupSearch

public void setupSearch(ImPoint startPoint,
                        ImPoint targetPoint,
                        BuildTrackStrategy bts)
                 throws PathNotFoundException
Throws:
PathNotFoundException