# Class Tile

java.lang.Object
com.codename1.maps.Tile

Direct Known Subclasses:
  `ProxyHttpTile`

public class Tile extends java.lang.Object
This class represents a single tile on a map. a map is been constructed from a few tiles that are been tiled on next to the other.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Tile(Dimension dimension, BoundingBox boundingBox, Image image)`
  Creates a new Tile.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Dimension`
  `dimension()`
  Gets the tile dimension
  `protected void`
  `fireReady()`
  inform the TileReadyListener that this tile is ready to be painted
  `BoundingBox`
  `getBoundingBox()`
  Gets the tile bounding box.
  `boolean`
  `paint(Graphics g)`
  Paints the tile on the Graphics Object
  `void`
  `paint(Graphics g, int x, int y)`
  Paints the tile on the Graphics Object translated to the given x, y, This method paints the tile image if available or will call paintTileLoading
  `void`
  `paintTileLoading(Graphics g)`
  This method paints a "tile loading" on the Graphics if boolean paint(Graphics g) returned false.
  `Point`
  `pointPosition(Coord point)`
  Returns the x, y point of the given coordinate relative to this tile
  `Coord`
  `position(int posX, int posY)`
  Returns the Coordinate of the given x, y position on the tile
  `static void`
  `setPaintLoading(boolean toPaint)`
  This flag indicates if the Tile should paint a Loading image or Text or simply not do any painting if a map image is not ready for painting
  `void`
  `setsTileReadyListener(ActionListener listener)`
  Sets a Listener to be notified when the tile is fireReady to be painted
  `static void`
  `setTileLoadingImage(Image tileLoadingImage)`
  Sets a static image that will be drawn on the map if the tile image is not available yet.
  `static void`
  `setTileLoadingText(String tileLoadingText)`
  Sets a static text to paint.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Tile

    public Tile(Dimension dimension, BoundingBox boundingBox, Image image)

    Creates a new Tile.

    ###### Parameters

    - `dimension`: the tile Dimensions (usually 256x256)

    - `getBoundingBox`: the bounding box this tile is showing

    - `image`: the map image or null.

- ## Method Details

  - ### setPaintLoading

    public static void setPaintLoading(boolean toPaint)

    This flag indicates if the Tile should paint a Loading image or Text or simply not do any painting if a map image is not ready for painting

    ###### Parameters

    - `if`: @param if true a Loading rect is displayed when map image is being downloaded

  - ### setTileLoadingImage

    public static void setTileLoadingImage(Image tileLoadingImage)

    Sets a static image that will be drawn on the map if the tile image is not available yet.

    ###### Parameters

    - `tileLoadingImage`

  - ### setTileLoadingText

    public static void setTileLoadingText(String tileLoadingText)

    Sets a static text to paint. This will be used if the map if the tile image is not available yet and the tileLoadingImage is null

    ###### Parameters

    - `tileLoadingText`

  - ### pointPosition

    public Point pointPosition(Coord point)

    Returns the x, y point of the given coordinate relative to this tile

    ###### Parameters

    - `point`: a coordinate to translate to x, y

    ###### Returns

    a Point object relative to this tile

  - ### position

    public Coord position(int posX, int posY)

    Returns the Coordinate of the given x, y position on the tile

    ###### Parameters

    - `posX`

    - `posY`

    ###### Returns

    a Coordinate that was created from the given x, y position

  - ### dimension

    public Dimension dimension()

    Gets the tile dimension

    ###### Returns

    the tile dimension

  - ### getBoundingBox

    public BoundingBox getBoundingBox()

    Gets the tile bounding box.

    ###### Returns

    the tile bounding box.

  - ### paint

    public boolean paint(Graphics g)

    Paints the tile on the Graphics Object

    ###### Parameters

    - `g`: Graphics object to paint on.

    ###### Returns

    true if painting succeeded.

  - ### paint

    public void paint(Graphics g, int x, int y)

    Paints the tile on the Graphics Object translated to the given x, y, This method paints the tile image if available or will call paintTileLoading

    ###### Parameters

    - `g`: Graphics object to paint on.

    - `x`: translate to x before painting

    - `y`: translate to y before painting

  - ### paintTileLoading

    public void paintTileLoading(Graphics g)

    This method paints a "tile loading" on the Graphics if boolean paint(Graphics g) returned false.

    ###### Parameters

    - `g`: Graphics object to paint on.

  - ### setsTileReadyListener

    public void setsTileReadyListener(ActionListener listener)

    Sets a Listener to be notified when the tile is fireReady to be painted

    ###### Parameters

    - `listener`

  - ### fireReady

    protected void fireReady()
    inform the TileReadyListener that this tile is ready to be painted

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `java.lang.Object`