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
ImageryLayer.ApplyOffsetAction, ImageryLayer.OffsetAction
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 |
private AbstractTileSourceLayer.TileHolder |
clickedTileHolder |
private TileCoordinateConverter |
coordinateConverter |
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 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_FADE_AMOUNT, PROP_FADE_COLOR, 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 |
---|---|
private static boolean |
actionSupportLayers(java.util.List<Layer> layers) |
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(ProgressMonitor monitor)
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 |
displace(double dx,
double dy)
Deprecated.
|
void |
displaySettingsChanged(TileSourceDisplaySettings.DisplaySettingsChangeEvent e)
Called whenever the display settings have changed.
|
AbstractTileSourceLayer.PrecacheTask |
downloadAreaToCache(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.
|
private void |
drawImageInside(java.awt.Graphics g,
java.awt.Image sourceImg,
java.awt.geom.Rectangle2D source,
java.awt.geom.Rectangle2D border) |
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() |
protected int |
getBestZoom() |
javax.swing.Action[] |
getCommonEntries()
Returns the common menu entries.
|
TileSourceDisplaySettings |
getDisplaySettings()
Gets the
TileSourceDisplaySettings instance associated with this tile source. |
double |
getDx()
Deprecated.
|
double |
getDy()
Deprecated.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getHeaders(T tileSource) |
java.lang.Object |
getInfoComponent() |
javax.swing.Action[] |
getLayerListEntries()
Returns the contextual menu entries in layer list dialog.
|
private java.awt.Image |
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) |
private Tile |
getOrCreateTile(int x,
int y,
int zoom) |
private Tile |
getOrCreateTile(TilePosition tilePosition) |
private 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 LatLon |
getShiftedLatLon(ICoordinate latLon) |
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(EastNorth topLeft,
EastNorth botRight,
int zoom)
Create a TileSet by EastNorth bbox taking a layer shift in account
|
protected AbstractTileSourceLayer.TileSet |
getTileSet(LatLon topLeft,
LatLon botRight,
int zoom)
Create a TileSet by known LatLon bbox without layer shift correction
|
private static <S extends AbstractTMSTileSource> |
getTileSetInfo(AbstractTileSourceLayer.TileSet ts) |
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() |
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 taht the user still sees the interface responsive.
|
boolean |
isChanged()
Check changed status of layer
|
boolean |
isSavable()
Replies the savable state of this layer (i.e if it can be saved through a "File->Save" dialog).
|
protected void |
loadAllErrorTiles(boolean force) |
protected void |
loadAllTiles(boolean force) |
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.Graphics g,
AbstractTileSourceLayer.TileSet ts) |
private java.util.List<Tile> |
paintTileImages(java.awt.Graphics g,
AbstractTileSourceLayer.TileSet ts,
int zoom,
Tile border) |
private void |
paintTileText(AbstractTileSourceLayer.TileSet ts,
Tile tile,
java.awt.Graphics g,
MapView mv,
int zoom,
Tile t) |
protected void |
redraw()
Initiates a repaint of Main.map
|
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.
|
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
|
void |
setOffset(double dx,
double dy)
Deprecated.
|
boolean |
setZoomLevel(int zoom)
Sets the zoom level of the layer
|
private Tile |
tempCornerTile(Tile t) |
void |
tileLoadingFinished(Tile tile,
boolean success)
Will be called if a new
Tile has been loaded successfully. |
void |
visitBoundingBox(BoundingXYVisitor v) |
void |
zoomChanged()
This fires every time the user changes the zoom, but also (due to ZoomChangeListener) - on all
changes to visible map (panning/zooming)
|
boolean |
zoomDecreaseAllowed()
Check if zooming out is allowed
|
boolean |
zoomIncreaseAllowed() |
addImageProcessor, applyImageProcessors, create, createImageProcessor, getFadeColor, getFadeColorWithAlpha, 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, projectionChanged, 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
public int currentZoomLevel
private final AttributionSupport attribution
private final AbstractTileSourceLayer.TileHolder clickedTileHolder
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
private TileCoordinateConverter coordinateConverter
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()
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(ProgressMonitor monitor)
monitor
- not used in this implementation - as cache clear is instaneusprotected void redraw()
Main.map
,
Component.repaint()
,
To trigger a repaint of all places where the layer is displayed.
@Deprecated public double getDx()
TileSourceDisplaySettings.getDx()
getDx
in class ImageryLayer
@Deprecated public double getDy()
TileSourceDisplaySettings.getDy()
getDy
in class ImageryLayer
@Deprecated public void displace(double dx, double dy)
TileSourceDisplaySettings
displace
in class ImageryLayer
dx
- deprecateddy
- deprecated@Deprecated public void setOffset(double dx, double dy)
TileSourceDisplaySettings
setOffset
in class ImageryLayer
dx
- The x offsetdy
- The y offsetpublic java.lang.Object getInfoComponent()
getInfoComponent
in class ImageryLayer
protected javax.swing.Action getAdjustAction()
getAdjustAction
in class ImageryLayer
private double getScaleFactor(int zoom)
zoom
- zoom levelprotected int getBestZoom()
private static boolean actionSupportLayers(java.util.List<Layer> layers)
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
protected int getMaxZoomLvl()
protected int getMinZoomLvl()
public boolean zoomIncreaseAllowed()
public boolean increaseZoomLevel()
public boolean setZoomLevel(int zoom)
zoom
- zoom levelpublic boolean zoomDecreaseAllowed()
public boolean decreaseZoomLevel()
private Tile tempCornerTile(Tile t)
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()
protected void loadAllTiles(boolean force)
protected void loadAllErrorTiles(boolean force)
public 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 getLoadedTileImage(Tile tile)
tile
- the Tile for which the image should be returnedprivate void drawImageInside(java.awt.Graphics g, java.awt.Image sourceImg, java.awt.geom.Rectangle2D source, java.awt.geom.Rectangle2D border)
private java.util.List<Tile> paintTileImages(java.awt.Graphics g, AbstractTileSourceLayer.TileSet ts)
private java.util.List<Tile> paintTileImages(java.awt.Graphics g, AbstractTileSourceLayer.TileSet ts, int zoom, Tile border)
private void myDrawString(java.awt.Graphics g, java.lang.String text, int x, int y)
private void paintTileText(AbstractTileSourceLayer.TileSet ts, Tile tile, java.awt.Graphics g, MapView mv, int zoom, Tile t)
private LatLon getShiftedLatLon(EastNorth en)
private ICoordinate getShiftedCoord(EastNorth en)
private LatLon getShiftedLatLon(ICoordinate latLon)
protected AbstractTileSourceLayer.TileSet getTileSet(EastNorth topLeft, EastNorth botRight, int zoom)
topLeft
- top-left lat/lonbotRight
- bottom-right lat/lonzoom
- zoom levelprotected AbstractTileSourceLayer.TileSet getTileSet(LatLon topLeft, LatLon botRight, int zoom)
topLeft
- top-left lat/lonbotRight
- bottom-right lat/lonzoom
- zoom levelprivate static <S extends AbstractTMSTileSource> AbstractTileSourceLayer.TileSetInfo getTileSetInfo(AbstractTileSourceLayer.TileSet ts)
public 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)
visitBoundingBox
in class Layer
public boolean isChanged()
Layer
public AbstractTileSourceLayer.PrecacheTask downloadAreaToCache(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