Class LocationTracker

  • All Implemented Interfaces:
    ILocationTracker

    @Component
    @Lazy
    public class LocationTracker
    extends java.lang.Object
    implements ILocationTracker
    Component that helps split up the amount of ships into segements of the navigable map. This reduces the omount of ships that need to be checked if a ship nearby is searched.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2015 Created on Dec 13, 2015
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • map

        @Autowired
        private IMap map
      • clientServerEventBus

        @Autowired
        @Qualifier("serverClientEventBus")
        private com.google.common.eventbus.AsyncEventBus clientServerEventBus
      • syncServerClientEventBus

        @Autowired
        @Qualifier("syncServerClientEventBus")
        private com.google.common.eventbus.EventBus syncServerClientEventBus
      • pointInterner

        @Autowired
        protected com.google.common.collect.Interner<javafx.geometry.Point2D> pointInterner
      • mapDimension

        private javafx.geometry.Dimension2D mapDimension
      • segmentEdgeWidth

        private double segmentEdgeWidth
      • segmentEdgeHeigth

        private double segmentEdgeHeigth
      • segments

        private java.util.List<java.lang.ref.WeakReference<INavigableVessel>>[][] segments
    • Constructor Detail

      • LocationTracker

        public LocationTracker()
    • Method Detail

      • initialize

        @PostConstruct
        void initialize()
      • unregister

        @PreDestroy
        private void unregister()
      • updateSegmentSize

        public void updateSegmentSize​(int nbShips)
      • calculateIndices

        int[] calculateIndices​(javafx.geometry.Point2D location)
      • getShipsInSegment

        public java.util.List<INavigableVessel> getShipsInSegment​(javafx.geometry.Point2D location)
      • getShipsInSegments

        public java.util.List<INavigableVessel> getShipsInSegments​(javafx.geometry.Point2D location,
                                                                   int radius)
      • getPointOnMap

        private javafx.geometry.Point2D getPointOnMap​(double x,
                                                      double y)
        Ensure that the point is on the map.
        Parameters:
        x - coordinate on the map
        y - coordinate on the map
        Returns:
        Point representing the point on the map.
      • calculateRowsAndColumnsNeeded

        int[] calculateRowsAndColumnsNeeded​(int numberOfImages,
                                            javafx.geometry.Dimension2D containerSize)
        Calculate the number of segments the image is partitioned into
        Parameters:
        numberOfImages - target number of segments
        containerSize - dimension of the image
        Returns:
        array of length: index 0: nbRows, index 1: nbCols
      • handleGameLoad

        public void handleGameLoad​(GameStateChange gameStateChange)