Package net.sf.gridarta.gui.copybuffer
Class CopyBuffer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.gui.copybuffer.CopyBuffer<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.ObjectCommon 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 Summary
Constructors Constructor Description CopyBuffer(@NotNull MapViewSettings mapViewSettings, @NotNull GameObjectFactory<G,A,R> gameObjectFactory, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull MapModelFactory<G,A,R> mapModelFactory, @NotNull InsertionModeSet<G,A,R> insertionModeSet)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapModelListener(@NotNull MapModelListener<G,A,R> listener)Adds aMapModelListenerto be notified about changes of the cut/copied game objects.voidclear(@NotNull MapView<G,A,R> mapView, @NotNull java.awt.Rectangle selectedRec)Executes the Clear command.voidcopy(@NotNull MapView<G,A,R> mapView, @NotNull java.awt.Rectangle selectedRec)Executes the Copy command.voidcut(@NotNull MapView<G,A,R> mapView, @NotNull java.awt.Rectangle selectedRec)Executes the Cut command.@NotNull java.util.List<G>getAllGameObjects()Returns all game objects.booleanisEmpty()Returns whether this copy buffer contains any game objects.voidpaste(@NotNull MapView<G,A,R> mapView, @NotNull java.awt.Point startLocation)Executes the Paste command.voidpasteTiled(@NotNull MapView<G,A,R> mapView, @NotNull java.lang.Iterable<MapSquare<G,A,R>> selectedSquares, @NotNull java.awt.Point origin)Executes the Paste Tiled command.voidremoveMapModelListener(@NotNull MapModelListener<G,A,R> listener)Removes aMapModelListenerto be notified about changes of the cut/copied game objects.
-
-
-
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 instancegameObjectFactory- the game object factory to usemapArchObjectFactory- the map arch object factory to usemapModelFactory- the map model factory to useinsertionModeSet- the insertion mode set to use
-
-
Method Detail
-
addMapModelListener
public void addMapModelListener(@NotNull @NotNull MapModelListener<G,A,R> listener)Adds aMapModelListenerto 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 aMapModelListenerto 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 clearselectedRec- 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 fromselectedRec- 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 fromselectedRec- 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 onstartLocation- 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 onselectedSquares- the square to paste intoorigin- 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
-
-