T
- Tile Source class used for this layerpublic abstract class AbstractTileSourceLayer<T extends AbstractTMSTileSource> extends ImageryLayer implements java.awt.image.ImageObserver, TileLoaderListener, NavigatableComponent.ZoomChangeListener, ImageryFilterSettings.FilterChangeListener, TileSourceDisplaySettings.DisplaySettingsChangeListener
Modifier and Type | Class and Description |
---|---|
private static class |
AbstractTileSourceLayer.AbstractTileAction |
private class |
AbstractTileSourceLayer.DeepTileSet |
private static class |
AbstractTileSourceLayer.GetOsmTileStatusAction |
private static class |
AbstractTileSourceLayer.LoadTileAction |
private static class |
AbstractTileSourceLayer.MarkOsmTileDirtyAction |
private static class |
AbstractTileSourceLayer.MenuAddition
Class to store a menu action and the class it belongs to.
|
private class |
AbstractTileSourceLayer.OffsetMenuBookmarkEntry
An entry for a bookmark in the offset menu.
|
class |
AbstractTileSourceLayer.PrecacheTask
Task responsible for precaching imagery along the gpx track
|
private static class |
AbstractTileSourceLayer.ShowTileInfoAction |
protected class |
AbstractTileSourceLayer.TileSet |
private static class |
AbstractTileSourceLayer.TileSetInfo
Data container to hold information about a
TileSet class. |
class |
AbstractTileSourceLayer.TileSourceLayerPopup
Tile source layer popup menu.
|
private class |
AbstractTileSourceLayer.TileSourcePainter |
ImageryLayer.OffsetAction, ImageryLayer.OffsetMenuEntry
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
AbstractMapViewPaintable.CompatibilityModeLayerPainter
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
Modifier and Type | Field and Description |
---|---|
private java.awt.event.MouseAdapter |
adapter |
private ImageryAdjustAction |
adjustAction |
private AttributionSupport |
attribution |
protected TileCoordinateConverter |
coordinateConverter |
private int |
currentZoomLevel
Zoomlevel at which tiles is currently downloaded.
|
private TileSourceDisplaySettings |
displaySettings |
private static java.awt.Font |
InfoFont |
private javax.swing.Timer |
invalidateLaterTimer
A timer that is used to delay invalidation events if required.
|
static int |
MAX_ZOOM
maximum zoom level supported
|
private static java.util.List<AbstractTileSourceLayer.MenuAddition> |
menuAdditions
additional layer menu actions
|
static int |
MIN_ZOOM
minium zoom level supported
|
private long |
minimumTileExpire |
private AbstractTileSourceLayer.TileSet |
nullTileSet |
private static java.lang.String |
PREFERENCE_PREFIX |
static IntegerProperty |
PROP_MAX_ZOOM_LVL
maximum zoom level to show to user
|
static IntegerProperty |
PROP_MIN_ZOOM_LVL
minimum zoom level to show to user
|
protected TileCache |
tileCache |
protected TileLoader |
tileLoader |
protected T |
tileSource |
static IntegerProperty |
ZOOM_OFFSET
Offset between calculated zoom level and zoom level used to download and show tiles.
|
icon, info, PROP_SHARPEN_LEVEL
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
Constructor and Description |
---|
AbstractTileSourceLayer(ImageryInfo info)
Creates Tile Source based Imagery Layer based on Imagery Info
|
Modifier and Type | Method and Description |
---|---|
static boolean |
actionSupportLayers(java.util.List<Layer> layers)
Default implementation of
Layer.LayerAction.supportLayers(List) . |
MapViewPaintable.LayerPainter |
attachToMapView(MapViewPaintable.MapViewEvent event)
This method is called whenever this layer is added to a map view.
|
static int |
checkMaxZoomLvl(int maxZoomLvl,
TileSource ts)
Checks zoom level against settings
|
static int |
checkMinZoomLvl(int minZoomLvl,
TileSource ts)
Checks zoom level against settings
|
void |
clearTileCache()
Clears the tile cache.
|
java.io.File |
createAndOpenSaveFileChooser()
Creates a new "Save" dialog for this layer and makes it visible.
When the user has chosen a file, checks the file extension, and confirms overwrite if needed. |
protected TileSourceDisplaySettings |
createDisplaySettings()
This method creates the
TileSourceDisplaySettings object. |
protected MapViewPaintable.LayerPainter |
createMapViewPainter(MapViewPaintable.MapViewEvent event)
Creates a new LayerPainter.
|
boolean |
decreaseZoomLevel()
Zoom out from map.
|
void |
destroy()
Called, when the layer is removed from the mapview and is going to be destroyed.
|
void |
displaySettingsChanged(TileSourceDisplaySettings.DisplaySettingsChangeEvent e)
Called whenever the display settings have changed.
|
private void |
drawImageInside(java.awt.Graphics2D g,
java.awt.image.BufferedImage toDrawImg,
TileAnchor anchorImage,
TileAnchor anchorScreen,
java.awt.Shape clip)
Draw a tile image on screen.
|
private void |
drawInViewArea(java.awt.Graphics2D g,
MapView mv,
ProjectionBounds pb) |
protected int |
estimateTileCacheSize() |
void |
filterChanged()
Invoked when the filter is changed.
|
protected javax.swing.Action |
getAdjustAction() |
private static TileAnchor |
getAnchor(Tile tile,
java.awt.image.BufferedImage image) |
int |
getBestZoom()
Returns best zoom level.
|
javax.swing.Action[] |
getCommonEntries()
Returns the common menu entries.
|
TileSourceDisplaySettings |
getDisplaySettings()
Gets the
TileSourceDisplaySettings instance associated with this tile source. |
AbstractTileSourceLayer.PrecacheTask |
getDownloadAreaToCacheTask(ProgressMonitor progressMonitor,
java.util.List<LatLon> points,
double bufferX,
double bufferY)
Calculates tiles, that needs to be downloaded to cache, gets a current tile loader and creates a task to download
all of the tiles.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getHeaders(T tileSource) |
java.lang.Object |
getInfoComponent()
Gets the layer information to display to the user.
|
javax.swing.Action[] |
getLayerListEntries()
Returns the contextual menu entries in layer list dialog.
|
private java.awt.image.BufferedImage |
getLoadedTileImage(Tile tile)
Returns the image for the given tile image is loaded.
|
protected int |
getMaxZoomLvl() |
static int |
getMaxZoomLvl(TileSource ts) |
private java.util.List<javax.swing.Action> |
getMenuAdditions()
Prepare list of additional layer context menu entries.
|
javax.swing.Action[] |
getMenuEntries()
Returns list of actions.
|
protected int |
getMinZoomLvl() |
static int |
getMinZoomLvl(TileSource ts) |
abstract java.util.Collection<java.lang.String> |
getNativeProjections()
Get projections this imagery layer supports natively.
|
protected java.util.List<ImageryLayer.OffsetMenuEntry> |
getOffsetMenuEntries() |
private Tile |
getOrCreateTile(int x,
int y,
int zoom) |
private Tile |
getOrCreateTile(TilePosition tilePosition) |
double |
getScaleFactor(int zoom)
Returns average number of screen pixels per tile pixel for current mapview
|
private ICoordinate |
getShiftedCoord(EastNorth en) |
private LatLon |
getShiftedLatLon(EastNorth en) |
private Tile |
getTile(int x,
int y,
int zoom)
Returns tile at given position.
|
private Tile |
getTile(TilePosition tilePosition) |
private Tile |
getTileForPixelpos(int px,
int py)
Returns tile for a pixel position.
|
protected abstract TileLoaderFactory |
getTileLoaderFactory() |
protected AbstractTileSourceLayer.TileSet |
getTileSet(ProjectionBounds bounds,
int zoom)
Create a TileSet by EastNorth bbox taking a layer shift in account
|
protected abstract T |
getTileSource()
Creates and returns a new
TileSource instance depending on ImageryLayer.info specified in the constructor. |
java.lang.String |
getToolTipText() |
private AbstractTileSourceLayer.TileSet |
getVisibleTileSet() |
int |
getZoomLevel()
Get the current zoom level of the layer
|
void |
hookUpMapView()
Creates popup menu items and binds to mouse actions
|
private boolean |
imageLoaded(java.awt.Image i) |
boolean |
imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height) |
boolean |
increaseZoomLevel()
Zoom in, go closer to map.
|
private void |
initializeIfRequired() |
protected void |
initTileSource(T tileSource) |
private void |
invalidateLater()
Invalidate the layer at a time in the future so that the user still sees the interface responsive.
|
boolean |
isSavable()
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
|
void |
loadAllErrorTiles(boolean force)
Load all visible tiles in error.
|
void |
loadAllTiles(boolean force)
Load all visible tiles.
|
private boolean |
loadTile(Tile tile,
boolean force) |
private void |
myDrawString(java.awt.Graphics g,
java.lang.String text,
int x,
int y) |
void |
paint(java.awt.Graphics2D g,
MapView mv,
Bounds bounds)
Paint the dataset using the engine set.
|
private java.util.List<Tile> |
paintTileImages(java.awt.Graphics2D g,
AbstractTileSourceLayer.TileSet ts) |
private java.util.List<Tile> |
paintTileImages(java.awt.Graphics2D g,
AbstractTileSourceLayer.TileSet ts,
int zoom,
Tile border) |
private void |
paintTileText(Tile tile,
java.awt.Graphics2D g) |
void |
projectionChanged(Projection oldValue,
Projection newValue) |
static void |
registerMenuAddition(javax.swing.Action addition)
Register an additional layer context menu entry.
|
static void |
registerMenuAddition(javax.swing.Action addition,
java.lang.Class<? extends AbstractTileSourceLayer<?>> clazz)
Register an additional layer context menu entry for a imagery layer
class.
|
private static void |
sendOsmTileRequest(Tile tile,
java.lang.String request) |
static void |
setMaxZoomLvl(int maxZoomLvl)
Sets maximum zoom level, that layer will attempt show
|
static void |
setMinZoomLvl(int minZoomLvl)
Sets minimum zoom level, that layer will attempt show
|
boolean |
setZoomLevel(int zoom)
Sets the zoom level of the layer
|
private boolean |
setZoomLevel(int zoom,
boolean invalidate) |
void |
tileLoadingFinished(Tile tile,
boolean success)
Will be called if a new
Tile has been loaded successfully. |
void |
visitBoundingBox(BoundingXYVisitor v)
Visits the content bounds of this layer.
|
void |
zoomChanged()
This fires every time the user changes the zoom, but also (due to ZoomChangeListener) - on all
changes to visible map (panning/zooming)
|
private void |
zoomChanged(boolean invalidate) |
boolean |
zoomDecreaseAllowed()
Check if zooming out is allowed
|
boolean |
zoomIncreaseAllowed() |
addImageProcessor, applyImageProcessors, create, createImageProcessor, createTextField, getChangesetSourceTag, getFilterSettings, getIcon, getImageProcessors, getInfo, getOffsetMenuItem, getOffsetMenuItem, getPPD, isMergable, mergeFrom, removeImageProcessor, toString
addPropertyChangeListener, checkSaveConditions, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getBaseColorProperty, getColorProperty, getDefaultLayerPosition, getName, getOpacity, getViewProjectionBounds, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible
addInvalidationListener, invalidate, removeInvalidationListener
private static final java.lang.String PREFERENCE_PREFIX
public static final int MAX_ZOOM
public static final int MIN_ZOOM
private static final java.awt.Font InfoFont
private static java.util.List<AbstractTileSourceLayer.MenuAddition> menuAdditions
public static final IntegerProperty PROP_MIN_ZOOM_LVL
public static final IntegerProperty PROP_MAX_ZOOM_LVL
private int currentZoomLevel
private final AttributionSupport attribution
public static final IntegerProperty ZOOM_OFFSET
protected T extends AbstractTMSTileSource tileSource
protected TileLoader tileLoader
private final javax.swing.Timer invalidateLaterTimer
private final java.awt.event.MouseAdapter adapter
private final TileSourceDisplaySettings displaySettings
private final ImageryAdjustAction adjustAction
protected TileCoordinateConverter coordinateConverter
private final long minimumTileExpire
private final AbstractTileSourceLayer.TileSet nullTileSet
public AbstractTileSourceLayer(ImageryInfo info)
info
- imagery infoprotected TileSourceDisplaySettings createDisplaySettings()
TileSourceDisplaySettings
object. Subclasses may implement it to e.g. change the prefix.public TileSourceDisplaySettings getDisplaySettings()
TileSourceDisplaySettings
instance associated with this tile source.public void filterChanged()
ImageryFilterSettings.FilterChangeListener
filterChanged
in interface ImageryFilterSettings.FilterChangeListener
protected abstract TileLoaderFactory getTileLoaderFactory()
public abstract java.util.Collection<java.lang.String> getNativeProjections()
protected abstract T getTileSource()
TileSource
instance depending on ImageryLayer.info
specified in the constructor.java.lang.IllegalArgumentException
- when Imagery is not supported by layerprotected java.util.Map<java.lang.String,java.lang.String> getHeaders(T tileSource)
protected void initTileSource(T tileSource)
public void tileLoadingFinished(Tile tile, boolean success)
TileLoaderListener
Tile
has been loaded successfully.
Loaded can mean downloaded or loaded from file cache.tileLoadingFinished
in interface TileLoaderListener
tile
- The tilesuccess
- true
if the tile has been loaded successfully, false
otherwisepublic void clearTileCache()
public java.lang.Object getInfoComponent()
Layer
getInfoComponent
in class ImageryLayer
Component
describing the layer.protected javax.swing.Action getAdjustAction()
getAdjustAction
in class ImageryLayer
public double getScaleFactor(int zoom)
zoom
- zoom levelpublic int getBestZoom()
public static boolean actionSupportLayers(java.util.List<Layer> layers)
Layer.LayerAction.supportLayers(List)
.layers
- layerstrue
is layers contains only a TMSLayer
private static void sendOsmTileRequest(Tile tile, java.lang.String request)
public void hookUpMapView()
hookUpMapView
in class Layer
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
AbstractMapViewPaintable
You need to return a painter here.
The MapViewPaintable.LayerPainter.detachFromMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)
method is called when the layer is removed
from that map view. You are free to reuse painters.
You should always call the super method. See AbstractMapViewPaintable.createMapViewPainter(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)
if you want to influence painter creation.
This replaces Layer.hookUpMapView()
in the long run.
attachToMapView
in class AbstractMapViewPaintable
event
- the event.private void initializeIfRequired()
protected MapViewPaintable.LayerPainter createMapViewPainter(MapViewPaintable.MapViewEvent event)
AbstractMapViewPaintable
createMapViewPainter
in class AbstractMapViewPaintable
event
- The event that triggered the creation.protected int estimateTileCacheSize()
public void displaySettingsChanged(TileSourceDisplaySettings.DisplaySettingsChangeEvent e)
TileSourceDisplaySettings.DisplaySettingsChangeListener
displaySettingsChanged
in interface TileSourceDisplaySettings.DisplaySettingsChangeListener
e
- The change event.public static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts)
maxZoomLvl
- zoom level to checkts
- tile source to crosscheck withpublic static int checkMinZoomLvl(int minZoomLvl, TileSource ts)
minZoomLvl
- zoom level to checkts
- tile source to crosscheck withpublic static int getMaxZoomLvl(TileSource ts)
ts
- TileSource for which we want to know maximum zoom levelpublic static int getMinZoomLvl(TileSource ts)
ts
- TileSource for which we want to know minimum zoom levelpublic static void setMaxZoomLvl(int maxZoomLvl)
maxZoomLvl
- maximum zoom levelpublic static void setMinZoomLvl(int minZoomLvl)
minZoomLvl
- minimum zoom levelpublic void zoomChanged()
zoomChanged
in interface NavigatableComponent.ZoomChangeListener
private void zoomChanged(boolean invalidate)
protected int getMaxZoomLvl()
protected int getMinZoomLvl()
public boolean zoomIncreaseAllowed()
public boolean increaseZoomLevel()
public int getZoomLevel()
public boolean setZoomLevel(int zoom)
zoom
- zoom levelprivate boolean setZoomLevel(int zoom, boolean invalidate)
public boolean zoomDecreaseAllowed()
public boolean decreaseZoomLevel()
private Tile getOrCreateTile(TilePosition tilePosition)
private Tile getOrCreateTile(int x, int y, int zoom)
private Tile getTile(TilePosition tilePosition)
private Tile getTile(int x, int y, int zoom)
x
- tile number on the x axis of the tile to be retrievedy
- tile number on the y axis of the tile to be retrievedzoom
- zoom level of the tile to be retrievedprivate AbstractTileSourceLayer.TileSet getVisibleTileSet()
public void loadAllTiles(boolean force)
force
- true
to force loading if auto-load is disabledpublic void loadAllErrorTiles(boolean force)
force
- true
to force loading if auto-load is disabledpublic boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
imageUpdate
in interface java.awt.image.ImageObserver
private void invalidateLater()
private boolean imageLoaded(java.awt.Image i)
private java.awt.image.BufferedImage getLoadedTileImage(Tile tile)
tile
- the Tile for which the image should be returnedprivate void drawImageInside(java.awt.Graphics2D g, java.awt.image.BufferedImage toDrawImg, TileAnchor anchorImage, TileAnchor anchorScreen, java.awt.Shape clip)
g
- the Graphics2DtoDrawImg
- tile imageanchorImage
- tile anchor in image coordinatesanchorScreen
- tile anchor in screen coordinatesclip
- clipping region in screen coordinates (can be null)private java.util.List<Tile> paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts)
private java.util.List<Tile> paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts, int zoom, Tile border)
private static TileAnchor getAnchor(Tile tile, java.awt.image.BufferedImage image)
private void myDrawString(java.awt.Graphics g, java.lang.String text, int x, int y)
private void paintTileText(Tile tile, java.awt.Graphics2D g)
private LatLon getShiftedLatLon(EastNorth en)
private ICoordinate getShiftedCoord(EastNorth en)
protected AbstractTileSourceLayer.TileSet getTileSet(ProjectionBounds bounds, int zoom)
bounds
- the EastNorth boundszoom
- zoom levelpublic void paint(java.awt.Graphics2D g, MapView mv, Bounds bounds)
MapViewPaintable
paint
in interface MapViewPaintable
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.bounds
- Bounding boxprivate void drawInViewArea(java.awt.Graphics2D g, MapView mv, ProjectionBounds pb)
private Tile getTileForPixelpos(int px, int py)
This isn't very efficient, but it is only used when the user right-clicks on the map.
px
- pixel X coordinatepy
- pixel Y coordinatepublic static void registerMenuAddition(javax.swing.Action addition)
addition
- additional menu actionpublic static void registerMenuAddition(javax.swing.Action addition, java.lang.Class<? extends AbstractTileSourceLayer<?>> clazz)
Example:
TMSLayer.registerMenuAddition(new TMSSpecificAction(), TMSLayer.class);
addition
- additional menu actionclazz
- class the menu action is registered forprivate java.util.List<javax.swing.Action> getMenuAdditions()
public javax.swing.Action[] getMenuEntries()
Layer
Layer.SeparatorLayerAction.INSTANCE
instead of new JSeparatorgetMenuEntries
in class Layer
public javax.swing.Action[] getLayerListEntries()
public javax.swing.Action[] getCommonEntries()
public java.lang.String getToolTipText()
getToolTipText
in class Layer
public void visitBoundingBox(BoundingXYVisitor v)
Layer
visitBoundingBox
in class Layer
v
- The visitor that gets notified about the contents of this layer.public AbstractTileSourceLayer.PrecacheTask getDownloadAreaToCacheTask(ProgressMonitor progressMonitor, java.util.List<LatLon> points, double bufferX, double bufferY)
progressMonitor
- progress monitor for download taskpoints
- lat/lon coordinates to downloadbufferX
- how many units in current Coordinate Reference System to cover in X axis in both sidesbufferY
- how many units in current Coordinate Reference System to cover in Y axis in both sidespublic boolean isSavable()
Layer
public java.io.File createAndOpenSaveFileChooser()
Layer
createAndOpenSaveFileChooser
in class Layer
File
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
public void destroy()
Layer
destroy
in interface Destroyable
destroy
in class Layer
public void projectionChanged(Projection oldValue, Projection newValue)
projectionChanged
in interface ProjectionChangeListener
projectionChanged
in class Layer
protected java.util.List<ImageryLayer.OffsetMenuEntry> getOffsetMenuEntries()
getOffsetMenuEntries
in class ImageryLayer