public class Tile extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
Tile.CachedCallable<V> |
Modifier and Type | Field and Description |
---|---|
protected boolean |
error |
static java.awt.image.BufferedImage |
ERROR_IMAGE
Red cross image that is displayed after a loading error, except for overlay sources
|
protected java.lang.String |
error_message |
protected java.awt.image.BufferedImage |
image |
protected java.lang.String |
key |
protected boolean |
loaded |
protected boolean |
loading |
static java.awt.image.BufferedImage |
LOADING_IMAGE
Hourglass image that is displayed until a map tile has been loaded, except for overlay sources
|
protected java.util.Map<java.lang.String,java.lang.String> |
metadata
TileLoader-specific tile metadata
|
protected TileSource |
source |
protected int |
xtile |
protected int |
ytile |
protected int |
zoom |
Constructor and Description |
---|
Tile(TileSource source,
int xtile,
int ytile,
int zoom)
Creates a tile with empty image.
|
Tile(TileSource source,
int xtile,
int ytile,
int zoom,
java.awt.image.BufferedImage image)
Creates a tile with specified image.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
|
void |
finishLoading()
indicate that loading process for this tile has ended
|
java.lang.String |
getErrorMessage() |
java.awt.image.BufferedImage |
getImage() |
java.lang.String |
getKey() |
java.util.Map<java.lang.String,java.lang.String> |
getMetadata() |
TileSource |
getSource() |
java.lang.String |
getStatus() |
static java.lang.String |
getTileKey(TileSource source,
int xtile,
int ytile,
int zoom) |
TileSource |
getTileSource() |
TileXY |
getTileXY() |
java.lang.String |
getUrl() |
java.lang.String |
getValue(java.lang.String key)
returns the metadata of the Tile
|
int |
getXtile()
Returns the X coordinate.
|
int |
getYtile()
Returns the Y coordinate.
|
int |
getZoom()
Returns the zoom level.
|
boolean |
hasError() |
int |
hashCode()
Note that the hash code does not include the
source . |
void |
initLoading()
indicate that loading process for this tile has started
|
boolean |
isLoaded() |
boolean |
isLoading() |
void |
loadImage(java.io.InputStream input) |
private static java.awt.image.BufferedImage |
loadImage(java.lang.String path) |
void |
loadingCanceled()
indicate that loading process for this tile has been canceled
|
void |
loadPlaceholderFromCache(TileCache cache)
Tries to get tiles of a lower or higher zoom level (one or two level
difference) from cache and use it as a placeholder until the tile has been loaded.
|
void |
paint(java.awt.Graphics g,
int x,
int y)
Paints the tile-image on the
Graphics g at the
position x /y . |
void |
paint(java.awt.Graphics g,
int x,
int y,
int width,
int height)
Paints the tile-image on the
Graphics g at the
position x /y . |
void |
putValue(java.lang.String key,
java.lang.String value)
Puts the given key/value pair to the metadata of the tile.
|
void |
setError(java.lang.Exception e) |
void |
setError(java.lang.String message) |
void |
setImage(java.awt.image.BufferedImage image) |
void |
setLoaded(boolean loaded) |
java.lang.String |
toString() |
public static final java.awt.image.BufferedImage LOADING_IMAGE
public static final java.awt.image.BufferedImage ERROR_IMAGE
protected TileSource source
protected int xtile
protected int ytile
protected int zoom
protected java.awt.image.BufferedImage image
protected java.lang.String key
protected volatile boolean loaded
protected volatile boolean loading
protected volatile boolean error
protected java.lang.String error_message
protected java.util.Map<java.lang.String,java.lang.String> metadata
public Tile(TileSource source, int xtile, int ytile, int zoom)
source
- Tile sourcextile
- X coordinateytile
- Y coordinatezoom
- Zoom levelpublic Tile(TileSource source, int xtile, int ytile, int zoom, java.awt.image.BufferedImage image)
source
- Tile sourcextile
- X coordinateytile
- Y coordinatezoom
- Zoom levelimage
- Image contentprivate static java.awt.image.BufferedImage loadImage(java.lang.String path)
public void loadPlaceholderFromCache(TileCache cache)
cache
- Tile cachepublic TileSource getSource()
public int getXtile()
public int getYtile()
public int getZoom()
public java.awt.image.BufferedImage getImage()
public void setImage(java.awt.image.BufferedImage image)
public void loadImage(java.io.InputStream input) throws java.io.IOException
java.io.IOException
public java.lang.String getKey()
public boolean isLoaded()
public boolean isLoading()
public void setLoaded(boolean loaded)
public java.lang.String getUrl() throws java.io.IOException
java.io.IOException
public void paint(java.awt.Graphics g, int x, int y)
Graphics
g
at the
position x
/y
.g
- the Graphics objectx
- x-coordinate in g
y
- y-coordinate in g
public void paint(java.awt.Graphics g, int x, int y, int width, int height)
Graphics
g
at the
position x
/y
.g
- the Graphics objectx
- x-coordinate in g
y
- y-coordinate in g
width
- width that tile should haveheight
- height that tile should havepublic java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
source
.
Therefore a hash based collection can only contain tiles
of one source
.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
obj
based on
the fields xtile
, ytile
and
zoom
.
The source
field is ignored.equals
in class java.lang.Object
public static java.lang.String getTileKey(TileSource source, int xtile, int ytile, int zoom)
public java.lang.String getStatus()
public boolean hasError()
public java.lang.String getErrorMessage()
public void setError(java.lang.Exception e)
public void setError(java.lang.String message)
public void putValue(java.lang.String key, java.lang.String value)
key
- Keyvalue
- Valuepublic java.lang.String getValue(java.lang.String key)
key
- metadata key that should be returnedpublic java.util.Map<java.lang.String,java.lang.String> getMetadata()
public void initLoading()
public void finishLoading()
public TileSource getTileSource()
public void loadingCanceled()