cad.simcad.worldsimulator.world
Class MyWorld

java.lang.Object
  |
  +--cad.simcad.worldsimulator.world.MyWorld
All Implemented Interfaces:
java.io.Serializable, SimEnvironment
Direct Known Subclasses:
CaCWorld

public class MyWorld
extends java.lang.Object
implements java.io.Serializable, SimEnvironment

Implementation of SimEnvironment

Version:
1.0
Author:
Charles-Philip Bentley
See Also:
Serialized Form

Field Summary
protected  java.util.Vector _allObjects
           
protected  AbstractMap _am
           
protected  Owner _defaultOwner
           
protected  Drawable2DObject[] _drObEx
           
protected  java.util.Vector _gaiaObjects
           
protected  Owner _gaiaOwner
           
protected  java.util.Vector _miniMapObjects
           
protected  java.util.Vector _movingObjects
           
protected  java.util.Vector _notMovingObjects
           
protected  ObjectMediator _om
           
protected  RandomGenerator _rndGen
           
protected  long _serial
           
protected  StructureMediator _sm
           
protected  SimObjectServer _sos
           
protected  StatServer _ss
           
protected  SimViewer _sv
           
protected  UnitMediator _um
           
protected  java.util.Vector selectedObjects
           
 
Constructor Summary
MyWorld(AbstractMap am, SimViewer sv)
          Creates new LondonTown
 
Method Summary
 void addDrawable2DObject(Drawable2DObject d2dObject)
           
 void addMovingObject(MyUnit mu)
           
 void addOtherObject(SimObject so)
           
 void addSimulatedObject(SimObject so)
           
 void addStaticStructure(PassiveStructure ps)
           
 boolean checkForRoom(SimObject so)
          Returns true if there is room to add the object
 SimObject createSimObject(java.lang.String name, Owner o)
          Adds a new Simulated Objects in the World
 SimObject createSimObject(java.lang.String name, Owner o, PathPlace pp)
          Adds a new Simulated Objects in the World
 AbstractMap getAbstractMap()
          Returns the Map making this world
 Owner getDefaultOwner()
          Return the default owner for this SimEnvironment
 Owner getGaiaOwner()
          Returns the Owner known as Gaia i.e Mother Nature
 Drawable2DObject[] getMiniMapDrawable2DObjects()
          Returns an Array of all the Drawable2DObject the SimWorld knows about
 java.util.Vector getMovingSimulatedObjects()
          Returns a Vector of the simulated units
 java.util.Vector getNotMovingSimulatedBuildings()
          Returns a Vector of the simulated structures
 SimObject[][] getObjects(int xcenter, int ycenter, int halfWidth, int halfHeight)
          Returns the SimObject that can been seen in the area defined by the parameters
 RandomGenerator getRandonGenerator()
          Returns a Random Generator for this world
 SimObjectServer getSimObjectServer()
          Returns the SimObjectServer of the SimEnvironment
 java.util.Vector getSimulatedObjects()
          Returns a Vector of all the simulated Objects
 SimViewer getSimViewer()
           
 StatServer getStatServer()
          Returns the StatServer of the SimEnvironment
 java.lang.String[] getStructureTypesString()
           
 java.util.Vector getStructureTypesVector()
          Returns a Vector of all the different SimObject of type "structure"
 java.lang.String[] getUnitTypesString()
           
 java.util.Vector getUnitTypesVector()
          Returns a Vector of all the different SimObject of type "unit"
 long nextSerial()
          Returns the next serial number for this SimEnvironment
 void removeDrawable2DObject(Drawable2DObject d2dObject)
           
 void removeMovingObject(MyUnit mu)
           
 void removeOtherObject(SimObject so)
           
 void removeSimulatedObject(SimObject so)
          Remove the given SimObject from the SimEnvironment
 void removeStaticStructure(PassiveStructure ps)
           
 void setSimViewer(SimViewer sv)
           
 void updateObjectPosition(SimObject so, PathPlace oldPathPlace, PathPlace newPathPlace)
          Update the position of the object given in parameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_movingObjects

protected java.util.Vector _movingObjects

_allObjects

protected java.util.Vector _allObjects

_miniMapObjects

protected java.util.Vector _miniMapObjects

_gaiaObjects

protected java.util.Vector _gaiaObjects

_notMovingObjects

protected java.util.Vector _notMovingObjects

_am

protected AbstractMap _am

selectedObjects

protected java.util.Vector selectedObjects

_drObEx

protected Drawable2DObject[] _drObEx

_um

protected UnitMediator _um

_sm

protected StructureMediator _sm

_om

protected ObjectMediator _om

_ss

protected StatServer _ss

_sos

protected SimObjectServer _sos

_defaultOwner

protected Owner _defaultOwner

_gaiaOwner

protected Owner _gaiaOwner

_serial

protected long _serial

_sv

protected SimViewer _sv

_rndGen

protected RandomGenerator _rndGen
Constructor Detail

MyWorld

public MyWorld(AbstractMap am,
               SimViewer sv)
Creates new LondonTown

Method Detail

setSimViewer

public void setSimViewer(SimViewer sv)
Specified by:
setSimViewer in interface SimEnvironment

getSimViewer

public SimViewer getSimViewer()
Specified by:
getSimViewer in interface SimEnvironment

updateObjectPosition

public void updateObjectPosition(SimObject so,
                                 PathPlace oldPathPlace,
                                 PathPlace newPathPlace)
Description copied from interface: SimEnvironment
Update the position of the object given in parameters

Specified by:
updateObjectPosition in interface SimEnvironment
Parameters:
so - The SimObject to update
oldPathPlace - the old position of the SimObject. oldPathPlace belongs to Map
newPathPlace - the new position of the SimObject.

addMovingObject

public void addMovingObject(MyUnit mu)

removeMovingObject

public void removeMovingObject(MyUnit mu)

addStaticStructure

public void addStaticStructure(PassiveStructure ps)

removeStaticStructure

public void removeStaticStructure(PassiveStructure ps)

getMovingSimulatedObjects

public java.util.Vector getMovingSimulatedObjects()
Description copied from interface: SimEnvironment
Returns a Vector of the simulated units

Specified by:
getMovingSimulatedObjects in interface SimEnvironment
Returns:
a Vector object

getNotMovingSimulatedBuildings

public java.util.Vector getNotMovingSimulatedBuildings()
Description copied from interface: SimEnvironment
Returns a Vector of the simulated structures

Specified by:
getNotMovingSimulatedBuildings in interface SimEnvironment
Returns:
a Vector object

getMiniMapDrawable2DObjects

public Drawable2DObject[] getMiniMapDrawable2DObjects()
Description copied from interface: SimEnvironment
Returns an Array of all the Drawable2DObject the SimWorld knows about

Specified by:
getMiniMapDrawable2DObjects in interface SimEnvironment
Returns:
an Array of Drawable2DObject. Empty array if there is none

getSimulatedObjects

public java.util.Vector getSimulatedObjects()
Description copied from interface: SimEnvironment
Returns a Vector of all the simulated Objects

Specified by:
getSimulatedObjects in interface SimEnvironment

removeSimulatedObject

public void removeSimulatedObject(SimObject so)
Description copied from interface: SimEnvironment
Remove the given SimObject from the SimEnvironment

Specified by:
removeSimulatedObject in interface SimEnvironment
Parameters:
so - a SimObject

checkForRoom

public boolean checkForRoom(SimObject so)
Returns true if there is room to add the object


addSimulatedObject

public void addSimulatedObject(SimObject so)

removeOtherObject

public void removeOtherObject(SimObject so)

addOtherObject

public void addOtherObject(SimObject so)

addDrawable2DObject

public void addDrawable2DObject(Drawable2DObject d2dObject)

removeDrawable2DObject

public void removeDrawable2DObject(Drawable2DObject d2dObject)

getObjects

public SimObject[][] getObjects(int xcenter,
                                int ycenter,
                                int halfWidth,
                                int halfHeight)
Description copied from interface: SimEnvironment
Returns the SimObject that can been seen in the area defined by the parameters

Specified by:
getObjects in interface SimEnvironment
Parameters:
xcenter - the x coordinate
ycenter - the y coordinate
halfWidth - the number of coordinates we have to take into account right/left xcenter
halfHeight - the number of coordinates we have to take into account above/below ycenter
Returns:
an Array of SimObjects.

getStructureTypesVector

public java.util.Vector getStructureTypesVector()
Description copied from interface: SimEnvironment
Returns a Vector of all the different SimObject of type "structure"

Specified by:
getStructureTypesVector in interface SimEnvironment
Returns:
a Vector object

getStructureTypesString

public java.lang.String[] getStructureTypesString()

getUnitTypesVector

public java.util.Vector getUnitTypesVector()
Description copied from interface: SimEnvironment
Returns a Vector of all the different SimObject of type "unit"

Specified by:
getUnitTypesVector in interface SimEnvironment
Returns:
a Vector object

getUnitTypesString

public java.lang.String[] getUnitTypesString()

getAbstractMap

public AbstractMap getAbstractMap()
Description copied from interface: SimEnvironment
Returns the Map making this world

Specified by:
getAbstractMap in interface SimEnvironment
Returns:
an AbstractMap object

createSimObject

public SimObject createSimObject(java.lang.String name,
                                 Owner o)
Description copied from interface: SimEnvironment
Adds a new Simulated Objects in the World

Specified by:
createSimObject in interface SimEnvironment
Parameters:
name - the name of the Object to create
o - the Owner of this object to be made
Returns:
a SimObject

createSimObject

public SimObject createSimObject(java.lang.String name,
                                 Owner o,
                                 PathPlace pp)
Description copied from interface: SimEnvironment
Adds a new Simulated Objects in the World

Specified by:
createSimObject in interface SimEnvironment
Parameters:
name - the name of the Object to create
o - the Owner of this object to be made
pp - the PathPlace where the new Object should be placed
Returns:
a SimObject

getDefaultOwner

public Owner getDefaultOwner()
Return the default owner for this SimEnvironment

Specified by:
getDefaultOwner in interface SimEnvironment
Pre:
A correctly initialized SimEnvironment
Returns:
an Owner object
Post:
Every SimEnvironment has a default owner for its SimObjects. cannot be null

getGaiaOwner

public Owner getGaiaOwner()
Returns the Owner known as Gaia i.e Mother Nature

Specified by:
getGaiaOwner in interface SimEnvironment
Pre:
always applicable
Returns:
an Owner object
Post:
the Gaia Owner of the World is returned. cannot be null;

getSimObjectServer

public SimObjectServer getSimObjectServer()
Description copied from interface: SimEnvironment
Returns the SimObjectServer of the SimEnvironment

Specified by:
getSimObjectServer in interface SimEnvironment
Returns:
a SimObjectServer

nextSerial

public long nextSerial()
Returns the next serial number for this SimEnvironment

Specified by:
nextSerial in interface SimEnvironment
Pre:
-
Returns:
a long value
Post:
a unique long value, never returned before

getRandonGenerator

public RandomGenerator getRandonGenerator()
Returns a Random Generator for this world

Specified by:
getRandonGenerator in interface SimEnvironment

getStatServer

public StatServer getStatServer()
Description copied from interface: SimEnvironment
Returns the StatServer of the SimEnvironment

Specified by:
getStatServer in interface SimEnvironment
Returns:
a StatServer

Logo

With the help of www.sourceforge.net and www.info.ucl.ac.be