com.threerings.media.tile
Class Tile

java.lang.Object
  extended by com.threerings.media.tile.Tile
Direct Known Subclasses:
BaseTile, ObjectTile, TrimmedTile

public class Tile
extends Object

A tile represents a single square in a single layer in a scene.


Nested Class Summary
static class Tile.Key
          Used when caching tiles.
 
Field Summary
protected  Mirage _mirage
          Our tileset image.
protected static long _totalTileMemory
          Used to track total (estimated) memory in use by tiles.
 Tile.Key key
          The key associated with this tile.
 
Constructor Summary
Tile()
           
 
Method Summary
protected  void finalize()
          Decrement total tile memory by our value.
 long getEstimatedMemoryUsage()
          Returns the estimated memory usage of our underlying tile image.
 int getHeight()
          Returns the height of this tile.
 int getWidth()
          Returns the width of this tile.
 boolean hitTest(int x, int y)
          Returns true if the specified coordinates within this tile contains a non-transparent pixel.
 void paint(Graphics2D gfx, int x, int y)
          Render the tile image at the specified position in the given graphics context.
 void setImage(Mirage image)
          Configures this tile with its tile image.
 String toString()
           
protected  void toString(StringBuilder buf)
          This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific tile information to the string buffer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

key

public Tile.Key key
The key associated with this tile.


_mirage

protected Mirage _mirage
Our tileset image.


_totalTileMemory

protected static long _totalTileMemory
Used to track total (estimated) memory in use by tiles.

Constructor Detail

Tile

public Tile()
Method Detail

setImage

public void setImage(Mirage image)
Configures this tile with its tile image.


getWidth

public int getWidth()
Returns the width of this tile.


getHeight

public int getHeight()
Returns the height of this tile.


getEstimatedMemoryUsage

public long getEstimatedMemoryUsage()
Returns the estimated memory usage of our underlying tile image.


paint

public void paint(Graphics2D gfx,
                  int x,
                  int y)
Render the tile image at the specified position in the given graphics context.


hitTest

public boolean hitTest(int x,
                       int y)
Returns true if the specified coordinates within this tile contains a non-transparent pixel.


toString

public String toString()
Overrides:
toString in class Object

toString

protected void toString(StringBuilder buf)
This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific tile information to the string buffer.


finalize

protected void finalize()
Decrement total tile memory by our value.

Overrides:
finalize in class Object