Class 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
    • Constructor Detail

      • AStarGraphProvider

        public AStarGraphProvider()
    • 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 graph
        isCity - 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: BaseGraphCalulationService
        Calculate the weight between two nodes.
        Specified by:
        calculateWeight in class BaseGraphCalulationService
        Parameters:
        from - source node
        to - destination node
        Returns:
        weight of the edge from node from to to
      • getGraph

        public GraphAStar<javafx.geometry.Point2D> getGraph()