public class Tile extends Object
Constructor and Description |
---|
Tile(Dimension dimension,
BoundingBox boundingBox,
Image image)
Creates a new Tile.
|
Modifier and Type | Method and 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()
Returns a string representation of the object.
|
public Tile(Dimension dimension, BoundingBox boundingBox, Image image)
dimension
- the tile Dimensions (usually 256x256)getBoundingBox
- the bounding box this tile is showingimage
- the map image or null.public Point pointPosition(Coord point)
point
- a coordinate to translate to x, ypublic Coord position(int posX, int posY)
posX
- posY
- public Dimension dimension()
public BoundingBox getBoundingBox()
public boolean paint(Graphics g)
g
- Graphics object to paint on.public void paint(Graphics g, int x, int y)
g
- Graphics object to paint on.x
- translate to x before paintingy
- translate to y before paintingpublic void paintTileLoading(Graphics g)
g
- Graphics object to paint on.public static void setPaintLoading(boolean toPaint)
if
- true a Loading rect is displayed when map image is being
downloadedpublic static void setTileLoadingImage(Image tileLoadingImage)
tileLoadingImage
- public static void setTileLoadingText(String tileLoadingText)
tileLoadingText
- public void setsTileReadyListener(ActionListener listener)
listener
- protected void fireReady()
public String toString()