com.threerings.media.tile
Class SwissArmyTileSet

java.lang.Object
  extended by com.threerings.media.tile.TileSet
      extended by com.threerings.media.tile.SwissArmyTileSet
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
BaseTileSet, ObjectTileSet

public class SwissArmyTileSet
extends TileSet

The swiss army tileset supports a diverse variety of tiles in the tileset image. Each row can contain varying numbers of tiles and each row can have its own width and height. Tiles can be separated from the edge of the tileset image by some border offset and can be separated from one another by a gap distance.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.tile.TileSet
TileSet.Colorizer
 
Field Summary
protected  Dimension _gapSize
          The distance (x, y) in pixels between each tile in each row horizontally, and between each row of tiles vertically.
protected  int[] _heights
          The height of the tiles in each row in pixels.
protected  int _numTiles
          The number of tiles in the tileset.
protected  Point _offsetPos
          The offset distance (x, y) in pixels from the top-left of the image to the start of the first tile image.
protected  int[] _tileCounts
          The number of tiles in each row.
protected  int[] _widths
          The width of the tiles in each row in pixels.
 
Fields inherited from class com.threerings.media.tile.TileSet
_atiles, _cacheStatThrottle, _imagePath, _improv, _key, _name, _zations
 
Constructor Summary
SwissArmyTileSet()
           
 
Method Summary
 Rectangle computeTileBounds(int tileIndex, Rectangle bounds)
          Computes and fills in the bounds for the specified tile based on the mechanism used by the derived class to do such things.
protected  void computeTileCount()
          Computes our total tile count from the individual counts for each row.
 int[] getHeights()
          Returns the height settings.
 int getTileCount()
          Returns the number of tiles in the tileset.
 int[] getTileCounts()
          Returns the tile count settings.
 int[] getWidths()
          Returns the width settings.
 void setGapSize(Dimension gapSize)
          Sets the size of the gap between tiles (in pixels).
 void setHeights(int[] heights)
          Sets the tile heights for each row.
 void setOffsetPos(Point offsetPos)
          Sets the offset in pixels of the upper left corner of the first tile in the first row.
 void setTileCounts(int[] tileCounts)
          Sets the tile counts which are the number of tiles in each row of the tileset image.
 void setWidths(int[] widths)
          Sets the tile widths for each row.
protected  void toString(StringBuilder buf)
          Derived classes can override this, calling super.toString(buf) and then appending additional information to the buffer.
 
Methods inherited from class com.threerings.media.tile.TileSet
checkTileIndex, clone, clone, createTile, getColorizations, getImagePath, getName, getRawTileImage, getRawTileSetImage, getTile, getTile, getTile, getTileMirage, getTileMirage, getTileMirages, initTile, reportCachePerformance, setImagePath, setImageProvider, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_tileCounts

protected int[] _tileCounts
The number of tiles in each row.


_numTiles

protected int _numTiles
The number of tiles in the tileset.


_widths

protected int[] _widths
The width of the tiles in each row in pixels.


_heights

protected int[] _heights
The height of the tiles in each row in pixels.


_offsetPos

protected Point _offsetPos
The offset distance (x, y) in pixels from the top-left of the image to the start of the first tile image.


_gapSize

protected Dimension _gapSize
The distance (x, y) in pixels between each tile in each row horizontally, and between each row of tiles vertically.

Constructor Detail

SwissArmyTileSet

public SwissArmyTileSet()
Method Detail

getTileCount

public int getTileCount()
Description copied from class: TileSet
Returns the number of tiles in the tileset.

Specified by:
getTileCount in class TileSet

computeTileBounds

public Rectangle computeTileBounds(int tileIndex,
                                   Rectangle bounds)
Description copied from class: TileSet
Computes and fills in the bounds for the specified tile based on the mechanism used by the derived class to do such things. The width and height of the bounds should be the size of the tile image and the x and y offset should be the offset in the tileset image for the image data of the specified tile.

Specified by:
computeTileBounds in class TileSet
Parameters:
tileIndex - the index of the tile whose bounds are to be computed.
bounds - the rectangle object into which to fill the bounds.
Returns:
the rectangle passed into the bounds parameter.

setTileCounts

public void setTileCounts(int[] tileCounts)
Sets the tile counts which are the number of tiles in each row of the tileset image. Each row can have an arbitrary number of tiles.


getTileCounts

public int[] getTileCounts()
Returns the tile count settings.


computeTileCount

protected void computeTileCount()
Computes our total tile count from the individual counts for each row.


setWidths

public void setWidths(int[] widths)
Sets the tile widths for each row. Each row can have tiles of a different width.


getWidths

public int[] getWidths()
Returns the width settings.


setHeights

public void setHeights(int[] heights)
Sets the tile heights for each row. Each row can have tiles of a different height.


getHeights

public int[] getHeights()
Returns the height settings.


setOffsetPos

public void setOffsetPos(Point offsetPos)
Sets the offset in pixels of the upper left corner of the first tile in the first row. If the tileset image has a border, this can be set to account for it.


setGapSize

public void setGapSize(Dimension gapSize)
Sets the size of the gap between tiles (in pixels). If the tiles have space between them, this can be set to account for it.


toString

protected void toString(StringBuilder buf)
Description copied from class: TileSet
Derived classes can override this, calling super.toString(buf) and then appending additional information to the buffer.

Overrides:
toString in class TileSet