Class MapViewsManager<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>

    • Constructor Detail

      • MapViewsManager

        public MapViewsManager​(@NotNull
                               @NotNull MapViewSettings mapViewSettings,
                               @NotNull
                               @NotNull MapViewFactory<G,​A,​R> mapViewFactory,
                               @NotNull
                               @NotNull MapManager<G,​A,​R> mapManager,
                               @NotNull
                               @NotNull MapManager<G,​A,​R> pickmapManager,
                               @NotNull
                               @NotNull PathManager pathManager)
        Creates a new instance.
        Parameters:
        mapViewSettings - the map view settings instance
        mapViewFactory - the map view factory to use
        mapManager - the map manager to use
        pickmapManager - the pickmap manager to use
        pathManager - the path manager for converting file instance
    • Method Detail

      • setFileControl

        @Deprecated
        public void setFileControl​(@NotNull
                                   @NotNull FileControl<G,​A,​R> fileControl)
        Deprecated.
      • addMapViewsListener

        public void addMapViewsListener​(@NotNull
                                        @NotNull MapControl<G,​A,​R> mapControl,
                                        @NotNull
                                        @NotNull MapViewsListener<G,​A,​R> listener)
        Adds a MapViewsListener to be notified of events.
        Parameters:
        mapControl - the map control to attach to
        listener - the listener
      • removeMapViewsListener

        public void removeMapViewsListener​(@NotNull
                                           @NotNull MapControl<G,​A,​R> mapControl,
                                           @NotNull
                                           @NotNull MapViewsListener<G,​A,​R> listener)
        Removes a MapViewsListener to be notified of events.
        Parameters:
        mapControl - the map control to attach to
        listener - the listener
      • getMapViewFrame

        @Nullable
        public @Nullable MapView<G,​A,​R> getMapViewFrame​(@NotNull
                                                                    @NotNull MapControl<G,​A,​R> mapControl)
        Returns the last used view of a MapControl.
        Parameters:
        mapControl - the map control
        Returns:
        the last used view
      • newMapView

        @NotNull
        public @NotNull MapView<G,​A,​R> newMapView​(@NotNull
                                                              @NotNull MapControl<G,​A,​R> mapControl,
                                                              @Nullable
                                                              @Nullable java.awt.Point viewPosition)
        Creates a new map view.
        Parameters:
        mapControl - the map control
        viewPosition - the view position to show initially; may be null to show the top left corner
        Returns:
        the map view
      • closeView

        public void closeView​(@NotNull
                              @NotNull MapView<G,​A,​R> mapView)
        Closes a view of a MapControl.
        Parameters:
        mapView - the view to be closed
      • setFocus

        public void setFocus​(@NotNull
                             @NotNull MapView<G,​A,​R> mapView)
        Sets a MapView as the main view.
        Parameters:
        mapView - the map view
      • getMapViewIterator

        public java.util.Iterator<MapView<G,​A,​R>> getMapViewIterator​(@NotNull
                                                                                 @NotNull MapControl<G,​A,​R> mapControl)
        Returns an Iterator returning all MapViews of a MapControl. The map views are returns top to bottom.
        Parameters:
        mapControl - the map control
        Returns:
        the iterator
      • newMapWithView

        public void newMapWithView​(@Nullable
                                   @Nullable java.util.List<G> objects,
                                   @NotNull
                                   A mapArchObject,
                                   @Nullable
                                   @Nullable java.awt.Point viewPosition,
                                   @Nullable
                                   @Nullable MapFile mapFile)
        Creates a new map control and an initial map view.
        Parameters:
        objects - the game objects to insert; may be null
        mapArchObject - the map arch object for the new map
        viewPosition - the view position to show initially; may be null to show the top left corner
        mapFile - the map file, or null if the map was not yet saved
      • closeMapView

        public void closeMapView​(@NotNull
                                 @NotNull MapView<G,​A,​R> mapView)
        Invoked when the user wants to close a map view. If there is only 1 view left the map will be closed.
        Parameters:
        mapView - the map view to close
      • openMapFileWithView

        @NotNull
        public @NotNull MapView<G,​A,​R> openMapFileWithView​(@NotNull
                                                                       @NotNull MapFile mapFile,
                                                                       @Nullable
                                                                       @Nullable java.awt.Point viewPosition)
                                                                throws java.io.IOException
        Loads a map file and creates a map view. Returns the last used view if the map is already loaded.
        Parameters:
        mapFile - the map file to load
        viewPosition - the view position to show initially; may be null to show the top left corner
        Returns:
        the map view
        Throws:
        java.io.IOException - if an I/O error occurs
      • openMapFileWithView

        public void openMapFileWithView​(@NotNull
                                        @NotNull java.io.File file,
                                        @Nullable
                                        @Nullable java.awt.Point viewPosition,
                                        @Nullable
                                        @Nullable java.awt.Point centerSquare)
                                 throws java.io.IOException
        Loads a map file and creates a map view.
        Parameters:
        file - the map file to load
        viewPosition - the view position to show initially; may be null to show the top left corner
        centerSquare - the map square that should be in the center of the view; ignored if viewPosition is set
        Throws:
        java.io.IOException - if an I/O error occurs