com.threerings.media.tile
Class ObjectTileSet

java.lang.Object
  extended by com.threerings.media.tile.TileSet
      extended by com.threerings.media.tile.SwissArmyTileSet
          extended by com.threerings.media.tile.ObjectTileSet
All Implemented Interfaces:
BaseSizableTileSet, RecolorableTileSet, Serializable, Cloneable

public class ObjectTileSet
extends SwissArmyTileSet
implements RecolorableTileSet, BaseSizableTileSet

The object tileset supports the specification of object information for object tiles in addition to all of the features of the swiss army tileset.

See Also:
ObjectTile, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.tile.TileSet
TileSet.Colorizer
 
Field Summary
protected  String[][] _constraints
          Lists of constraints associated with our tiles.
protected  int[] _oheights
          The height (in tile units) of our object tiles.
protected  int[] _owidths
          The width (in tile units) of our object tiles.
protected  byte[] _priorities
          The default render priorities of our objects.
protected  byte[] _sorients
          The orientation of the "spots" associated with our tiles.
protected  int[] _xorigins
          The x offset in pixels to the origin of the tile images.
protected  short[] _xspots
          The x offset to the "spots" associated with our tiles.
protected  int[] _yorigins
          The y offset in pixels to the origin of the tile images.
protected  short[] _yspots
          The y offset to the "spots" associated with our tiles.
protected  String[] _zations
          Colorization classes that apply to our objects.
static String ATTACH
          A constraint prefix indicating that the object must be attached to a wall facing the suffixed direction (N, E, S, or W).
static String LOW
          The low suffix for walls and attachments.
static String ON_SURFACE
          A constraint indicating that the object must be placed on a surface.
static String ON_WALL
          A constraint prefix indicating that the object must be placed on a wall facing the suffixed direction (N, E, S, or W).
static String SPACE
          A constraint prefix indicating that the object must have empty space in the suffixed direction (N, E, S, or W).
static String SURFACE
          A constraint indicating that the object is a surface (e.g., table).
static String WALL
          A constraint prefix indicating that the object is a wall facing the suffixed direction (N, E, S, or W).
 
Fields inherited from class com.threerings.media.tile.SwissArmyTileSet
_gapSize, _heights, _numTiles, _offsetPos, _tileCounts, _widths
 
Fields inherited from class com.threerings.media.tile.TileSet
_atiles, _cacheStatThrottle, _imagePath, _improv, _key, _name
 
Constructor Summary
ObjectTileSet()
           
 
Method Summary
protected  Tile createTile()
          Creates a blank tile of the appropriate type for this tileset.
 int getBaseHeight(int tileIdx)
          Returns the base height for the specified object index.
 int getBaseWidth(int tileIdx)
          Returns the base width for the specified object index.
 String[] getColorizations()
          Returns the colorization classes that should be used to recolor objects in this tileset.
protected  Colorization[] getColorizations(int tileIndex, TileSet.Colorizer rizer)
          Returns colorizations for the specified tile image.
 String[] getConstraints(int tileIdx)
          Returns the list of constraints associated with the specified tile index, or null if the index has no constraints.
 int getSpotOrient(int tileIdx)
          Returns the orientation of the spot associated with the specified tile index.
 int getXSpot(int tileIdx)
          Returns the x coordinate of the spot associated with the specified tile index.
 int getYSpot(int tileIdx)
          Returns the y coordinate of the spot associated with the specified tile index.
 boolean hasConstraint(int tileIdx, String constraint)
          Checks whether the tile at the specified index has the given constraint.
protected  void initTile(Tile tile, int tileIndex, Colorization[] zations)
          Initializes the supplied tile.
 void setColorizations(String[] zations)
          Provides a set of colorization classes that apply to objects in this tileset.
 void setConstraints(String[][] constraints)
          Sets the lists of constraints associated with our object tiles.
 void setObjectHeights(int[] objectHeights)
          Sets the heights (in unit tile count) of the objects in this tileset.
 void setObjectWidths(int[] objectWidths)
          Sets the widths (in unit tile count) of the objects in this tileset.
 void setPriorities(byte[] priorities)
          Sets the default render priorities for our object tiles.
 void setSpotOrients(byte[] sorients)
          Sets the orientation of the "spots" associated with our object tiles.
 void setXOrigins(int[] xorigins)
          Sets the x offset in pixels to the image origin.
 void setXSpots(short[] xspots)
          Sets the x offset to the "spots" associated with our object tiles.
 void setYOrigins(int[] yorigins)
          Sets the y offset in pixels to the image origin.
 void setYSpots(short[] yspots)
          Sets the y offset to the "spots" associated with our object tiles.
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.SwissArmyTileSet
computeTileBounds, computeTileCount, getHeights, getTileCount, getTileCounts, getWidths, setGapSize, setHeights, setOffsetPos, setTileCounts, setWidths
 
Methods inherited from class com.threerings.media.tile.TileSet
checkTileIndex, clone, clone, getImagePath, getName, getRawTileImage, getRawTileSetImage, getTile, getTile, getTile, getTileMirage, getTileMirage, getTileMirages, reportCachePerformance, setImagePath, setImageProvider, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPACE

public static final String SPACE
A constraint prefix indicating that the object must have empty space in the suffixed direction (N, E, S, or W).

See Also:
Constant Field Values

SURFACE

public static final String SURFACE
A constraint indicating that the object is a surface (e.g., table).

See Also:
Constant Field Values

ON_SURFACE

public static final String ON_SURFACE
A constraint indicating that the object must be placed on a surface.

See Also:
Constant Field Values

WALL

public static final String WALL
A constraint prefix indicating that the object is a wall facing the suffixed direction (N, E, S, or W).

See Also:
Constant Field Values

ON_WALL

public static final String ON_WALL
A constraint prefix indicating that the object must be placed on a wall facing the suffixed direction (N, E, S, or W).

See Also:
Constant Field Values

ATTACH

public static final String ATTACH
A constraint prefix indicating that the object must be attached to a wall facing the suffixed direction (N, E, S, or W).

See Also:
Constant Field Values

LOW

public static final String LOW
The low suffix for walls and attachments. Low attachments can be placed on low or normal walls; normal attachments can only be placed on normal walls.

See Also:
Constant Field Values

_owidths

protected int[] _owidths
The width (in tile units) of our object tiles.


_oheights

protected int[] _oheights
The height (in tile units) of our object tiles.


_xorigins

protected int[] _xorigins
The x offset in pixels to the origin of the tile images.


_yorigins

protected int[] _yorigins
The y offset in pixels to the origin of the tile images.


_priorities

protected byte[] _priorities
The default render priorities of our objects.


_zations

protected String[] _zations
Colorization classes that apply to our objects.


_xspots

protected short[] _xspots
The x offset to the "spots" associated with our tiles.


_yspots

protected short[] _yspots
The y offset to the "spots" associated with our tiles.


_sorients

protected byte[] _sorients
The orientation of the "spots" associated with our tiles.


_constraints

protected String[][] _constraints
Lists of constraints associated with our tiles.

Constructor Detail

ObjectTileSet

public ObjectTileSet()
Method Detail

setObjectWidths

public void setObjectWidths(int[] objectWidths)
Sets the widths (in unit tile count) of the objects in this tileset. This must be accompanied by a call to setObjectHeights(int[]).


setObjectHeights

public void setObjectHeights(int[] objectHeights)
Sets the heights (in unit tile count) of the objects in this tileset. This must be accompanied by a call to setObjectWidths(int[]).


setXOrigins

public void setXOrigins(int[] xorigins)
Sets the x offset in pixels to the image origin.


setYOrigins

public void setYOrigins(int[] yorigins)
Sets the y offset in pixels to the image origin.


setPriorities

public void setPriorities(byte[] priorities)
Sets the default render priorities for our object tiles.


setColorizations

public void setColorizations(String[] zations)
Provides a set of colorization classes that apply to objects in this tileset.


setXSpots

public void setXSpots(short[] xspots)
Sets the x offset to the "spots" associated with our object tiles.


setYSpots

public void setYSpots(short[] yspots)
Sets the y offset to the "spots" associated with our object tiles.


setSpotOrients

public void setSpotOrients(byte[] sorients)
Sets the orientation of the "spots" associated with our object tiles.


setConstraints

public void setConstraints(String[][] constraints)
Sets the lists of constraints associated with our object tiles.


getXSpot

public int getXSpot(int tileIdx)
Returns the x coordinate of the spot associated with the specified tile index.


getYSpot

public int getYSpot(int tileIdx)
Returns the y coordinate of the spot associated with the specified tile index.


getSpotOrient

public int getSpotOrient(int tileIdx)
Returns the orientation of the spot associated with the specified tile index.


getConstraints

public String[] getConstraints(int tileIdx)
Returns the list of constraints associated with the specified tile index, or null if the index has no constraints.


hasConstraint

public boolean hasConstraint(int tileIdx,
                             String constraint)
Checks whether the tile at the specified index has the given constraint.


getColorizations

public String[] getColorizations()
Description copied from interface: RecolorableTileSet
Returns the colorization classes that should be used to recolor objects in this tileset.

Specified by:
getColorizations in interface RecolorableTileSet

getBaseWidth

public int getBaseWidth(int tileIdx)
Description copied from interface: BaseSizableTileSet
Returns the base width for the specified object index.

Specified by:
getBaseWidth in interface BaseSizableTileSet

getBaseHeight

public int getBaseHeight(int tileIdx)
Description copied from interface: BaseSizableTileSet
Returns the base height for the specified object index.

Specified by:
getBaseHeight in interface BaseSizableTileSet

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 SwissArmyTileSet

getColorizations

protected Colorization[] getColorizations(int tileIndex,
                                          TileSet.Colorizer rizer)
Description copied from class: TileSet
Returns colorizations for the specified tile image. The default is to return any colorizations associated with the tileset via a call to TileSet.clone(Colorization[]), however derived classes may have dynamic colorization policies that look up colorization assignments from the supplied colorizer.

Overrides:
getColorizations in class TileSet

createTile

protected Tile createTile()
Description copied from class: TileSet
Creates a blank tile of the appropriate type for this tileset.

Overrides:
createTile in class TileSet
Returns:
a blank tile ready to be populated with its image and metadata.

initTile

protected void initTile(Tile tile,
                        int tileIndex,
                        Colorization[] zations)
Description copied from class: TileSet
Initializes the supplied tile. Derived classes can override this method to add in their own tile information, but should be sure to call super.initTile().

Overrides:
initTile in class TileSet
Parameters:
tile - the tile to initialize.
tileIndex - the index of the tile.
zations - the colorizations to be used when generating the tile image.