Class AbstractTileSourceLayer<T extends org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource>
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
-
- org.openstreetmap.josm.gui.layer.Layer
-
- org.openstreetmap.josm.gui.layer.ImageryLayer
-
- org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer<T>
-
- Type Parameters:
T
- Tile Source class used for this layer
- All Implemented Interfaces:
java.awt.image.ImageObserver
,org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener
,ProjectionChangeListener
,ImageryFilterSettings.FilterChangeListener
,TileSourceDisplaySettings.DisplaySettingsChangeListener
,MapViewPaintable
,NavigatableComponent.ZoomChangeListener
,Destroyable
- Direct Known Subclasses:
AbstractCachedTileSourceLayer
public abstract class AbstractTileSourceLayer<T extends org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource> extends ImageryLayer implements java.awt.image.ImageObserver, org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener, NavigatableComponent.ZoomChangeListener, ImageryFilterSettings.FilterChangeListener, TileSourceDisplaySettings.DisplaySettingsChangeListener
Base abstract class that supports displaying images provided by TileSource. It might be TMS source, WMS or WMTS It implements all standard functions of tilesource based layers: autozoom, tile reloads, layer saving, loading,etc.- Since:
- 3715, 8526 (copied from TMSLayer)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 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 trackprivate static class
AbstractTileSourceLayer.ShowTileInfoAction
protected class
AbstractTileSourceLayer.TileSet
private static class
AbstractTileSourceLayer.TileSetInfo
Data container to hold information about aTileSet
class.class
AbstractTileSourceLayer.TileSourceLayerPopup
Tile source layer popup menu.private class
AbstractTileSourceLayer.TileSourcePainter
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.ImageryLayer
ImageryLayer.OffsetAction, ImageryLayer.OffsetMenuEntry
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.Layer
Layer.LayerAction, Layer.LayerGpxExportAction, Layer.LayerSaveAction, Layer.LayerSaveAsAction, Layer.MultiLayerAction, Layer.SeparatorLayerAction
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
AbstractMapViewPaintable.CompatibilityModeLayerPainter
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.event.MouseAdapter
adapter
private ImageryAdjustAction
adjustAction
private org.openstreetmap.gui.jmapviewer.AttributionSupport
attribution
protected TileCoordinateConverter
coordinateConverter
private int
currentZoomLevel
Zoomlevel at which tiles is currently downloaded.private TileSourceDisplaySettings
displaySettings
private static java.lang.String
ERROR_STRING
private static java.awt.Font
InfoFont
private javax.swing.Timer
invalidateLaterTimer
A timer that is used to delay invalidation events if required.private static int
MAX_TILES_SPANNED
static int
MAX_ZOOM
maximum zoom level supportedprivate static java.util.List<AbstractTileSourceLayer.MenuAddition>
menuAdditions
additional layer menu actionsstatic int
MIN_ZOOM
minimum zoom level supportedprivate long
minimumTileExpire
private AbstractTileSourceLayer.TileSet
nullTileSet
private static BooleanProperty
POPUP_MENU_ENABLED
private static java.lang.String
PREFERENCE_PREFIX
static IntegerProperty
PROP_MAX_ZOOM_LVL
maximum zoom level to show to userstatic IntegerProperty
PROP_MIN_ZOOM_LVL
minimum zoom level to show to userprotected org.openstreetmap.gui.jmapviewer.interfaces.TileCache
tileCache
protected org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
tileLoader
protected T
tileSource
static IntegerProperty
ZOOM_OFFSET
Offset between calculated zoom level and zoom level used to download and show tiles.-
Fields inherited from class org.openstreetmap.josm.gui.layer.ImageryLayer
icon, info, PROP_SHARPEN_LEVEL
-
Fields inherited from class org.openstreetmap.josm.gui.layer.Layer
FILTER_STATE_PROP, NAME_PROP, OPACITY_PROP, propertyChangeSupport, VISIBLE_PROP
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTileSourceLayer(ImageryInfo info)
Creates Tile Source based Imagery Layer based on Imagery Info
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static boolean
actionSupportLayers(java.util.List<Layer> layers)
Default implementation ofLayer.LayerAction.supportLayers(List)
.MapViewPaintable.LayerPainter
attachToMapView(MapViewPaintable.MapViewEvent event)
This method is called whenever this layer is added to a map view.private static int
calculateRealTiles(int visibleTiles, int maxXtiles, int maxYtiles)
Take into account ZOOM_OFFSET to calculate real number of tiles and multiply by 7, to cover all tiles, that might be accessed when looking for tiles outside current zoom level.static int
checkMaxZoomLvl(int maxZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Checks zoom level against settingsstatic int
checkMinZoomLvl(int minZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Checks zoom level against settingsvoid
clearErrorTiles()
Remove all cached error tilesvoid
clearTileCache()
Clears the tile cache.java.io.File
createAndOpenSaveFileChooser()
Creates a new "Save" dialog for this layer and makes it visible.protected TileSourceDisplaySettings
createDisplaySettings()
This method creates theTileSourceDisplaySettings
object.protected MapViewPaintable.LayerPainter
createMapViewPainter(MapViewPaintable.MapViewEvent event)
Creates a new LayerPainter.org.openstreetmap.gui.jmapviewer.Tile
createTile(T source, int x, int y, int zoom)
Create a new tile.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(org.openstreetmap.gui.jmapviewer.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 theTileSourceDisplaySettings
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(org.openstreetmap.gui.jmapviewer.Tile tile)
Returns the image for the given tile image is loaded.protected int
getMaxZoomLvl()
static int
getMaxZoomLvl(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Returns maximum max zoom level, that will be shown on layer.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(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Returns minimum zoom level, that will be shown on layer.abstract java.util.Collection<java.lang.String>
getNativeProjections()
Get projections this imagery layer supports natively.protected java.util.List<ImageryLayer.OffsetMenuEntry>
getOffsetMenuEntries()
private org.openstreetmap.gui.jmapviewer.Tile
getOrCreateTile(int x, int y, int zoom)
private org.openstreetmap.gui.jmapviewer.Tile
getOrCreateTile(TilePosition tilePosition)
double
getScaleFactor(int zoom)
Returns average number of screen pixels per tile pixel for current mapviewprivate org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate
getShiftedCoord(EastNorth en)
private LatLon
getShiftedLatLon(EastNorth en)
private org.openstreetmap.gui.jmapviewer.Tile
getTile(int x, int y, int zoom)
Returns tile at given position.private org.openstreetmap.gui.jmapviewer.Tile
getTile(TilePosition tilePosition)
private org.openstreetmap.gui.jmapviewer.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 accountprotected abstract T
getTileSource()
Creates and returns a newTileSource
instance depending onImageryLayer.info
specified in the constructor.java.lang.String
getToolTipText()
Returns a small tooltip hint about some statistics for this layer.private AbstractTileSourceLayer.TileSet
getVisibleTileSet()
int
getZoomLevel()
Get the current zoom level of the layervoid
hookUpMapView()
Creates popup menu items and binds to mouse actionsprivate 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(org.openstreetmap.gui.jmapviewer.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<org.openstreetmap.gui.jmapviewer.Tile>
paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts)
private java.util.List<org.openstreetmap.gui.jmapviewer.Tile>
paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts, int zoom, org.openstreetmap.gui.jmapviewer.Tile border)
private void
paintTileText(org.openstreetmap.gui.jmapviewer.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(org.openstreetmap.gui.jmapviewer.Tile tile, java.lang.String request)
static void
setMaxZoomLvl(int maxZoomLvl)
Sets maximum zoom level, that layer will attempt showstatic void
setMinZoomLvl(int minZoomLvl)
Sets minimum zoom level, that layer will attempt showboolean
setZoomLevel(int zoom)
Sets the zoom level of the layerprivate boolean
setZoomLevel(int zoom, boolean invalidate)
void
tileLoadingFinished(org.openstreetmap.gui.jmapviewer.Tile tile, boolean success)
private java.util.List<org.openstreetmap.gui.jmapviewer.Tile>
tryLoadFromDifferentZoom(java.awt.Graphics2D g, int displayZoomLevel, java.util.List<org.openstreetmap.gui.jmapviewer.Tile> missedTiles, int zoomOffset)
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 allowedboolean
zoomIncreaseAllowed()
Determines if it is allowed to zoom in.-
Methods inherited from class org.openstreetmap.josm.gui.layer.ImageryLayer
addImageProcessor, applyImageProcessors, create, createImageProcessor, createTextField, getChangesetSourceTag, getFilterSettings, getIcon, getImageProcessors, getInfo, getOffsetMenuItem, getOffsetMenuItem, getPPD, isMergable, mergeFrom, removeImageProcessor, toString
-
Methods inherited from class org.openstreetmap.josm.gui.layer.Layer
addPropertyChangeListener, checkSaveConditions, fireFilterStateChanged, fireOpacityChanged, fireVisibleChanged, getAssociatedFile, getColor, getDefaultLayerPosition, getLabel, getName, getOpacity, getViewProjectionBounds, hasColor, isBackgroundLayer, isInfoResizable, isProjectionSupported, isRenamed, isVisible, nameSupportedProjections, onPostLoadFromFile, removePropertyChangeListener, rename, setAssociatedFile, setBackgroundLayer, setColor, setFilterStateChanged, setName, setOpacity, setVisible, toggleVisible
-
Methods inherited from class org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
addInvalidationListener, invalidate, removeInvalidationListener
-
-
-
-
Field Detail
-
PREFERENCE_PREFIX
private static final java.lang.String PREFERENCE_PREFIX
- See Also:
- Constant Field Values
-
MAX_TILES_SPANNED
private static final int MAX_TILES_SPANNED
- See Also:
- Constant Field Values
-
MAX_ZOOM
public static final int MAX_ZOOM
maximum zoom level supported- See Also:
- Constant Field Values
-
MIN_ZOOM
public static final int MIN_ZOOM
minimum zoom level supported- See Also:
- Constant Field Values
-
InfoFont
private static final java.awt.Font InfoFont
-
menuAdditions
private static final java.util.List<AbstractTileSourceLayer.MenuAddition> menuAdditions
additional layer menu actions
-
PROP_MIN_ZOOM_LVL
public static final IntegerProperty PROP_MIN_ZOOM_LVL
minimum zoom level to show to user
-
PROP_MAX_ZOOM_LVL
public static final IntegerProperty PROP_MAX_ZOOM_LVL
maximum zoom level to show to user
-
currentZoomLevel
private int currentZoomLevel
Zoomlevel at which tiles is currently downloaded. Initial zoom lvl is set to bestZoom
-
attribution
private final org.openstreetmap.gui.jmapviewer.AttributionSupport attribution
-
ZOOM_OFFSET
public static final IntegerProperty ZOOM_OFFSET
Offset between calculated zoom level and zoom level used to download and show tiles. Negative values will result in lower resolution of imagery useful in "retina" displays, positive values will result in higher resolution
-
POPUP_MENU_ENABLED
private static final BooleanProperty POPUP_MENU_ENABLED
-
ERROR_STRING
private static final java.lang.String ERROR_STRING
-
tileCache
protected org.openstreetmap.gui.jmapviewer.interfaces.TileCache tileCache
-
tileSource
protected T extends org.openstreetmap.gui.jmapviewer.tilesources.AbstractTMSTileSource tileSource
-
tileLoader
protected org.openstreetmap.gui.jmapviewer.interfaces.TileLoader tileLoader
-
invalidateLaterTimer
private final javax.swing.Timer invalidateLaterTimer
A timer that is used to delay invalidation events if required.
-
adapter
private final java.awt.event.MouseAdapter adapter
-
displaySettings
private final TileSourceDisplaySettings displaySettings
-
adjustAction
private final ImageryAdjustAction adjustAction
-
coordinateConverter
protected TileCoordinateConverter coordinateConverter
-
minimumTileExpire
private final long minimumTileExpire
-
nullTileSet
private final AbstractTileSourceLayer.TileSet nullTileSet
-
-
Constructor Detail
-
AbstractTileSourceLayer
protected AbstractTileSourceLayer(ImageryInfo info)
Creates Tile Source based Imagery Layer based on Imagery Info- Parameters:
info
- imagery info
-
-
Method Detail
-
createDisplaySettings
protected TileSourceDisplaySettings createDisplaySettings()
This method creates theTileSourceDisplaySettings
object. Subclasses may implement it to e.g. change the prefix.- Returns:
- The object.
- Since:
- 10568
-
getDisplaySettings
public TileSourceDisplaySettings getDisplaySettings()
Gets theTileSourceDisplaySettings
instance associated with this tile source.- Returns:
- The tile source display settings
- Since:
- 10568
-
filterChanged
public void filterChanged()
Description copied from interface:ImageryFilterSettings.FilterChangeListener
Invoked when the filter is changed.- Specified by:
filterChanged
in interfaceImageryFilterSettings.FilterChangeListener
-
getTileLoaderFactory
protected abstract TileLoaderFactory getTileLoaderFactory()
-
getNativeProjections
public abstract java.util.Collection<java.lang.String> getNativeProjections()
Get projections this imagery layer supports natively. For example projection of tiles that are downloaded from a server. Layer may support even more projections (by reprojecting the tiles), but with a certain loss in image quality and performance.- Returns:
- projections this imagery layer supports natively; null if layer is projection agnostic.
-
getTileSource
protected abstract T getTileSource()
Creates and returns a newTileSource
instance depending onImageryLayer.info
specified in the constructor.- Returns:
- TileSource for specified ImageryInfo
- Throws:
java.lang.IllegalArgumentException
- when Imagery is not supported by layer
-
getHeaders
protected java.util.Map<java.lang.String,java.lang.String> getHeaders(T tileSource)
-
initTileSource
protected void initTileSource(T tileSource)
-
tileLoadingFinished
public void tileLoadingFinished(org.openstreetmap.gui.jmapviewer.Tile tile, boolean success)
- Specified by:
tileLoadingFinished
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener
-
clearTileCache
public void clearTileCache()
Clears the tile cache.
-
getInfoComponent
public java.lang.Object getInfoComponent()
Description copied from class:Layer
Gets the layer information to display to the user. This is used if the user requests information about this layer. It should display a description of the layer content.- Overrides:
getInfoComponent
in classImageryLayer
- Returns:
- Either a String or a
Component
describing the layer.
-
getAdjustAction
protected javax.swing.Action getAdjustAction()
- Specified by:
getAdjustAction
in classImageryLayer
-
getScaleFactor
public double getScaleFactor(int zoom)
Returns average number of screen pixels per tile pixel for current mapview- Parameters:
zoom
- zoom level- Returns:
- average number of screen pixels per tile pixel
-
getBestZoom
public int getBestZoom()
Returns best zoom level.- Returns:
- best zoom level
-
actionSupportLayers
public static boolean actionSupportLayers(java.util.List<Layer> layers)
Default implementation ofLayer.LayerAction.supportLayers(List)
.- Parameters:
layers
- layers- Returns:
true
is layers contains only aTMSLayer
-
sendOsmTileRequest
private static void sendOsmTileRequest(org.openstreetmap.gui.jmapviewer.Tile tile, java.lang.String request)
-
hookUpMapView
public void hookUpMapView()
Creates popup menu items and binds to mouse actions- Overrides:
hookUpMapView
in classLayer
-
attachToMapView
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
Description copied from class:AbstractMapViewPaintable
This method is called whenever this layer is added to a map view.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.- Overrides:
attachToMapView
in classAbstractMapViewPaintable
- Parameters:
event
- the event.- Returns:
- A layer painter.
-
initializeIfRequired
private void initializeIfRequired()
-
createMapViewPainter
protected MapViewPaintable.LayerPainter createMapViewPainter(MapViewPaintable.MapViewEvent event)
Description copied from class:AbstractMapViewPaintable
Creates a new LayerPainter.- Overrides:
createMapViewPainter
in classAbstractMapViewPaintable
- Parameters:
event
- The event that triggered the creation.- Returns:
- The painter.
-
estimateTileCacheSize
protected int estimateTileCacheSize()
-
calculateRealTiles
private static int calculateRealTiles(int visibleTiles, int maxXtiles, int maxYtiles)
Take into account ZOOM_OFFSET to calculate real number of tiles and multiply by 7, to cover all tiles, that might be accessed when looking for tiles outside current zoom level.Currently we use otherZooms = {1, 2, -1, -2, -3, -4, -5}
The value should be sum(2^x for x in (-5 to 2)) - 1 -1 to exclude current zoom level
Add +2 to maxYtiles / maxXtiles to add space in cache for extra tiles in current zoom level that are download by overloadTiles(). This is not added in computation of visibleTiles as this unnecessarily grow the cache size
Check call to tryLoadFromDifferentZoom
-
displaySettingsChanged
public void displaySettingsChanged(TileSourceDisplaySettings.DisplaySettingsChangeEvent e)
Description copied from interface:TileSourceDisplaySettings.DisplaySettingsChangeListener
Called whenever the display settings have changed.- Specified by:
displaySettingsChanged
in interfaceTileSourceDisplaySettings.DisplaySettingsChangeListener
- Parameters:
e
- The change event.
-
checkMaxZoomLvl
public static int checkMaxZoomLvl(int maxZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Checks zoom level against settings- Parameters:
maxZoomLvl
- zoom level to checkts
- tile source to crosscheck with- Returns:
- maximum zoom level, not higher than supported by tilesource nor set by the user
-
checkMinZoomLvl
public static int checkMinZoomLvl(int minZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Checks zoom level against settings- Parameters:
minZoomLvl
- zoom level to checkts
- tile source to crosscheck with- Returns:
- minimum zoom level, not higher than supported by tilesource nor set by the user
-
getMaxZoomLvl
public static int getMaxZoomLvl(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Returns maximum max zoom level, that will be shown on layer.- Parameters:
ts
- TileSource for which we want to know maximum zoom level- Returns:
- maximum max zoom level, that will be shown on layer
-
getMinZoomLvl
public static int getMinZoomLvl(org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)
Returns minimum zoom level, that will be shown on layer.- Parameters:
ts
- TileSource for which we want to know minimum zoom level- Returns:
- minimum zoom level, that will be shown on layer
-
setMaxZoomLvl
public static void setMaxZoomLvl(int maxZoomLvl)
Sets maximum zoom level, that layer will attempt show- Parameters:
maxZoomLvl
- maximum zoom level
-
setMinZoomLvl
public static void setMinZoomLvl(int minZoomLvl)
Sets minimum zoom level, that layer will attempt show- Parameters:
minZoomLvl
- minimum zoom level
-
zoomChanged
public void zoomChanged()
This fires every time the user changes the zoom, but also (due to ZoomChangeListener) - on all changes to visible map (panning/zooming)- Specified by:
zoomChanged
in interfaceNavigatableComponent.ZoomChangeListener
-
zoomChanged
private void zoomChanged(boolean invalidate)
-
getMaxZoomLvl
protected int getMaxZoomLvl()
-
getMinZoomLvl
protected int getMinZoomLvl()
-
zoomIncreaseAllowed
public boolean zoomIncreaseAllowed()
Determines if it is allowed to zoom in.- Returns:
- if it is allowed to zoom in
-
increaseZoomLevel
public boolean increaseZoomLevel()
Zoom in, go closer to map.- Returns:
- true, if zoom increasing was successful, false otherwise
-
getZoomLevel
public int getZoomLevel()
Get the current zoom level of the layer- Returns:
- the current zoom level
- Since:
- 12603
-
setZoomLevel
public boolean setZoomLevel(int zoom)
Sets the zoom level of the layer- Parameters:
zoom
- zoom level- Returns:
- true, when zoom has changed to desired value, false if it was outside supported zoom levels
-
setZoomLevel
private boolean setZoomLevel(int zoom, boolean invalidate)
-
zoomDecreaseAllowed
public boolean zoomDecreaseAllowed()
Check if zooming out is allowed- Returns:
- true, if zooming out is allowed (currentZoomLevel > minZoomLevel)
-
decreaseZoomLevel
public boolean decreaseZoomLevel()
Zoom out from map.- Returns:
- true, if zoom increasing was successful, false otherwise
-
getOrCreateTile
private org.openstreetmap.gui.jmapviewer.Tile getOrCreateTile(TilePosition tilePosition)
-
getOrCreateTile
private org.openstreetmap.gui.jmapviewer.Tile getOrCreateTile(int x, int y, int zoom)
-
getTile
private org.openstreetmap.gui.jmapviewer.Tile getTile(TilePosition tilePosition)
-
getTile
private org.openstreetmap.gui.jmapviewer.Tile getTile(int x, int y, int zoom)
Returns tile at given position. This can and will return null for tiles that are not already in the cache.- Parameters:
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 retrieved- Returns:
- tile at given position
-
loadTile
private boolean loadTile(org.openstreetmap.gui.jmapviewer.Tile tile, boolean force)
-
getVisibleTileSet
private AbstractTileSourceLayer.TileSet getVisibleTileSet()
-
loadAllTiles
public void loadAllTiles(boolean force)
Load all visible tiles.- Parameters:
force
-true
to force loading if auto-load is disabled- Since:
- 11950
-
loadAllErrorTiles
public void loadAllErrorTiles(boolean force)
Load all visible tiles in error.- Parameters:
force
-true
to force loading if auto-load is disabled- Since:
- 11950
-
clearErrorTiles
public void clearErrorTiles()
Remove all cached error tiles- Since:
- 19192
-
imageUpdate
public boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
- Specified by:
imageUpdate
in interfacejava.awt.image.ImageObserver
-
invalidateLater
private void invalidateLater()
Invalidate the layer at a time in the future so that the user still sees the interface responsive.
-
imageLoaded
private boolean imageLoaded(java.awt.Image i)
-
getLoadedTileImage
private java.awt.image.BufferedImage getLoadedTileImage(org.openstreetmap.gui.jmapviewer.Tile tile)
Returns the image for the given tile image is loaded. Otherwise returns null.- Parameters:
tile
- the Tile for which the image should be returned- Returns:
- the image of the tile or null.
-
drawImageInside
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.- Parameters:
g
- the Graphics2DtoDrawImg
- tile imageanchorImage
- tile anchor in image coordinatesanchorScreen
- tile anchor in screen coordinatesclip
- clipping region in screen coordinates (can be null)
-
paintTileImages
private java.util.List<org.openstreetmap.gui.jmapviewer.Tile> paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts)
-
paintTileImages
private java.util.List<org.openstreetmap.gui.jmapviewer.Tile> paintTileImages(java.awt.Graphics2D g, AbstractTileSourceLayer.TileSet ts, int zoom, org.openstreetmap.gui.jmapviewer.Tile border)
-
getAnchor
private static TileAnchor getAnchor(org.openstreetmap.gui.jmapviewer.Tile tile, java.awt.image.BufferedImage image)
-
myDrawString
private void myDrawString(java.awt.Graphics g, java.lang.String text, int x, int y)
-
paintTileText
private void paintTileText(org.openstreetmap.gui.jmapviewer.Tile tile, java.awt.Graphics2D g)
-
getShiftedLatLon
private LatLon getShiftedLatLon(EastNorth en)
-
getShiftedCoord
private org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate getShiftedCoord(EastNorth en)
-
getTileSet
protected AbstractTileSourceLayer.TileSet getTileSet(ProjectionBounds bounds, int zoom)
Create a TileSet by EastNorth bbox taking a layer shift in account- Parameters:
bounds
- the EastNorth boundszoom
- zoom level- Returns:
- the tile set
-
paint
public void paint(java.awt.Graphics2D g, MapView mv, Bounds bounds)
Description copied from interface:MapViewPaintable
Paint the dataset using the engine set.- Specified by:
paint
in interfaceMapViewPaintable
- Parameters:
g
- Graphicsmv
- The object that can translate GeoPoints to screen coordinates.bounds
- Bounding box
-
drawInViewArea
private void drawInViewArea(java.awt.Graphics2D g, MapView mv, ProjectionBounds pb)
-
tryLoadFromDifferentZoom
private java.util.List<org.openstreetmap.gui.jmapviewer.Tile> tryLoadFromDifferentZoom(java.awt.Graphics2D g, int displayZoomLevel, java.util.List<org.openstreetmap.gui.jmapviewer.Tile> missedTiles, int zoomOffset)
-
getTileForPixelpos
private org.openstreetmap.gui.jmapviewer.Tile getTileForPixelpos(int px, int py)
Returns tile for a pixel position.This isn't very efficient, but it is only used when the user right-clicks on the map.
- Parameters:
px
- pixel X coordinatepy
- pixel Y coordinate- Returns:
- Tile at pixel position
-
registerMenuAddition
public static void registerMenuAddition(javax.swing.Action addition)
Register an additional layer context menu entry.- Parameters:
addition
- additional menu action- Since:
- 11197
-
registerMenuAddition
public 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. The menu entry is valid for the specified class and subclasses thereof only.Example:
TMSLayer.registerMenuAddition(new TMSSpecificAction(), TMSLayer.class);
- Parameters:
addition
- additional menu actionclazz
- class the menu action is registered for- Since:
- 11197
-
getMenuAdditions
private java.util.List<javax.swing.Action> getMenuAdditions()
Prepare list of additional layer context menu entries. The list is empty if there are no additional menu entries.- Returns:
- list of additional layer context menu entries
-
getMenuEntries
public javax.swing.Action[] getMenuEntries()
Description copied from class:Layer
Returns list of actions. Action can implement LayerAction interface when it needs to be represented by other menu component than JMenuItem or when it supports multiple layers. Actions that support multiple layers should also have correct equals implementation.Use
Layer.SeparatorLayerAction.INSTANCE
instead of new JSeparator- Specified by:
getMenuEntries
in classLayer
- Returns:
- menu actions for this layer
-
getLayerListEntries
public javax.swing.Action[] getLayerListEntries()
Returns the contextual menu entries in layer list dialog.- Returns:
- the contextual menu entries in layer list dialog
-
getCommonEntries
public javax.swing.Action[] getCommonEntries()
Returns the common menu entries.- Returns:
- the common menu entries
-
getToolTipText
public java.lang.String getToolTipText()
Description copied from class:Layer
Returns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipText
in classLayer
- Returns:
- A small tooltip hint about some statistics for this layer.
-
visitBoundingBox
public void visitBoundingBox(BoundingXYVisitor v)
Description copied from class:Layer
Visits the content bounds of this layer. The behavior of this method depends on the layer, but each implementation should attempt to cover the relevant content of the layer in this method.- Specified by:
visitBoundingBox
in classLayer
- Parameters:
v
- The visitor that gets notified about the contents of this layer.
-
getDownloadAreaToCacheTask
public 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. Buffer contains at least one tile.To prevent accidental clear of the queue, new download executor is created with separate queue
- Parameters:
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 sides- Returns:
- precache task representing download task
-
isSavable
public boolean isSavable()
Description copied from class:Layer
Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).
-
createAndOpenSaveFileChooser
public java.io.File createAndOpenSaveFileChooser()
Description copied from class:Layer
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 overwriting if needed.
- Overrides:
createAndOpenSaveFileChooser
in classLayer
- Returns:
- The output
File
- See Also:
SaveActionBase.createAndOpenSaveFileChooser(java.lang.String, org.openstreetmap.josm.actions.ExtensionFileFilter)
-
createTile
public org.openstreetmap.gui.jmapviewer.Tile createTile(T source, int x, int y, int zoom)
Create a new tile. Added to allow use of customTile
objects.- Parameters:
source
- Tile sourcex
- X coordinatey
- Y coordinatezoom
- Zoom level- Returns:
- The new
Tile
- Since:
- 17862
-
destroy
public void destroy()
Description copied from class:Layer
Called, when the layer is removed from the mapview and is going to be destroyed.This is because the Layer constructor cannot add itself safely as a listener to the layerlist dialog, because there may be no such dialog yet (loaded via command line parameter).
- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classLayer
-
projectionChanged
public void projectionChanged(Projection oldValue, Projection newValue)
- Specified by:
projectionChanged
in interfaceProjectionChangeListener
- Overrides:
projectionChanged
in classLayer
-
getOffsetMenuEntries
protected java.util.List<ImageryLayer.OffsetMenuEntry> getOffsetMenuEntries()
- Specified by:
getOffsetMenuEntries
in classImageryLayer
-
-