Class AStarGraphProvider
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
-
- ch.sahits.game.openpatrician.engine.sea.AStarGraphProvider
-
- All Implemented Interfaces:
ch.sahits.game.graphic.image.model.MapGrid
@Component @Lazy public class AStarGraphProvider extends BaseGraphCalulationService
Factory class to provide the graph for the AStar path finding calculation- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Jan 01, 2016
-
-
Field Summary
-
Fields inherited from class ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
imageService, map, pointInterner
-
-
Constructor Summary
Constructors Constructor Description AStarGraphProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDestinationPoint(javafx.geometry.Point2D newPoint, boolean isCity)Add a new destination Node to the graph.protected doublecalculateWeight(javafx.geometry.Point2D from, javafx.geometry.Point2D to)Calculate the weight between two nodes.GraphAStar<javafx.geometry.Point2D>getGraph()voidinitGraph(ch.sahits.game.openpatrician.event.data.HeuristicGraphInitialisationComplete event)-
Methods inherited from class ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
getPoint, getSegments, getTangentialSegments, isOnSea
-
-
-
-
Method Detail
-
initGraph
public void initGraph(ch.sahits.game.openpatrician.event.data.HeuristicGraphInitialisationComplete event)
-
addDestinationPoint
public void addDestinationPoint(javafx.geometry.Point2D newPoint, boolean isCity)Add a new destination Node to the graph. The new point is added to the heuristic as target and to the graph together with edges to its nearest neighbors and they back to the new node.- Parameters:
newPoint- new location to add to the graphisCity- flag indicating if the new location is a city, which means the coordinates may not be located in the sea area.
-
calculateWeight
protected double calculateWeight(javafx.geometry.Point2D from, javafx.geometry.Point2D to)Description copied from class:BaseGraphCalulationServiceCalculate the weight between two nodes.- Specified by:
calculateWeightin classBaseGraphCalulationService- Parameters:
from- source nodeto- destination node- Returns:
- weight of the edge from node
fromtoto
-
getGraph
public GraphAStar<javafx.geometry.Point2D> getGraph()
-
-