public abstract class Tile
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Tile.TileState |
Modifier and Type | Field and Description |
---|---|
java.lang.String |
id |
protected java.awt.image.BufferedImage |
image |
protected java.lang.String |
lasErrorMessage |
int |
levelOfDetail |
static long |
MILISECONDS_TO_TILE_MEM_REMOVAL |
protected boolean |
temporaryTransparencyDetectedOnImageOnDisk |
protected static java.lang.String |
TILE_BASE_CACHE_DIR |
protected static java.lang.String |
TILE_FX_EXTENSION |
protected static java.lang.String |
tileClassId |
int |
tileX |
int |
tileY |
int |
worldX |
int |
worldY |
Constructor and Description |
---|
Tile(java.lang.Integer levelOfDetail,
java.lang.Integer tileX,
java.lang.Integer tileY,
java.awt.image.BufferedImage image) |
Tile(java.lang.String id)
This method will try to load from file (
loadTile() ). |
Modifier and Type | Method and Description |
---|---|
static void |
clearDiskCache()
This should be override, this implementation does not do anything.
|
protected static void |
clearDiskCache(java.lang.String tileClassId)
This will delete the disk cache.
|
protected abstract void |
createTileImage()
Implement this to generate the tile image.
|
void |
dispose()
This will invalidate this tile for future use;
If overridden call the super.dispose.
|
java.lang.String |
getId() |
java.lang.String |
getLasErrorMessage() |
long |
getLastPaintTimeMillis() |
static int |
getMaxLevelOfDetail()
Put a static method like this in an overwrite class to indicate
the maximum level of detail to display the tiles.
|
Tile.TileState |
getState() |
protected java.lang.String |
getTileFilePath() |
protected java.lang.String |
getTileFilePathFor(int levelOfDetailToUse,
int tileXToUse,
int tileYToUse) |
static <T extends Tile> |
getTilesMap()
This method should be overridden to return a tile map.
|
static java.lang.String |
getTileStyleID()
Override this to return the tile map style id
|
protected float |
getTransparencyToApplyToImage()
[0.0, 1.0]
|
protected boolean |
isBaseOrLayerMap() |
static boolean |
isFetchableOrGenerated() |
boolean |
isShowTileId() |
protected static <T extends Tile> |
loadCache(java.lang.String tileClassId)
This will delete the disk cache.
|
protected void |
loadOrCreateTileImage()
This method will try to load from file (
loadTile() ). |
boolean |
loadTile()
|
void |
paint(java.awt.Graphics2D g,
StateRenderer2D renderer,
boolean useTransparency) |
void |
retryLoadingTile()
Will retry to reload the tile if the
state ==ERROR
Please call this even if you need to override it. |
boolean |
saveTile()
|
void |
setShowTileId(boolean showTileId) |
protected void |
setState(Tile.TileState state)
The state will not change if the current state =
Tile.TileState.DISPOSING ||
Tile.TileState.FATAL_ERROR except to put the state in Tile.TileState.DISPOSING .. |
static void |
staticPropertiesChanged()
Override to be warned if any of the
NeptusProperty getChanged by PropertiesEditor |
protected void |
testForAlfaOnLoaddImage(java.awt.image.BufferedImage img) |
protected static java.lang.String TILE_BASE_CACHE_DIR
protected static final java.lang.String TILE_FX_EXTENSION
public static final long MILISECONDS_TO_TILE_MEM_REMOVAL
protected java.lang.String lasErrorMessage
protected static java.lang.String tileClassId
public final java.lang.String id
public final int levelOfDetail
public final int tileX
public final int tileY
public final int worldX
public final int worldY
protected java.awt.image.BufferedImage image
protected boolean temporaryTransparencyDetectedOnImageOnDisk
public Tile(java.lang.Integer levelOfDetail, java.lang.Integer tileX, java.lang.Integer tileY, java.awt.image.BufferedImage image) throws java.lang.Exception
levelOfDetail
- tileX
- tileY
- image
- java.lang.Exception
public Tile(java.lang.String id) throws java.lang.Exception
loadTile()
). If not,
will call createTileImage()
. This calls will run on a Thread
and because of that this constructor will return straightway.id
- This should be the
MapTileUtil.tileXYToQuadKey(int, int, int)
and
MapTileUtil.quadKeyToTileXY(String)
java.lang.Exception
public long getLastPaintTimeMillis()
public Tile.TileState getState()
protected void setState(Tile.TileState state)
Tile.TileState.DISPOSING
||
Tile.TileState.FATAL_ERROR
except to put the state in Tile.TileState.DISPOSING
..state
- the state to setpublic java.lang.String getLasErrorMessage()
public void retryLoadingTile()
state
==ERROR
Please call this even if you need to override it.public boolean isShowTileId()
public void setShowTileId(boolean showTileId)
showTileId
- the showTileId to setpublic static int getMaxLevelOfDetail()
protected final void loadOrCreateTileImage()
loadTile()
). If not,
will call createTileImage()
.
This creates a Thread
to execute and return straightway.protected float getTransparencyToApplyToImage()
protected abstract void createTileImage()
state
,
if equal to Tile.TileState.DISPOSING
or
Tile.TileState.FATAL_ERROR
return without processing.public static boolean isFetchableOrGenerated()
public static java.lang.String getTileStyleID()
public static void staticPropertiesChanged()
NeptusProperty
getChanged by PropertiesEditor
public static <T extends Tile> java.util.Map<java.lang.String,T> getTilesMap()
public java.lang.String getId()
public void paint(java.awt.Graphics2D g, StateRenderer2D renderer, boolean useTransparency)
public void dispose()
protected final java.lang.String getTileFilePath()
protected final java.lang.String getTileFilePathFor(int levelOfDetailToUse, int tileXToUse, int tileYToUse)
public boolean saveTile()
TILE_BASE_CACHE_DIR
/[Class SimpleName]/z
levelOfDetail
/xtileX
/ytileY
.
TILE_FX_EXTENSION
public boolean loadTile()
TILE_BASE_CACHE_DIR
/[Class SimpleName]/z
levelOfDetail
/xtileX
/ytileY
.
TILE_FX_EXTENSION
Sets the state
protected void testForAlfaOnLoaddImage(java.awt.image.BufferedImage img)
img
- protected boolean isBaseOrLayerMap()
public static void clearDiskCache()
protected static void clearDiskCache(java.lang.String tileClassId)
tileClassId
- This should be the class Class.getSimpleName()
.protected static <T extends Tile> java.util.Vector<T> loadCache(java.lang.String tileClassId)
tileClassId
- This should be the class Class.getSimpleName()
.Copyright © 2004-2020 FEUP-LSTS and Neptus developers. All Rights Reserved.