Interface TileProvider


public interface TileProvider
A provider of image tiles.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Register a tile listener which will be notified if the contents of a tile change.
    Get the coordinates of the "main area of interest" of this tile provider, if any, in tile coordinates and disregarding the current zoom level.
    int
    getTilePriority(int x, int y)
    Get the priority with which a specific tile should be rendered.
    int
    Get the width and height of tiles (which must be square) in pixels.
    int
    Get the zoom as an exponent of two.
    boolean
    isTilePresent(int x, int y)
    Determines, if possible, if there is a tile present at a specified location.
    boolean
    Indicates whether the tile provider implements zooming itself (when true) or whether the tile consumer should implement it (when false).
    boolean
    paintTile(Image image, int x, int y, int dx, int dy)
    Paint the tile at the specified tile coordinates to an image.
    void
    Remove a previously registered tile listener.
    void
    setZoom(int zoom)
    Set the zoom as an exponent of two.
  • Method Details

    • getTileSize

      int getTileSize()
      Get the width and height of tiles (which must be square) in pixels. The size must be a power of two!
      Returns:
      The size in pixels of a tile.
    • isTilePresent

      boolean isTilePresent(int x, int y)
      Determines, if possible, if there is a tile present at a specified location.
      Parameters:
      x - The X coordinate (in tiles) to check for the presence of a tile.
      y - The Y coordinate (in tiles) to check for the presence of a tile.
      Returns:
      true if there is a tile there.
    • paintTile

      boolean paintTile(Image image, int x, int y, int dx, int dy)
      Paint the tile at the specified tile coordinates to an image. The X coordinate increases to the right and the Y coordinate increases towards the bottom. An image of the correct size (or larger) will be provided on which to paint the tile. The tile provider may be requested to paint the tile in a different location on the provided image than the top left corner.

      The provider must paint the tile completely. The image is guaranteed to support transparency and the provider may make parts or all of the tile transparent.

      The provider may fail to paint the tile for some reason, for example because a dependency is not met, in which case it should return false and leave the image unaltered.

      Parameters:
      image - The image on which to paint the tile
      x - The X coordinate (in tiles) of the tile to paint.
      y - The Y coordinate (in tiles) of the tile to paint.
      dx - The X coordinate at which to paint the tile in the image.
      dy - The Y coordinate at which to paint the tile in the image.
      Returns:
      true if the tile was painted; false if it could not be painted for some reason.
    • getTilePriority

      int getTilePriority(int x, int y)
      Get the priority with which a specific tile should be rendered. A tile consumer may choose to render higher priority tiles before lower priority tiles. It is entirely up to the tile provider which values to return, or even to always return the same value.
      Parameters:
      x - The X coordinate (in tiles) of the tile.
      y - The Y coordinate (in tiles) of the tile.
      Returns:
      The priority of the specified tile.
    • getExtent

      Rectangle getExtent()
      Get the coordinates of the "main area of interest" of this tile provider, if any, in tile coordinates and disregarding the current zoom level. Note that the tile provider is still free to provide tiles outside this area. If the tile provider has no distinguishable area of interest (because it is endless, for instance), it may return null.
      Returns:
      The coordinates of the main area of interest of this tile provider.
    • addTileListener

      void addTileListener(TileListener tileListener)
      Register a tile listener which will be notified if the contents of a tile change.
      Parameters:
      tileListener - The tile listener to register.
    • removeTileListener

      void removeTileListener(TileListener tileListener)
      Remove a previously registered tile listener.
      Parameters:
      tileListener - The tile listener to remove.
    • isZoomSupported

      boolean isZoomSupported()
      Indicates whether the tile provider implements zooming itself (when true) or whether the tile consumer should implement it (when false). In the latter case getZoom() and setZoom(int) will never be invoked.
      Returns:
      true if the tile provider implements zooming.
    • getZoom

      int getZoom()
      Get the zoom as an exponent of two. In other words the tiles will be displayed at a scale of 1:2^n, so that n=-1 means half size, n=0 means 1:1 and 1 means double size, etc.
      Returns:
      The zoom as an exponent of two.
    • setZoom

      void setZoom(int zoom)
      Set the zoom as an exponent of two. In other words the tiles will be displayed at a scale of 1:2^n, so that n=-1 means half size, n=0 means 1:1 and 1 means double size, etc.
      Parameters:
      zoom - The zoom as an exponent of two.