Gridarta Editor
net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Referenceabstract

Base class for classes that contain GameObjects as children in the sense of containment. More...

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

Classes

class  ReverseIterator
 An iterator for iterating over a list in reverse order. More...
 

Public Member Functions

void addFirst (@NotNull final G gameObject)
 Add the given GameObject at the end of this Container. More...
 
void addLast (@NotNull final G gameObject)
 Add the given GameObject at the end of this Container. More...
 
abstract G asGameObject ()
 Returns this instance as a GameObject or. More...
 
getFirst ()
 Return the first GameObject contained in this container. More...
 
getLast ()
 Return the last GameObject contained in this container. More...
 
abstract MapSquare< G, A, R > getMapSquare ()
 Returns the MapSquare of this container. More...
 
getNext (@NotNull final G gameObject)
 Return the GameObject succeeding a given game object. More...
 
getPrev (@NotNull final G gameObject)
 Return the GameObject preceding a given game object. More...
 
boolean hasSameContents (@NotNull final GameObjectContainer<?, ?, ?> gameObjectContainer)
 Compare this object to another game object container. More...
 
void insertAfter (@Nullable final G previousGameObject, @NotNull final G gameObject)
 Add a GameObject after another. More...
 
void insertBefore (@NotNull final G gameObject, @Nullable final G nextGameObject)
 Add a GameObject before another. More...
 
boolean isBottom (@NotNull final G gameObject)
 Returns whether this game object is the bottom-most one. More...
 
boolean isEmpty ()
 Check whether this square is empty. More...
 
boolean isTop (@NotNull final G gameObject)
 Returns whether this game object is the top-most one. More...
 
Iterator< G > iterator ()
 The Iterator returned does not recurse, it only contains objects on the first level. More...
 
void moveBottom (@NotNull final G gameObject)
 Move an item to bottom. More...
 
void moveDown (@NotNull final G gameObject)
 Move an item down. More...
 
void moveTop (@NotNull final G gameObject)
 Move an item to top. More...
 
void moveUp (@NotNull final G gameObject)
 Move an item up. More...
 
Iterable< G > recursive ()
 Return an object that is a recursive representation. More...
 
void remove (@NotNull final G gameObject)
 Remove a GameObject from this container. More...
 
void removeAll ()
 Removes all GameObjects from this container. More...
 
void replace (@NotNull final G oldGameObject, @NotNull final G newGameObject)
 Replace an GameObject with another one. More...
 
Iterable< G > reverse ()
 Return an object that is the reverse representation. More...
 
String toString ()
 

Protected Member Functions

Object clone ()
 
 GameObjectContainer ()
 Create a new GameObjectContainer. More...
 
abstract void notifyBeginChange ()
 Notify the map model that this container is about to change. More...
 
abstract void notifyEndChange ()
 Notify the map model that this container has changed. More...
 
abstract void setThisContainer (@NotNull G gameObject)
 Sets a GameObject's container to this container. More...
 

Private Member Functions

void initData ()
 Initialize the fields. More...
 
void readObject (@NotNull final ObjectInputStream stream) throws IOException, ClassNotFoundException
 

Private Attributes

List< G > contents
 The contents of this container. More...
 
transient Iterable< G > recursive
 Iterable implementation for recursive traversal. More...
 
transient Iterable< G > reverse
 Iterable implementation for reverse traversal. More...
 

Static Private Attributes

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

Detailed Description

Base class for classes that contain GameObjects as children in the sense of containment.

The interface serves 2 main purposes:

  • GameObject extends this class for containing other GameObjects, like inventory contents e.g. of a bag or attached events.
  • MapSquare extends this class to list the squares on a MapSquare.
Author
Christian Hujer
Todo:
In case of MapSquares, this class is most likely bogus regarding multi-part objects. This needs to be fixed.

Definition at line 50 of file GameObjectContainer.java.

Constructor & Destructor Documentation

◆ GameObjectContainer()

net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.GameObjectContainer ( )
protected

Create a new GameObjectContainer.

Definition at line 80 of file GameObjectContainer.java.

Member Function Documentation

◆ addFirst()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addFirst ( @NotNull final G  gameObject)

Add the given GameObject at the end of this Container.

Parameters
gameObjectthe free yet unlinked
GameObject
to be placed in the inventory
Exceptions
IllegalArgumentExceptionif
gameObject
already is inside another container

Definition at line 450 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testAddFirst().

+ Here is the caller graph for this function:

◆ addLast()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addLast ( @NotNull final G  gameObject)

Add the given GameObject at the end of this Container.

Parameters
gameObjectthe free yet unlinked
GameObject
to be placed in the inventory
Exceptions
IllegalArgumentExceptionif
gameObject
already is inside another container

Definition at line 428 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.mapmodel.SavedSquares< G, A, R >.applyChanges(), net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.newContainer(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testAddLast().

+ Here is the caller graph for this function:

◆ asGameObject()

abstract G net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.asGameObject ( )
abstract

Returns this instance as a GameObject or.

null

if this instance is not a game object.

Returns
this instance or
null

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.getContainerGameObject(), and net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.getTopContainer().

+ Here is the caller graph for this function:

◆ clone()

Object net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.clone ( )
protected

Definition at line 604 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectContainer<?, ?, ?>.clone().

+ Here is the caller graph for this function:

◆ getFirst()

G net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getFirst ( )

Return the first GameObject contained in this container.

Returns
first GameObject contained or
null
if isEmpty() returns
true

Definition at line 206 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testInsertAfter().

+ Here is the caller graph for this function:

◆ getLast()

G net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getLast ( )

Return the last GameObject contained in this container.

You should not invoke this method to iterate over GameObjects, such invocation is regarded deprecated.

Returns
last GameObject contained or
null
if isEmpty() returns
true
TypeMayBeWeakened

Definition at line 254 of file GameObjectContainer.java.

◆ getMapSquare()

abstract MapSquare<G, A, R> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapSquare ( )
abstract

◆ getNext()

G net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getNext ( @NotNull final G  gameObject)

Return the GameObject succeeding a given game object.

Parameters
gameObjectthe given game object
Returns
the successor game object or
null
if no successor game object exists.

Definition at line 234 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.deleteSelectedGameObject(), net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.getNext(), and net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.selectBelow().

+ Here is the caller graph for this function:

◆ getPrev()

G net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getPrev ( @NotNull final G  gameObject)

Return the GameObject preceding a given game object.

Parameters
gameObjectthe given game object
Returns
the preceding game object or
null
if no preceding game object exists.

Definition at line 217 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.getPrev(), and net.sf.gridarta.model.mapcursor.MapCursor< G, A, R >.selectAbove().

+ Here is the caller graph for this function:

◆ hasSameContents()

boolean net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.hasSameContents ( @NotNull final GameObjectContainer<?, ?, ?>  gameObjectContainer)

Compare this object to another game object container.

Parameters
gameObjectContainerthe other game object container
Returns
true
if this object equals the other object

Definition at line 634 of file GameObjectContainer.java.

◆ initData()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.initData ( )
private

Initialize the fields.

This is needed because there are two ways of object construction,

  • regular object construction via constructor invocation and
  • cloning of objects via clone().

Definition at line 92 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectContainer<?, ?, ?>.clone().

+ Here is the caller graph for this function:

◆ insertAfter()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.insertAfter ( @Nullable final G  previousGameObject,
@NotNull final G  gameObject 
)

Add a GameObject after another.

Parameters
previousGameObjectprevious anchor or
null
to insert last
gameObjectGameObject to insert
Exceptions
IllegalArgumentExceptionif
gameObject
already is inside another container or
previousGameObject
isn't inside this container TypeMayBeWeakened

Definition at line 477 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.insertAfter(), net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.moveEnv(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testInsertAfter().

+ Here is the caller graph for this function:

◆ insertBefore()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.insertBefore ( @NotNull final G  gameObject,
@Nullable final G  nextGameObject 
)

Add a GameObject before another.

Parameters
gameObjectGameObject to insert
nextGameObjectnextGameObject anchor or
null
to add first
Exceptions
IllegalArgumentExceptionif
gameObject
already is inside another container or
prev
isn't inside this container

Definition at line 523 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.insertBefore(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testInsertBefore().

+ Here is the caller graph for this function:

◆ isBottom()

boolean net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isBottom ( @NotNull final G  gameObject)

Returns whether this game object is the bottom-most one.

Parameters
gameObjectitem to move to top
Returns
whether this game object is the bottom-most one
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 319 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.isBottom().

+ Here is the caller graph for this function:

◆ isEmpty()

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

Check whether this square is empty.

Returns
true
if this square is empty, otherwise
false

Definition at line 196 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.mainactions.MainActions< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doExpandEmptySelection(), and net.sf.gridarta.gui.map.renderer.AbstractSimpleIsoMapRenderer< G, A, R >.paintComponent2().

+ Here is the caller graph for this function:

◆ isTop()

boolean net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isTop ( @NotNull final G  gameObject)

Returns whether this game object is the top-most one.

Parameters
gameObjectitem to move to top
Returns
whether this game object is the top-most one
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 308 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.isTop().

+ Here is the caller graph for this function:

◆ iterator()

Iterator<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.iterator ( )

The Iterator returned does not recurse, it only contains objects on the first level.

The Iterator returned is transparent, that means modifying the iterator's collection actually modifies the underlying GameObjectContainer.

The basic iterator.

Current element (last element returned by next()).

Definition at line 120 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.mapmodel.AutoInsertionModeTest.testInsertSystemObject1(), net.sf.gridarta.model.mapmodel.AutoInsertionModeTest.testInsertSystemObject2(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testIterator().

+ Here is the caller graph for this function:

◆ moveBottom()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.moveBottom ( @NotNull final G  gameObject)

Move an item to bottom.

Parameters
gameObjectitem to move to bottom
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 404 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.moveBottom(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testMoveBottom().

+ Here is the caller graph for this function:

◆ moveDown()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.moveDown ( @NotNull final G  gameObject)

Move an item down.

Parameters
gameObjectitem to move down
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 379 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.moveDown(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testMoveDown().

+ Here is the caller graph for this function:

◆ moveTop()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.moveTop ( @NotNull final G  gameObject)

Move an item to top.

Parameters
gameObjectitem to move to top
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 329 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.moveTop(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testMoveTop().

+ Here is the caller graph for this function:

◆ moveUp()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.moveUp ( @NotNull final G  gameObject)

Move an item up.

Parameters
gameObjectitem to move up
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container

Definition at line 354 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.moveUp(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testMoveUp().

+ Here is the caller graph for this function:

◆ notifyBeginChange()

abstract void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.notifyBeginChange ( )
abstractprotected

Notify the map model that this container is about to change.

◆ notifyEndChange()

abstract void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.notifyEndChange ( )
abstractprotected

Notify the map model that this container has changed.

◆ readObject()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.readObject ( @NotNull final ObjectInputStream  stream) throws IOException, ClassNotFoundException
private

Definition at line 623 of file GameObjectContainer.java.

◆ recursive()

Iterable<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.recursive ( )

Return an object that is a recursive representation.

Invoke this method if you want to iterate over the contained GameObjects recursively.

Returns
recursive representation

Definition at line 188 of file GameObjectContainer.java.

◆ remove()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.remove ( @NotNull final G  gameObject)

Remove a GameObject from this container.

Parameters
gameObjectGameObject to remove
Exceptions
IllegalArgumentExceptionif
gameObject
isn't in this container this implementation does not take care of multi square objects.

Definition at line 265 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.gameobject.AbstractGameObject< GameObject, MapArchObject, Archetype >.remove(), net.sf.gridarta.model.mapmodel.DefaultMapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeGameObject(), and net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testRemove().

+ Here is the caller graph for this function:

◆ removeAll()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeAll ( )

Removes all GameObjects from this container.

this implementation does not take care of multi square objects.

Definition at line 285 of file GameObjectContainer.java.

◆ replace()

void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.replace ( @NotNull final G  oldGameObject,
@NotNull final G  newGameObject 
)

Replace an GameObject with another one.

Parameters
oldGameObjectold GameObject to be replaced
newGameObjectnew GameObject that replaces oldGameObject
Exceptions
IllegalArgumentExceptionif
oldGameObject
isn't in this container or is a multi-part object

Definition at line 558 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testReplace().

+ Here is the caller graph for this function:

◆ reverse()

Iterable<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reverse ( )

◆ setThisContainer()

abstract void net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setThisContainer ( @NotNull G  gameObject)
abstractprotected

Sets a GameObject's container to this container.

Parameters
gameObjectthe game object

Referenced by net.sf.gridarta.model.baseobject.GameObjectContainer<?, ?, ?>.clone().

+ Here is the caller graph for this function:

◆ toString()

String net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.toString ( )

Definition at line 664 of file GameObjectContainer.java.

Member Data Documentation

◆ contents

List<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.contents
private

The contents of this container.

Note
the order of this container is bottom to top.

Definition at line 63 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.model.baseobject.GameObjectContainer<?, ?, ?>.clone().

◆ recursive

transient Iterable<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.recursive
private

Iterable implementation for recursive traversal.

Definition at line 69 of file GameObjectContainer.java.

◆ reverse

transient Iterable<G> net.sf.gridarta.model.baseobject.GameObjectContainer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.reverse
private

Iterable implementation for reverse traversal.

Definition at line 75 of file GameObjectContainer.java.

Referenced by net.sf.gridarta.var.crossfire.model.gameobject.PropagateElevationTest.testReverse().

◆ serialVersionUID

final long net.sf.gridarta.model.baseobject.GameObjectContainer< 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 55 of file GameObjectContainer.java.


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