Package cz.cuni.mff.abacs.burglar.visual.multithreading

Source Code of cz.cuni.mff.abacs.burglar.visual.multithreading.PathfindingThread

/**
*
*/
package cz.cuni.mff.abacs.burglar.visual.multithreading;

import aStarLibrary.AStar;
import aStarLibrary.Node;
import cz.cuni.mff.abacs.burglar.logics.ExecutingMap;
import cz.cuni.mff.abacs.burglar.logics.GameMap;
import cz.cuni.mff.abacs.burglar.logics.objects.positions.Position;
import java.util.List;

/**
* Not in use.
*
* @author abacs
*
*/
public class PathfindingThread extends Thread {
 
  /**  */
  private ExecutingMap _map;
  /**  */
  private Node _from;
  /**  */
  private Node _to;
  /**  */
  private PathfinderListener _listener;
 
 
  // -------------------------------------------------------------------------
  // constructors:
 
  /**
   *
   *
   * @param map
   * @param from
   * @param to
   * @param handler
   */
  public PathfindingThread(
      GameMap map,
      Node from,
      Node to,
      PathfinderListener handler
  ) {
    super();
    this._map = (ExecutingMap)map;
    this._from = from;
    this._to = to;
    this._listener = handler;
  }
 
 
  // -------------------------------------------------------------------------
 
 
  /* (non-Javadoc)
   * @see java.lang.Runnable#run()
   */
  @SuppressWarnings("unchecked")
  @Override
  public void run() {
   
    AStar aStar = new AStar();
   
    aStar.nodes.addAll(this._map.getNodes());
   
    List<Node> nodes = aStar.getPath(this._from, this._to);
    List<Position> positions = this._map.nodesToPositions(nodes);
   
    this._listener.pathfindingFinished(positions);
  }
 
 
}
TOP

Related Classes of cz.cuni.mff.abacs.burglar.visual.multithreading.PathfindingThread

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.