com.threerings.media.tile
Class ObjectTile

java.lang.Object
  extended by com.threerings.media.tile.Tile
      extended by com.threerings.media.tile.ObjectTile

public class ObjectTile
extends Tile

An object tile extends the base tile to provide support for objects whose image spans more than one unit tile.

An object tile is generally positioned based on its origin rather than the upper left of its image. Generally this origin is in the bottom center of the object image, but can be configured to be anywhere that the natural center point of "contact" is for the object. Note that this does not automatically adjust the semantics of Tile.paint(java.awt.Graphics2D, int, int), it is just expected that the caller will account for the object tile's origin when painting, if appropriate.

An object tile has dimensions (in tile units) that represent its footprint or "shadow".


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.tile.Tile
Tile.Key
 
Field Summary
protected  Dimension _base
          The object footprint width in unit tile units.
protected  String[] _constraints
          The list of constraints associated with this object.
protected  Point _origin
          The offset from the origin of the tile image to the object's origin or MIN_VALUE if the origin should be calculated based on the footprint.
protected  int _priority
          This object tile's default render priority.
protected  byte _sorient
          The orientation of the "spot" associated with this object.
protected  Point _spot
          The coordinates of the "spot" associated with this object.
 
Fields inherited from class com.threerings.media.tile.Tile
_mirage, _totalTileMemory, key
 
Constructor Summary
ObjectTile()
           
 
Method Summary
 int getBaseHeight()
          Returns the object footprint height in tile units.
 int getBaseWidth()
          Returns the object footprint width in tile units.
 String[] getConstraints()
          Returns the list of constraints associated with this object, or null if the object has no constraints.
 int getOriginX()
          Returns the x offset into the tile image of the origin (which will be aligned with the bottom center of the origin tile) or Integer.MIN_VALUE if the origin is not explicitly specified and should be computed from the image size and tile footprint.
 int getOriginY()
          Returns the y offset into the tile image of the origin (which will be aligned with the bottom center of the origin tile) or Integer.MIN_VALUE if the origin is not explicitly specified and should be computed from the image size and tile footprint.
 int getPriority()
          Returns this object tile's default render priority.
 int getSpotOrient()
          Returns the orientation of the "spot" associated with this object.
 int getSpotX()
          Returns the x-coordinate of the "spot" associated with this object.
 int getSpotY()
          Returns the x-coordinate of the "spot" associated with this object.
 boolean hasConstraint(String constraint)
          Checks whether this object has the given constraint.
 boolean hasSpot()
          Returns true if this object has a spot.
protected  void setBase(int width, int height)
          Sets the object footprint in tile units.
 void setConstraints(String[] constraints)
          Configures this object's constraints.
protected  void setOrigin(int x, int y)
          Sets the offset in pixels from the origin of the tile image to the origin of the object.
protected  void setPriority(int priority)
          Sets this object tile's default render priority.
 void setSpot(int x, int y, byte orient)
          Configures the "spot" associated with this object.
 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 com.threerings.media.tile.Tile
finalize, getEstimatedMemoryUsage, getHeight, getWidth, hitTest, paint, setImage, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_base

protected Dimension _base
The object footprint width in unit tile units.


_origin

protected Point _origin
The offset from the origin of the tile image to the object's origin or MIN_VALUE if the origin should be calculated based on the footprint.


_priority

protected int _priority
This object tile's default render priority.


_spot

protected Point _spot
The coordinates of the "spot" associated with this object.


_sorient

protected byte _sorient
The orientation of the "spot" associated with this object.


_constraints

protected String[] _constraints
The list of constraints associated with this object.

Constructor Detail

ObjectTile

public ObjectTile()
Method Detail

getBaseWidth

public int getBaseWidth()
Returns the object footprint width in tile units.


getBaseHeight

public int getBaseHeight()
Returns the object footprint height in tile units.


setBase

protected void setBase(int width,
                       int height)
Sets the object footprint in tile units.


getOriginX

public int getOriginX()
Returns the x offset into the tile image of the origin (which will be aligned with the bottom center of the origin tile) or Integer.MIN_VALUE if the origin is not explicitly specified and should be computed from the image size and tile footprint.


getOriginY

public int getOriginY()
Returns the y offset into the tile image of the origin (which will be aligned with the bottom center of the origin tile) or Integer.MIN_VALUE if the origin is not explicitly specified and should be computed from the image size and tile footprint.


setOrigin

protected void setOrigin(int x,
                         int y)
Sets the offset in pixels from the origin of the tile image to the origin of the object. The object will be rendered such that its origin is at the bottom center of its origin tile. If no origin is specified, the bottom of the image is aligned with the bottom of the origin tile and the left side of the image is aligned with the left edge of the left-most base tile.


getPriority

public int getPriority()
Returns this object tile's default render priority.


setPriority

protected void setPriority(int priority)
Sets this object tile's default render priority.


setSpot

public void setSpot(int x,
                    int y,
                    byte orient)
Configures the "spot" associated with this object.


hasSpot

public boolean hasSpot()
Returns true if this object has a spot.


getSpotX

public int getSpotX()
Returns the x-coordinate of the "spot" associated with this object.


getSpotY

public int getSpotY()
Returns the x-coordinate of the "spot" associated with this object.


getSpotOrient

public int getSpotOrient()
Returns the orientation of the "spot" associated with this object.


getConstraints

public String[] getConstraints()
Returns the list of constraints associated with this object, or null if the object has no constraints.


hasConstraint

public boolean hasConstraint(String constraint)
Checks whether this object has the given constraint.


setConstraints

public void setConstraints(String[] constraints)
Configures this object's constraints.


toString

public void toString(StringBuilder buf)
Description copied from class: Tile
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.

Overrides:
toString in class Tile