Package nl.bebr.mapviewer.data
Class Tile<T>
- java.lang.Object
-
- nl.bebr.mapviewer.data.util.AbstractBean
-
- nl.bebr.mapviewer.data.Tile<T>
-
- Direct Known Subclasses:
OfflineTile
public class Tile<T> extends AbstractBean
The Tile class represents a particular square image piece of the world bitmap at a particular zoom level.- Author:
- joshy, Frantisek Post
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTile.Priority
-
Field Summary
Fields Modifier and Type Field Description protected SoftReference<T>imageThe image loaded for this Tilestatic StringLOADEDprotected TileFactory<T,Tile<T>>tileFactory
-
Constructor Summary
Constructors Constructor Description Tile(int x, int y, int zoom)Create a new Tile at the specified tile point and zoom levelTile(int x, int y, int zoom, String url, Tile.Priority priority, TileFactory<T,Tile<T>> tileFactory)Create a new Tile that loads its data from the given URL.Tile(int x, int y, int zoom, String url, TileFactory<T,Tile<T>> tileFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUniquePropertyChangeListener(String propertyName, PropertyChangeListener listener)Adds a single property change listener.voidfirePropertyChangeOnEDT(String propertyName, Object oldValue, Object newValue)ThrowablegetError()TgetImage()Returns the Image associated with this Tile.ThrowablegetLoadingError()Returns the Throwable tied to any error that may have ocurred while loading the tile.Tile.PrioritygetPriority()Gets the loading priority of this tile.ThrowablegetUnrecoverableError()Returns the last error in a possible chain of errors that occured during the loading of the tileStringgetURL()Gets the URL of this tile.intgetX()intgetY()intgetZoom()booleanisLoaded()Indicates if this tile's underlying image has been successfully loaded yet.booleanisLoading()voidsetError(Throwable error)voidsetLoaded(boolean loaded)Toggles the loaded state, and fires the appropriate property change notificationvoidsetLoading(boolean isLoading)voidsetPriority(Tile.Priority priority)Set the loading priority of this tile.-
Methods inherited from class nl.bebr.mapviewer.data.util.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Field Detail
-
LOADED
public static final String LOADED
- See Also:
- Constant Field Values
-
tileFactory
protected TileFactory<T,Tile<T>> tileFactory
-
image
protected SoftReference<T> image
The image loaded for this Tile
-
-
Constructor Detail
-
Tile
public Tile(int x, int y, int zoom)Create a new Tile at the specified tile point and zoom level- Parameters:
location-zoom-
-
Tile
public Tile(int x, int y, int zoom, String url, TileFactory<T,Tile<T>> tileFactory)
-
Tile
public Tile(int x, int y, int zoom, String url, Tile.Priority priority, TileFactory<T,Tile<T>> tileFactory)Create a new Tile that loads its data from the given URL. The URL must resolve to an image
-
-
Method Detail
-
isLoaded
public boolean isLoaded()
Indicates if this tile's underlying image has been successfully loaded yet.- Returns:
-
setLoaded
public void setLoaded(boolean loaded)
Toggles the loaded state, and fires the appropriate property change notification
-
getUnrecoverableError
public Throwable getUnrecoverableError()
Returns the last error in a possible chain of errors that occured during the loading of the tile
-
getLoadingError
public Throwable getLoadingError()
Returns the Throwable tied to any error that may have ocurred while loading the tile. This error may change several times if multiple errors occur- Returns:
-
getImage
public T getImage()
Returns the Image associated with this Tile. This is a read only property This may return null at any time, however if this returns null, a load operation will automatically be started for it.
-
getZoom
public int getZoom()
- Returns:
- the zoom level that this tile belongs in
-
addUniquePropertyChangeListener
public void addUniquePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a single property change listener. If a listener has been previously added then it will be replaced by the new one.- Parameters:
propertyName-listener-
-
firePropertyChangeOnEDT
public void firePropertyChangeOnEDT(String propertyName, Object oldValue, Object newValue)
-
getError
public Throwable getError()
- Returns:
- the error
-
setError
public void setError(Throwable error)
- Parameters:
error- the error to set
-
isLoading
public boolean isLoading()
- Returns:
- the isLoading
-
setLoading
public void setLoading(boolean isLoading)
- Parameters:
isLoading- the isLoading to set
-
getPriority
public Tile.Priority getPriority()
Gets the loading priority of this tile.- Returns:
-
setPriority
public void setPriority(Tile.Priority priority)
Set the loading priority of this tile.- Parameters:
priority- the priority to set
-
getURL
public String getURL()
Gets the URL of this tile.- Returns:
-
getX
public int getX()
-
getY
public int getY()
-
-