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 classAbstractTileSourceLayer.AbstractTileActionprivate classAbstractTileSourceLayer.DeepTileSetprivate static classAbstractTileSourceLayer.GetOsmTileStatusActionprivate static classAbstractTileSourceLayer.LoadTileActionprivate static classAbstractTileSourceLayer.MarkOsmTileDirtyActionprivate static classAbstractTileSourceLayer.MenuAdditionClass to store a menu action and the class it belongs to.private classAbstractTileSourceLayer.OffsetMenuBookmarkEntryAn entry for a bookmark in the offset menu.classAbstractTileSourceLayer.PrecacheTaskTask responsible for precaching imagery along the gpx trackprivate static classAbstractTileSourceLayer.ShowTileInfoActionprotected classAbstractTileSourceLayer.TileSetprivate static classAbstractTileSourceLayer.TileSetInfoData container to hold information about aTileSetclass.classAbstractTileSourceLayer.TileSourceLayerPopupTile source layer popup menu.private classAbstractTileSourceLayer.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.MouseAdapteradapterprivate ImageryAdjustActionadjustActionprivate org.openstreetmap.gui.jmapviewer.AttributionSupportattributionprotected TileCoordinateConvertercoordinateConverterprivate intcurrentZoomLevelZoomlevel at which tiles is currently downloaded.private TileSourceDisplaySettingsdisplaySettingsprivate static java.lang.StringERROR_STRINGprivate static java.awt.FontInfoFontprivate javax.swing.TimerinvalidateLaterTimerA timer that is used to delay invalidation events if required.private static intMAX_TILES_SPANNEDstatic intMAX_ZOOMmaximum zoom level supportedprivate static java.util.List<AbstractTileSourceLayer.MenuAddition>menuAdditionsadditional layer menu actionsstatic intMIN_ZOOMminimum zoom level supportedprivate longminimumTileExpireprivate AbstractTileSourceLayer.TileSetnullTileSetprivate static BooleanPropertyPOPUP_MENU_ENABLEDprivate static java.lang.StringPREFERENCE_PREFIXstatic IntegerPropertyPROP_MAX_ZOOM_LVLmaximum zoom level to show to userstatic IntegerPropertyPROP_MIN_ZOOM_LVLminimum zoom level to show to userprotected org.openstreetmap.gui.jmapviewer.interfaces.TileCachetileCacheprotected org.openstreetmap.gui.jmapviewer.interfaces.TileLoadertileLoaderprotected TtileSourcestatic IntegerPropertyZOOM_OFFSETOffset 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 protectedAbstractTileSourceLayer(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 booleanactionSupportLayers(java.util.List<Layer> layers)Default implementation ofLayer.LayerAction.supportLayers(List).MapViewPaintable.LayerPainterattachToMapView(MapViewPaintable.MapViewEvent event)This method is called whenever this layer is added to a map view.private static intcalculateRealTiles(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 intcheckMaxZoomLvl(int maxZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)Checks zoom level against settingsstatic intcheckMinZoomLvl(int minZoomLvl, org.openstreetmap.gui.jmapviewer.interfaces.TileSource ts)Checks zoom level against settingsvoidclearErrorTiles()Remove all cached error tilesvoidclearTileCache()Clears the tile cache.java.io.FilecreateAndOpenSaveFileChooser()Creates a new "Save" dialog for this layer and makes it visible.protected TileSourceDisplaySettingscreateDisplaySettings()This method creates theTileSourceDisplaySettingsobject.protected MapViewPaintable.LayerPaintercreateMapViewPainter(MapViewPaintable.MapViewEvent event)Creates a new LayerPainter.org.openstreetmap.gui.jmapviewer.TilecreateTile(T source, int x, int y, int zoom)Create a new tile.booleandecreaseZoomLevel()Zoom out from map.voiddestroy()Called, when the layer is removed from the mapview and is going to be destroyed.voiddisplaySettingsChanged(TileSourceDisplaySettings.DisplaySettingsChangeEvent e)Called whenever the display settings have changed.private voiddrawImageInside(java.awt.Graphics2D g, java.awt.image.BufferedImage toDrawImg, TileAnchor anchorImage, TileAnchor anchorScreen, java.awt.Shape clip)Draw a tile image on screen.private voiddrawInViewArea(java.awt.Graphics2D g, MapView mv, ProjectionBounds pb)protected intestimateTileCacheSize()voidfilterChanged()Invoked when the filter is changed.protected javax.swing.ActiongetAdjustAction()private static TileAnchorgetAnchor(org.openstreetmap.gui.jmapviewer.Tile tile, java.awt.image.BufferedImage image)intgetBestZoom()Returns best zoom level.javax.swing.Action[]getCommonEntries()Returns the common menu entries.TileSourceDisplaySettingsgetDisplaySettings()Gets theTileSourceDisplaySettingsinstance associated with this tile source.AbstractTileSourceLayer.PrecacheTaskgetDownloadAreaToCacheTask(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.ObjectgetInfoComponent()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.BufferedImagegetLoadedTileImage(org.openstreetmap.gui.jmapviewer.Tile tile)Returns the image for the given tile image is loaded.protected intgetMaxZoomLvl()static intgetMaxZoomLvl(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 intgetMinZoomLvl()static intgetMinZoomLvl(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.TilegetOrCreateTile(int x, int y, int zoom)private org.openstreetmap.gui.jmapviewer.TilegetOrCreateTile(TilePosition tilePosition)doublegetScaleFactor(int zoom)Returns average number of screen pixels per tile pixel for current mapviewprivate org.openstreetmap.gui.jmapviewer.interfaces.ICoordinategetShiftedCoord(EastNorth en)private LatLongetShiftedLatLon(EastNorth en)private org.openstreetmap.gui.jmapviewer.TilegetTile(int x, int y, int zoom)Returns tile at given position.private org.openstreetmap.gui.jmapviewer.TilegetTile(TilePosition tilePosition)private org.openstreetmap.gui.jmapviewer.TilegetTileForPixelpos(int px, int py)Returns tile for a pixel position.protected abstract TileLoaderFactorygetTileLoaderFactory()protected AbstractTileSourceLayer.TileSetgetTileSet(ProjectionBounds bounds, int zoom)Create a TileSet by EastNorth bbox taking a layer shift in accountprotected abstract TgetTileSource()Creates and returns a newTileSourceinstance depending onImageryLayer.infospecified in the constructor.java.lang.StringgetToolTipText()Returns a small tooltip hint about some statistics for this layer.private AbstractTileSourceLayer.TileSetgetVisibleTileSet()intgetZoomLevel()Get the current zoom level of the layervoidhookUpMapView()Creates popup menu items and binds to mouse actionsprivate booleanimageLoaded(java.awt.Image i)booleanimageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)booleanincreaseZoomLevel()Zoom in, go closer to map.private voidinitializeIfRequired()protected voidinitTileSource(T tileSource)private voidinvalidateLater()Invalidate the layer at a time in the future so that the user still sees the interface responsive.booleanisSavable()Replies the savable state of this layer (i.e., if it can be saved through a "File → Save" dialog).voidloadAllErrorTiles(boolean force)Load all visible tiles in error.voidloadAllTiles(boolean force)Load all visible tiles.private booleanloadTile(org.openstreetmap.gui.jmapviewer.Tile tile, boolean force)private voidmyDrawString(java.awt.Graphics g, java.lang.String text, int x, int y)voidpaint(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 voidpaintTileText(org.openstreetmap.gui.jmapviewer.Tile tile, java.awt.Graphics2D g)voidprojectionChanged(Projection oldValue, Projection newValue)static voidregisterMenuAddition(javax.swing.Action addition)Register an additional layer context menu entry.static voidregisterMenuAddition(javax.swing.Action addition, java.lang.Class<? extends AbstractTileSourceLayer<?>> clazz)Register an additional layer context menu entry for a imagery layer class.private static voidsendOsmTileRequest(org.openstreetmap.gui.jmapviewer.Tile tile, java.lang.String request)static voidsetMaxZoomLvl(int maxZoomLvl)Sets maximum zoom level, that layer will attempt showstatic voidsetMinZoomLvl(int minZoomLvl)Sets minimum zoom level, that layer will attempt showbooleansetZoomLevel(int zoom)Sets the zoom level of the layerprivate booleansetZoomLevel(int zoom, boolean invalidate)voidtileLoadingFinished(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)voidvisitBoundingBox(BoundingXYVisitor v)Visits the content bounds of this layer.voidzoomChanged()This fires every time the user changes the zoom, but also (due to ZoomChangeListener) - on all changes to visible map (panning/zooming)private voidzoomChanged(boolean invalidate)booleanzoomDecreaseAllowed()Check if zooming out is allowedbooleanzoomIncreaseAllowed()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 theTileSourceDisplaySettingsobject. Subclasses may implement it to e.g. change the prefix.- Returns:
- The object.
- Since:
- 10568
-
getDisplaySettings
public TileSourceDisplaySettings getDisplaySettings()
Gets theTileSourceDisplaySettingsinstance associated with this tile source.- Returns:
- The tile source display settings
- Since:
- 10568
-
filterChanged
public void filterChanged()
Description copied from interface:ImageryFilterSettings.FilterChangeListenerInvoked when the filter is changed.- Specified by:
filterChangedin 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 newTileSourceinstance depending onImageryLayer.infospecified 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:
tileLoadingFinishedin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener
-
clearTileCache
public void clearTileCache()
Clears the tile cache.
-
getInfoComponent
public java.lang.Object getInfoComponent()
Description copied from class:LayerGets 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:
getInfoComponentin classImageryLayer- Returns:
- Either a String or a
Componentdescribing the layer.
-
getAdjustAction
protected javax.swing.Action getAdjustAction()
- Specified by:
getAdjustActionin 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:
trueis 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:
hookUpMapViewin classLayer
-
attachToMapView
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
Description copied from class:AbstractMapViewPaintableThis 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:
attachToMapViewin 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:AbstractMapViewPaintableCreates a new LayerPainter.- Overrides:
createMapViewPainterin 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.DisplaySettingsChangeListenerCalled whenever the display settings have changed.- Specified by:
displaySettingsChangedin 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:
zoomChangedin 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-trueto force loading if auto-load is disabled- Since:
- 11950
-
loadAllErrorTiles
public void loadAllErrorTiles(boolean force)
Load all visible tiles in error.- Parameters:
force-trueto 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:
imageUpdatein 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:MapViewPaintablePaint the dataset using the engine set.- Specified by:
paintin 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:LayerReturns 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.INSTANCEinstead of new JSeparator- Specified by:
getMenuEntriesin 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:LayerReturns a small tooltip hint about some statistics for this layer.- Specified by:
getToolTipTextin classLayer- Returns:
- A small tooltip hint about some statistics for this layer.
-
visitBoundingBox
public void visitBoundingBox(BoundingXYVisitor v)
Description copied from class:LayerVisits 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:
visitBoundingBoxin 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:LayerReplies 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:LayerCreates 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:
createAndOpenSaveFileChooserin 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 customTileobjects.- Parameters:
source- Tile sourcex- X coordinatey- Y coordinatezoom- Zoom level- Returns:
- The new
Tile - Since:
- 17862
-
destroy
public void destroy()
Description copied from class:LayerCalled, 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:
destroyin interfaceDestroyable- Overrides:
destroyin classLayer
-
projectionChanged
public void projectionChanged(Projection oldValue, Projection newValue)
- Specified by:
projectionChangedin interfaceProjectionChangeListener- Overrides:
projectionChangedin classLayer
-
getOffsetMenuEntries
protected java.util.List<ImageryLayer.OffsetMenuEntry> getOffsetMenuEntries()
- Specified by:
getOffsetMenuEntriesin classImageryLayer
-
-