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


  • public class CopyBuffer<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>
    extends java.lang.Object
    Common base implementation of CopyBuffer. The CopyBuffer is responsible for cut, copy, paste and related operations like filling. It is backed by an invisible MapModel.
    • Constructor Detail

      • CopyBuffer

        public CopyBuffer​(@NotNull
                          @NotNull MapViewSettings mapViewSettings,
                          @NotNull
                          @NotNull GameObjectFactory<G,​A,​R> gameObjectFactory,
                          @NotNull
                          @NotNull MapArchObjectFactory<A> mapArchObjectFactory,
                          @NotNull
                          @NotNull MapModelFactory<G,​A,​R> mapModelFactory,
                          @NotNull
                          @NotNull InsertionModeSet<G,​A,​R> insertionModeSet)
        Creates a new instance.
        Parameters:
        mapViewSettings - the map view settings instance
        gameObjectFactory - the game object factory to use
        mapArchObjectFactory - the map arch object factory to use
        mapModelFactory - the map model factory to use
        insertionModeSet - the insertion mode set to use
    • Method Detail

      • addMapModelListener

        public void addMapModelListener​(@NotNull
                                        @NotNull MapModelListener<G,​A,​R> listener)
        Adds a MapModelListener to be notified about changes of the cut/copied game objects.
        Parameters:
        listener - the listener
      • removeMapModelListener

        public void removeMapModelListener​(@NotNull
                                           @NotNull MapModelListener<G,​A,​R> listener)
        Removes a MapModelListener to be notified about changes of the cut/copied game objects.
        Parameters:
        listener - the listener
      • clear

        public void clear​(@NotNull
                          @NotNull MapView<G,​A,​R> mapView,
                          @NotNull
                          @NotNull java.awt.Rectangle selectedRec)
        Executes the Clear command.
        Parameters:
        mapView - the map view to clear
        selectedRec - the rectangle to operate on
      • cut

        public void cut​(@NotNull
                        @NotNull MapView<G,​A,​R> mapView,
                        @NotNull
                        @NotNull java.awt.Rectangle selectedRec)
        Executes the Cut command.
        Parameters:
        mapView - the map view to cut from
        selectedRec - the rectangle to operate on
      • copy

        public void copy​(@NotNull
                         @NotNull MapView<G,​A,​R> mapView,
                         @NotNull
                         @NotNull java.awt.Rectangle selectedRec)
        Executes the Copy command.
        Parameters:
        mapView - the map view to copy from
        selectedRec - the rectangle to operate on
      • paste

        public void paste​(@NotNull
                          @NotNull MapView<G,​A,​R> mapView,
                          @NotNull
                          @NotNull java.awt.Point startLocation)
        Executes the Paste command.
        Parameters:
        mapView - the map view to paste on
        startLocation - the location to paste into
      • pasteTiled

        public void pasteTiled​(@NotNull
                               @NotNull MapView<G,​A,​R> mapView,
                               @NotNull
                               @NotNull java.lang.Iterable<MapSquare<G,​A,​R>> selectedSquares,
                               @NotNull
                               @NotNull java.awt.Point origin)
        Executes the Paste Tiled command.
        Parameters:
        mapView - the map view to paste on
        selectedSquares - the square to paste into
        origin - the origin where to start pasting
      • getAllGameObjects

        @NotNull
        public @NotNull java.util.List<G> getAllGameObjects()
        Returns all game objects. Only top-level head parts are returned; tail parts are ignored as are objects in inventories.
        Returns:
        all game objects
      • isEmpty

        public boolean isEmpty()
        Returns whether this copy buffer contains any game objects.
        Returns:
        whether any game objects exist