Gridarta Editor
net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

Common base implementation of CopyBuffer. More...

+ Inheritance diagram for net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

void addMapModelListener (@NotNull final MapModelListener< G, A, R > listener)
 Adds a MapModelListener to be notified about changes of the cut/copied game objects. More...
 
void clear (@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
 Executes the Clear command. More...
 
void copy (@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
 Executes the Copy command. More...
 
 CopyBuffer (@NotNull final MapViewSettings mapViewSettings, @NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final MapArchObjectFactory< A > mapArchObjectFactory, @NotNull final MapModelFactory< G, A, R > mapModelFactory, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
 Creates a new instance. More...
 
void cut (@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
 Executes the Cut command. More...
 
List< G > getAllGameObjects ()
 Returns all game objects. More...
 
boolean isEmpty ()
 Returns whether this copy buffer contains any game objects. More...
 
void paste (@NotNull final MapView< G, A, R > mapView, @NotNull final Point startLocation)
 Executes the Paste command. More...
 
void pasteTiled (@NotNull final MapView< G, A, R > mapView, @NotNull final Iterable< MapSquare< G, A, R >> selectedSquares, @NotNull final Point origin)
 Executes the Paste Tiled command. More...
 
void removeMapModelListener (@NotNull final MapModelListener< G, A, R > listener)
 Removes a MapModelListener to be notified about changes of the cut/copied game objects. More...
 

Private Member Functions

void copyNCut (@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec, @NotNull final CopyMode copyMode)
 Implements clear, cut and copy in one function (since they are so similar). More...
 

Private Attributes

final GameObjectFactory< G, A, R > gameObjectFactory
 The GameObjectFactory to use. More...
 
final InsertionModeSet< G, A, R > insertionModeSet
 The InsertionModeSet to use. More...
 
final MapModel< G, A, R > mapModel
 Internal map model to store the cut / copied game objects. More...
 
final MapViewSettings mapViewSettings
 The map view settings instance. More...
 

Detailed Description

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.

Author
Andreas Vogl
Christian Hujer
Andreas Kirschbaum

Definition at line 52 of file CopyBuffer.java.

Constructor & Destructor Documentation

◆ CopyBuffer()

net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.CopyBuffer ( @NotNull final MapViewSettings  mapViewSettings,
@NotNull final GameObjectFactory< G, A, R >  gameObjectFactory,
@NotNull final MapArchObjectFactory< A >  mapArchObjectFactory,
@NotNull final MapModelFactory< G, A, R >  mapModelFactory,
@NotNull final InsertionModeSet< G, A, R >  insertionModeSet 
)

Creates a new instance.

Parameters
mapViewSettingsthe map view settings instance
gameObjectFactorythe game object factory to use
mapArchObjectFactorythe map arch object factory to use
mapModelFactorythe map model factory to use
insertionModeSetthe insertion mode set to use

Definition at line 86 of file CopyBuffer.java.

Member Function Documentation

◆ addMapModelListener()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addMapModelListener ( @NotNull final MapModelListener< G, A, R >  listener)

Adds a MapModelListener to be notified about changes of the cut/copied game objects.

Parameters
listenerthe listener

Definition at line 100 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.MainActions().

+ Here is the caller graph for this function:

◆ clear()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.clear ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Rectangle  selectedRec 
)

Executes the Clear command.

Parameters
mapViewthe map view to clear
selectedRecthe rectangle to operate on

Definition at line 118 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doClear().

+ Here is the caller graph for this function:

◆ copy()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.copy ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Rectangle  selectedRec 
)

Executes the Copy command.

Parameters
mapViewthe map view to copy from
selectedRecthe rectangle to operate on

Definition at line 136 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doCopy().

+ Here is the caller graph for this function:

◆ copyNCut()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.copyNCut ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Rectangle  selectedRec,
@NotNull final CopyMode  copyMode 
)
private

Implements clear, cut and copy in one function (since they are so similar).

Parameters
mapViewthe map view to operate on
selectedRecthe rectangle to operate on
copyModedefines if we have a cut, copy or paste action

Definition at line 147 of file CopyBuffer.java.

Referenced by net.sf.gridarta.gui.copybuffer.CopyBuffer< G, A, R >.clear(), net.sf.gridarta.gui.copybuffer.CopyBuffer< G, A, R >.copy(), and net.sf.gridarta.gui.copybuffer.CopyBuffer< G, A, R >.cut().

+ Here is the caller graph for this function:

◆ cut()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.cut ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Rectangle  selectedRec 
)

Executes the Cut command.

Parameters
mapViewthe map view to cut from
selectedRecthe rectangle to operate on

Definition at line 127 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doCut(), and net.sf.gridarta.gui.copybuffer.CopyBufferTest.testCutPaste1().

+ Here is the caller graph for this function:

◆ getAllGameObjects()

List<G> net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.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

Definition at line 263 of file CopyBuffer.java.

Referenced by net.sf.gridarta.gui.dialog.replace.ReplaceDialog< G, A, R >.display(), and net.sf.gridarta.gui.dialog.replace.ReplaceDialog< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.ReplaceWithBoxItemListener.itemStateChanged().

+ Here is the caller graph for this function:

◆ isEmpty()

boolean net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isEmpty ( )

◆ paste()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.paste ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Point  startLocation 
)

Executes the Paste command.

Parameters
mapViewthe map view to paste on
startLocationthe location to paste into

Definition at line 180 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doPaste(), and net.sf.gridarta.gui.copybuffer.CopyBufferTest.testCutPaste1().

+ Here is the caller graph for this function:

◆ pasteTiled()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.pasteTiled ( @NotNull final MapView< G, A, R >  mapView,
@NotNull final Iterable< MapSquare< G, A, R >>  selectedSquares,
@NotNull final Point  origin 
)

Executes the Paste Tiled command.

Parameters
mapViewthe map view to paste on
selectedSquaresthe square to paste into
originthe origin where to start pasting

Definition at line 220 of file CopyBuffer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doPasteTiled().

+ Here is the caller graph for this function:

◆ removeMapModelListener()

void net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeMapModelListener ( @NotNull final MapModelListener< G, A, R >  listener)

Removes a MapModelListener to be notified about changes of the cut/copied game objects.

Parameters
listenerthe listener

Definition at line 109 of file CopyBuffer.java.

Member Data Documentation

◆ gameObjectFactory

final GameObjectFactory<G, A, R> net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.gameObjectFactory
private

◆ insertionModeSet

◆ mapModel

◆ mapViewSettings

final MapViewSettings net.sf.gridarta.gui.copybuffer.CopyBuffer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.mapViewSettings
private

The documentation for this class was generated from the following file: