Gridarta Editor
net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

Records a set of changed map squares. More...

+ Inheritance diagram for net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

void applyChanges (@NotNull final MapModel< G, A, R > mapModel)
 Applies the saved squares to the given map model. More...
 
void clear ()
 Forgets all saved squares. More...
 
SavedSquares< G, A, R > cloneAndClear ()
 Creates a new instance having the same contents as this instance, then forgets all saves squares in this instance. More...
 
boolean isEmpty ()
 Returns whether no saved squares exist. More...
 
void recordMapSquare (@NotNull final MapSquare< G, A, R > mapSquare)
 Records a map square as changed. More...
 
void removeEmptySquares (@NotNull final Size2D size)
 Removes empty squares outside a given area. More...
 
 SavedSquares (@NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers)
 Creates a new instance. More...
 

Private Member Functions

ArrayList< G > allocateMapSquare (final int x, final int y)
 Allocates a saved map square. More...
 
boolean isOutsideEmpty (final int width, final int height)
 Returns whether all squares outside a given area are empty or unchanged. More...
 

Private Attributes

final GameObjectFactory< G, A, R > gameObjectFactory
 The GameObjectFactory to use. More...
 
final GameObjectMatchers gameObjectMatchers
 The GameObjectMatchers to use. More...
 
final List< ArrayList< ArrayList< G > > > savedSquares = new ArrayList<>()
 The saved squares. More...
 

Static Private Attributes

static final long serialVersionUID = 1L
 The serial version UID. More...
 

Detailed Description

Records a set of changed map squares.

Author
Andreas Kirschbaum

Definition at line 41 of file SavedSquares.java.

Constructor & Destructor Documentation

◆ SavedSquares()

net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.SavedSquares ( @NotNull final GameObjectFactory< G, A, R >  gameObjectFactory,
@NotNull final GameObjectMatchers  gameObjectMatchers 
)

Creates a new instance.

Parameters
gameObjectFactorythe game object factory to use
gameObjectMatchersthe game object matchers to use

Definition at line 72 of file SavedSquares.java.

Member Function Documentation

◆ allocateMapSquare()

ArrayList<G> net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.allocateMapSquare ( final int  x,
final int  y 
)
private

Allocates a saved map square.

Parameters
xthe x-coordinate
ythe y-coordinate
Returns
the newly allocated map square or
null
if the map square already did exist

Definition at line 106 of file SavedSquares.java.

Referenced by net.sf.gridarta.model.mapmodel.SavedSquares< G, A, R >.recordMapSquare().

+ Here is the caller graph for this function:

◆ applyChanges()

void net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.applyChanges ( @NotNull final MapModel< G, A, R >  mapModel)

Applies the saved squares to the given map model.

Parameters
mapModelthe map model to change

Definition at line 176 of file SavedSquares.java.

◆ clear()

◆ cloneAndClear()

SavedSquares<G, A, R> net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.cloneAndClear ( )

Creates a new instance having the same contents as this instance, then forgets all saves squares in this instance.

Returns
the new instance

Definition at line 165 of file SavedSquares.java.

Referenced by net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.UndoControl().

+ Here is the caller graph for this function:

◆ isEmpty()

boolean net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isEmpty ( )

Returns whether no saved squares exist.

Returns
whether no saved squares exist

Definition at line 148 of file SavedSquares.java.

◆ isOutsideEmpty()

boolean net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isOutsideEmpty ( final int  width,
final int  height 
)
private

Returns whether all squares outside a given area are empty or unchanged.

Parameters
widththe width of the area
heightthe height of the area
Returns
whether no non-empty squares exist

Definition at line 261 of file SavedSquares.java.

Referenced by net.sf.gridarta.model.mapmodel.SavedSquares< G, A, R >.removeEmptySquares().

+ Here is the caller graph for this function:

◆ recordMapSquare()

void net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.recordMapSquare ( @NotNull final MapSquare< G, A, R >  mapSquare)

◆ removeEmptySquares()

void net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeEmptySquares ( @NotNull final Size2D  size)

Removes empty squares outside a given area.

Parameters
sizethe area

Definition at line 234 of file SavedSquares.java.

Referenced by net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.UndoControl().

+ Here is the caller graph for this function:

Member Data Documentation

◆ gameObjectFactory

◆ gameObjectMatchers

◆ savedSquares

final List<ArrayList<ArrayList<G> > > net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.savedSquares = new ArrayList<>()
private

The saved squares.

Maps x-coordinate to y-coordinate to map squares contents. Not saved map squares (or map columns) are null.

Definition at line 53 of file SavedSquares.java.

Referenced by net.sf.gridarta.model.mapmodel.SavedSquares< G, A, R >.cloneAndClear().

◆ serialVersionUID

final long net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.serialVersionUID = 1L
staticprivate

The serial version UID.

Definition at line 46 of file SavedSquares.java.


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