sema
Class World

java.lang.Object
  extended bysema.World
Direct Known Subclasses:
GradientWorld

public class World
extends java.lang.Object

Simulated world. It has his Engine, his Map, his Drawing interface, his Nature,and his Elements.


Field Summary
 Drawing drawing
          The drawing interface associated with this world.
 Engine engine
          The engine associated with this world.
 Map map
          The map associated with this world.
 Nature nature
          The Nature associated with this world.
 
Constructor Summary
World()
          Default world
World(Engine engine, Map map, Nature nature, Drawing drawing, java.lang.String name, java.lang.String comments)
          Constructs a World with an engine a map a drawing and a nature.
 
Method Summary
 void draw()
          Draws some things of the world.
 java.lang.String getComments()
          Returns the comments.
 java.util.TreeMap getElements()
          Elements of the world.
 java.lang.String getName()
          Returns the name.
 java.lang.String[][] getProperties()
          Returns the properties of the world
 Element id2element(java.lang.Integer id)
          Returns the elements corresponding to the ID and null if the ID is not attributed.
protected  java.lang.Integer register(Element el)
          Registers an element and returns its new ID.
 void setProperties(java.lang.String s1, java.lang.String s2)
          Try to sets the value to the property of the world.
protected  void unregister(Element el)
          Unregisters an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

engine

public final Engine engine
The engine associated with this world.


drawing

public final Drawing drawing
The drawing interface associated with this world.


map

public final Map map
The map associated with this world.


nature

public final Nature nature
The Nature associated with this world.

Constructor Detail

World

public World(Engine engine,
             Map map,
             Nature nature,
             Drawing drawing,
             java.lang.String name,
             java.lang.String comments)
Constructs a World with an engine a map a drawing and a nature. Elements register itself to the world.


World

public World()
Default world

Method Detail

getName

public java.lang.String getName()
Returns the name.


getComments

public java.lang.String getComments()
Returns the comments.


draw

public void draw()
Draws some things of the world.


getElements

public java.util.TreeMap getElements()
Elements of the world. The TreeMap associates an element to it's ID Returns a copy of the real treemap.


register

protected java.lang.Integer register(Element el)
Registers an element and returns its new ID.
It's automatically called by the constructor of an Element.


unregister

protected void unregister(Element el)
Unregisters an element.
It's automatically called when an element die (Element.death()).


id2element

public Element id2element(java.lang.Integer id)
Returns the elements corresponding to the ID and null if the ID is not attributed.


getProperties

public java.lang.String[][] getProperties()
Returns the properties of the world

Returns:
the element's properties.
See Also:
Engine.getProperties()

setProperties

public void setProperties(java.lang.String s1,
                          java.lang.String s2)
Try to sets the value to the property of the world. The new value is ignored if the property is read_only or if the value isn't valid.

Parameters:
s1 - the property to change.
s2 - the new value for the property.
See Also:
Engine.setProperties(java.lang.String, java.lang.String)