Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.huguesjohnson.tiamat.graphics
Class TileMap

    java.lang.Object
      com.huguesjohnson.tiamat.graphics.Map
          com.huguesjohnson.tiamat.graphics.TileMap

All Implemented Interfaces:
  Storable, Drawable

    public class TileMap

extends Map

TileMap - a map composed of fixed-size tiles

Author:
  Hugues Johnson

Field Summary

Fields inherited from class com.huguesjohnson.tiamat.graphics.Map
`absoluteDir, height, name, width`

Constructor Summary
`TileMap()` Default constructor, creates an empty map.
`TileMap(int width, int height, java.awt.Component canvas)` Create a map with the specified width, height, and canvas.

Method Summary
`void` | `draw()` Draws the entire map.
`void` | `draw(int x, int y)` Draw the tile at (x,y).
`void` | `draw(int x1, int y1, int x2, int y2)` Draw the tiles specified by rectangle (x1,y1)-(x2,y2).
`TileMapData` | `getMapData(int x, int y)` Returns the map data at the specified (x,y) co-ordinate.
`java.lang.Object` | `getObjectAt(int x, int y)` Returns the object at (x,y).
`java.awt.image.BufferedImage` | `getTile(int index)` Returns the tile at the specified index.
`java.awt.image.BufferedImage[]` | `getTileSet()` Returns the tile set for this map.
`boolean` | `importObjectData(java.lang.Object[][] objectData)` Imports object data.
`boolean` | `importTileData(int[][] tileData)` Imports tile data.
`boolean` | `importTileSet(java.lang.String absoluteDir, java.lang.String[] tilePaths)` Imports tileset data.
`boolean` | `importTypeData(int[][] typeData)` Imports type data.
`void` | `onDeserialize(Formatter formatter, java.lang.String absoluteDir)` The onDeserialize event should be fired after an object is de-serialized.
`void` | `setCanvas(java.awt.Component canvas)` Override of setCanvas to reload images when canvas changes.
`void` | `setMapData(int x, int y, TileMapData mapData)` Sets the map data at the specified (x,y) co-ordinate.
`void` | `setObjectAt(int x, int y, java.lang.Object object)` Sets the object at (x,y).
`java.lang.String` | `toString()` Returns a string representation of the object.

Methods inherited from class com.huguesjohnson.tiamat.graphics.Map
`getCanvas, getHeight, getName, getWidth, setAbsoluteDir, setHeight, setName, setWidth`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### TileMap

    public TileMap()

  Default constructor, creates an empty map.

### TileMap

    public TileMap(int width,
                   int height,
                   java.awt.Component canvas)

  Create a map with the specified width, height, and canvas.

  Parameters:
    `width` - The width for this map.
    `height` - The height for this map.
    `canvas` - The canvas for this map.

Method Detail

### getTileSet

    public java.awt.image.BufferedImage[] getTileSet()

  Returns the tile set for this map.

  Returns:
    The tile set for this map.

### getTile

    public java.awt.image.BufferedImage getTile(int index)

  Returns the tile at the specified index.

  Parameters:
    `index` - The index of the time to return.
  Returns:
    The tile at the specified index.

### getMapData

    public TileMapData getMapData(int x,
                                  int y)

  Returns the map data at the specified (x,y) co-ordinate.

  Parameters:
    `x` - The x co-ordinate.
    `y` - The y co-ordinate.
  Returns:
    The map data at (x,y).

### setMapData

    public void setMapData(int x,
                           int y,
                           TileMapData mapData)

  Sets the map data at the specified (x,y) co-ordinate.

  Parameters:
    `x` - The x co-ordinate.
    `y` - The y co-ordinate.
    `mapData` - The data to set at (x,y).

### setCanvas

    public void setCanvas(java.awt.Component canvas)

  Override of setCanvas to reload images when canvas changes.

  Overrides:
    `setCanvas` in class `Map`
  Parameters:
    `canvas` - The new canvas for this map.

### importTileSet

    public boolean importTileSet(java.lang.String absoluteDir,
                                 java.lang.String[] tilePaths)

  Imports tileset data.

  Parameters:
    `absoluteDir` - The absolute path to where images are stored.
    `tilePaths` - An array of relative paths to images.
  Returns:
    Sucess of the import.

### importTileData

    public boolean importTileData(int[][] tileData)

  Imports tile data.

  Parameters:
    `tileData` - An array of tile data.
  Returns:
    Sucess of the import.

### importTypeData

    public boolean importTypeData(int[][] typeData)

  Imports type data.

  Parameters:
    `typeData` - An array of type data.
  Returns:
    Sucess of the import.

### importObjectData

    public boolean importObjectData(java.lang.Object[][] objectData)

  Imports object data.

  Parameters:
    `objectData` - An array of object data.
  Returns:
    Sucess of the import.

### draw

    public void draw()

  Draws the entire map.

  Specified by:
    `draw` in interface `Drawable`
  Specified by:
    `draw` in class `Map`

### draw

    public void draw(int x,
                     int y)

  Draw the tile at (x,y).

  Specified by:
    `draw` in interface `Drawable`
  Specified by:
    `draw` in class `Map`
  Parameters:
    `x` - The x co-ordinate.
    `y` - The y co-ordinate.

### draw

    public void draw(int x1,
                     int y1,
                     int x2,
                     int y2)

  Draw the tiles specified by rectangle (x1,y1)-(x2,y2).

  Specified by:
    `draw` in interface `Drawable`
  Specified by:
    `draw` in class `Map`
  Parameters:
    `x1` - The starting x co-ordinate.
    `y1` - The starting y co-ordinate.
    `x2` - The ending x co-ordinate.
    `y2` - The ending y co-ordinate.

### setObjectAt

    public void setObjectAt(int x,
                            int y,
                            java.lang.Object object)

  Sets the object at (x,y).

  Parameters:
    `x` - The x co-ordinate.
    `y` - The y co-ordinate.
    `object` - The object to set at (x,y).

### getObjectAt

    public java.lang.Object getObjectAt(int x,
                                        int y)

  Returns the object at (x,y).

  Parameters:
    `x` - The x co-ordinate.
    `y` - The y co-ordinate.
  Returns:
    The object at (x,y).

### toString

    public java.lang.String toString()

  Returns a string representation of the object.

  Overrides:
    `toString` in class `Map`
  Returns:
    A string representation of the object.

### onDeserialize

    public void onDeserialize(Formatter formatter,
                              java.lang.String absoluteDir)

  The onDeserialize event should be fired after an object is de-serialized. This allows objects to load transient members, set their working directory, and load Storable members if needed.

  Specified by:
    `onDeserialize` in interface `Storable`
  Specified by:
    `onDeserialize` in class `Map`
  Parameters:
    `formatter` - the formatter to use to load any storable members
    `absoluteDir` - the working directory since all paths stored in the object should be relative

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hugues Johnson