Class AStarGraphProvider
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
-
- ch.sahits.game.openpatrician.engine.sea.AStarGraphProvider
-
- All Implemented Interfaces:
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 Modifier and Type Field Description private com.google.common.eventbus.AsyncEventBus
clientServerEventBus
private GraphAStar<javafx.geometry.Point2D>
graph
private int
height
private java.util.Map<javafx.geometry.Point2D,com.carrotsearch.hppc.ObjectDoubleMap<javafx.geometry.Point2D>>
heuristic
private AStarHeuristicProvider
heuristicProvider
private boolean
initialized
private java.lang.Object
lock
private java.util.concurrent.Executor
serverThreadPool
private int
width
-
Fields inherited from class ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
imageService, map, pointInterner
-
Fields inherited from interface ch.sahits.game.graphic.image.model.MapGrid
CHECK_DISTANCE, DIAG_CHECK_DISTANCE
-
-
Constructor Summary
Constructors Constructor Description AStarGraphProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDestinationPoint(javafx.geometry.Point2D newPoint, boolean isCity)
Add a new destination Node to the graph.(package private) void
addDestinationPointInternal(javafx.geometry.Point2D newPoint, boolean isCity)
private void
addEdges(javafx.geometry.Point2D from, javafx.geometry.Point2D to, boolean isCity, boolean initial)
(package private) void
addSourcePointInternal(javafx.geometry.Point2D source, boolean isCity)
protected double
calculateWeight(javafx.geometry.Point2D from, javafx.geometry.Point2D to)
Calculate the weight between two nodes.(package private) void
createGraph()
GraphAStar<javafx.geometry.Point2D>
getGraph()
private void
init()
void
initGraph(HeuristicGraphInitialisationComplete event)
(package private) void
initImage()
-
Methods inherited from class ch.sahits.game.openpatrician.engine.sea.BaseGraphCalulationService
getPoint, getSegments, getTangentialSegments, isOnSea
-
-
-
-
Field Detail
-
heuristicProvider
@Autowired private AStarHeuristicProvider heuristicProvider
-
serverThreadPool
@Autowired @Qualifier("serverThreadPool") private java.util.concurrent.Executor serverThreadPool
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
lock
private final java.lang.Object lock
-
width
private int width
-
height
private int height
-
graph
private GraphAStar<javafx.geometry.Point2D> graph
-
heuristic
private java.util.Map<javafx.geometry.Point2D,com.carrotsearch.hppc.ObjectDoubleMap<javafx.geometry.Point2D>> heuristic
-
initialized
private boolean initialized
-
-
Method Detail
-
init
@PostConstruct private void init()
-
initGraph
public void initGraph(HeuristicGraphInitialisationComplete event)
-
createGraph
void createGraph()
-
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.
-
addDestinationPointInternal
void addDestinationPointInternal(javafx.geometry.Point2D newPoint, boolean isCity)
-
addSourcePointInternal
void addSourcePointInternal(javafx.geometry.Point2D source, boolean isCity)
-
calculateWeight
protected double calculateWeight(javafx.geometry.Point2D from, javafx.geometry.Point2D to)
Description copied from class:BaseGraphCalulationService
Calculate the weight between two nodes.- Specified by:
calculateWeight
in classBaseGraphCalulationService
- Parameters:
from
- source nodeto
- destination node- Returns:
- weight of the edge from node
from
toto
-
addEdges
private void addEdges(javafx.geometry.Point2D from, javafx.geometry.Point2D to, boolean isCity, boolean initial)
-
initImage
void initImage()
-
getGraph
public GraphAStar<javafx.geometry.Point2D> getGraph()
-
-