net.sourceforge.worldsaver.rp
Class Area

java.lang.Object
  |
  +--net.sourceforge.worldsaver.rp.RpBase
        |
        +--net.sourceforge.worldsaver.rp.Area
All Implemented Interfaces:
MiscUtils, Saveable
Direct Known Subclasses:
Building, City, Land, World

public abstract class Area
extends RpBase
implements MiscUtils, Saveable

The abstract base class for all areas. There's much implemented in this class, but a specific type of area should extend this class and add some specific information to the new class and the saveable String.

Version:
Feb 16 2001
Author:
Andreas Schmitz

Fields inherited from interface net.sourceforge.worldsaver.util.MiscUtils
CONSOLE_WIDTH, NEWLINE, RANDOM
 
Constructor Summary
Area(java.util.HashMap map)
          Creates a new area from loaded values.
Area(RpBase father, java.lang.String name, int x, int y)
          Creates a new area with a map with x*y tiles, the given name and belonging to the given father.
 
Method Summary
 java.util.ArrayList getMap(int x, int y)
          Returns the list of objects that are on a specific location.
 int getMapX()
          Returns the length of the x-axis of the map.
 int getMapY()
          Returns the length of the y-axis of the map.
 void getReferencesRight(java.util.HashMap pool, IDGenerator gen)
          See RpBase for details.
 java.lang.String getSaveableString()
          Returns a String which can immediately be saved to disk.
 java.awt.image.BufferedImage getVisualization()
          Returns a BufferedImage which shows the area.
 void setMap(RpBase val, int x, int y)
          Fills the specified piece of the map with life.
 void setMapX(int v)
          Resizes the x-axis of the map.
 void setMapY(int v)
          Resizes the y-axis of the map.
 void setVisualization(java.awt.image.BufferedImage val)
          Sets the graphical visualization of the area.
 
Methods inherited from class net.sourceforge.worldsaver.rp.RpBase
addChild, addDescription, copy, getChilds, getDescription, getFather, getID, getName, setDescription, setFather, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Area

public Area(RpBase father,
            java.lang.String name,
            int x,
            int y)
Creates a new area with a map with x*y tiles, the given name and belonging to the given father.
Parameters:
father - the father of the new area
name - the name of the new area
x - the x-axis of the new area
y - the y-axis of the new area

Area

public Area(java.util.HashMap map)
Creates a new area from loaded values.
Parameters:
map - the values
See Also:
RpBase.RpBase(net.sourceforge.worldsaver.rp.RpBase, java.lang.String)
Method Detail

getReferencesRight

public void getReferencesRight(java.util.HashMap pool,
                               IDGenerator gen)
See RpBase for details.
Specified by:
getReferencesRight in interface Saveable
Overrides:
getReferencesRight in class RpBase
See Also:
RpBase.getReferencesRight(java.util.HashMap, net.sourceforge.worldsaver.util.IDGenerator)

getSaveableString

public java.lang.String getSaveableString()
                                   throws java.io.IOException
Returns a String which can immediately be saved to disk.
Specified by:
getSaveableString in interface Saveable
Overrides:
getSaveableString in class RpBase
Returns:
the String
See Also:
RpBase.getSaveableString()

getMapY

public int getMapY()
Returns the length of the y-axis of the map.
Returns:
the y-axis

setMapY

public void setMapY(int v)
Resizes the y-axis of the map.
Parameters:
v - the new length of the y-axis

getMapX

public int getMapX()
Returns the length of the x-axis of the map.
Returns:
the x-axis

setMapX

public void setMapX(int v)
Resizes the x-axis of the map.
Parameters:
v - the new length of the x-axis

setVisualization

public void setVisualization(java.awt.image.BufferedImage val)
Sets the graphical visualization of the area.
Parameters:
val - the BufferedImage which contains the visualization

setMap

public void setMap(RpBase val,
                   int x,
                   int y)
Fills the specified piece of the map with life. You can add several Objects to a tile, for example there could be a city on a piece of a land, and an adventure to take place there.
Parameters:
val - the object that shall be added
x - the x-location of the object
y - the y-location of the object

getMap

public java.util.ArrayList getMap(int x,
                                  int y)
Returns the list of objects that are on a specific location.
Parameters:
x - the x-location
y - the y-location
Returns:
an ArrayList with the Objects or null, if there is nothing

getVisualization

public java.awt.image.BufferedImage getVisualization()
Returns a BufferedImage which shows the area.
Returns:
the image