Class ImageryLayerInfo
- java.lang.Object
-
- org.openstreetmap.josm.data.imagery.ImageryLayerInfo
-
public class ImageryLayerInfo extends java.lang.Object
Manages the list of imagery entries that are shown in the imagery menu.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classImageryLayerInfo.DefaultEntryLoaderLoader/updater of the available imagery entries
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.List<ImageryInfo>allDefaultLayersList of all available default layers (including mirrors)private static java.lang.String[]DEFAULT_LAYER_SITES(package private) static java.util.Map<java.lang.String,ImageryInfo>defaultLayerIdsList of all layer ids of available default layers (including mirrors)(package private) static java.util.List<ImageryInfo>defaultLayersList of all available default layersstatic ImageryLayerInfoinstanceUnique instanceprivate java.util.Map<java.lang.String,ImageryInfo>layerIdsList of layer ids of all usable layersprivate java.util.List<ImageryInfo>layersList of all usable layers
-
Constructor Summary
Constructors Modifier Constructor Description privateImageryLayerInfo()ImageryLayerInfo(ImageryLayerInfo info)Constructs a newImageryLayerInfofrom an existing one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(ImageryInfo info)Add a new imagery entry.static voidaddLayer(ImageryInfo info)static voidaddLayers(java.util.Collection<ImageryInfo> infos)private static voidbuildIdMap(java.util.List<ImageryInfo> lst, java.util.Map<java.lang.String,ImageryInfo> idMap)Build the mapping of unique ids toImageryInfos.voidclear()Clear the lists of layers.voiddropOldEntries()Drop entries with Id which do no longer exist (removed from defaults).java.util.List<ImageryInfo>getAllDefaultLayers()List of all available default layers (including mirrors)java.util.List<ImageryInfo>getDefaultLayers()List of available default layersstatic java.util.Collection<java.lang.String>getImageryLayersSites()Returns the list of imagery layers sites.ImageryInfogetLayer(java.lang.String id)Returns imagery layer info for the given id.java.util.List<ImageryInfo>getLayers()List of usable layersjava.lang.StringgetUniqueId(ImageryInfo info)Get unique id for ImageryInfo.private static booleanisSimilar(java.lang.String a, java.lang.String b)private static booleanisSimilar(ImageryInfo iiA, ImageryInfo iiB)voidload(boolean fastFail)Loads the custom as well as default imagery entries.voidloadDefaults(boolean clearCache, java.util.concurrent.ExecutorService worker, boolean fastFail)Loads the available imagery entries.voidremove(ImageryInfo info)Remove an imagery entry.voidsave()Save the list of imagery entries to preferences.voidupdateEntriesFromDefaults(boolean dropold)Update user entries according to the list of default entries.
-
-
-
Field Detail
-
instance
public static final ImageryLayerInfo instance
Unique instance
-
layers
private final java.util.List<ImageryInfo> layers
List of all usable layers
-
layerIds
private final java.util.Map<java.lang.String,ImageryInfo> layerIds
List of layer ids of all usable layers
-
defaultLayers
static final java.util.List<ImageryInfo> defaultLayers
List of all available default layers
-
allDefaultLayers
static final java.util.List<ImageryInfo> allDefaultLayers
List of all available default layers (including mirrors)
-
defaultLayerIds
static final java.util.Map<java.lang.String,ImageryInfo> defaultLayerIds
List of all layer ids of available default layers (including mirrors)
-
DEFAULT_LAYER_SITES
private static final java.lang.String[] DEFAULT_LAYER_SITES
-
-
Constructor Detail
-
ImageryLayerInfo
private ImageryLayerInfo()
-
ImageryLayerInfo
public ImageryLayerInfo(ImageryLayerInfo info)
Constructs a newImageryLayerInfofrom an existing one.- Parameters:
info- info to copy
-
-
Method Detail
-
getImageryLayersSites
public static java.util.Collection<java.lang.String> getImageryLayersSites()
Returns the list of imagery layers sites.- Returns:
- the list of imagery layers sites
- Since:
- 7434
-
clear
public void clear()
Clear the lists of layers.
-
load
public void load(boolean fastFail)
Loads the custom as well as default imagery entries.- Parameters:
fastFail- whether opening HTTP connections should fail fast, seeImageryReader.setFastFail(boolean)
-
loadDefaults
public void loadDefaults(boolean clearCache, java.util.concurrent.ExecutorService worker, boolean fastFail)
Loads the available imagery entries. The data is downloaded from the JOSM website (or loaded from cache). Entries marked as "default" are added to the user selection, if not already present.- Parameters:
clearCache- if true, clear the cache and start a fresh download.worker- executor service which will perform the loading. If null, it should be performed using aPleaseWaitRunnablein the backgroundfastFail- whether opening HTTP connections should fail fast, seeImageryReader.setFastFail(boolean)- Since:
- 12634
-
buildIdMap
private static void buildIdMap(java.util.List<ImageryInfo> lst, java.util.Map<java.lang.String,ImageryInfo> idMap)
Build the mapping of unique ids toImageryInfos.- Parameters:
lst- input listidMap- output map
-
updateEntriesFromDefaults
public void updateEntriesFromDefaults(boolean dropold)
Update user entries according to the list of default entries.- Parameters:
dropold- iftrueold entries should be removed- Since:
- 11706
-
dropOldEntries
public void dropOldEntries()
Drop entries with Id which do no longer exist (removed from defaults).- Since:
- 11527
-
isSimilar
private static boolean isSimilar(ImageryInfo iiA, ImageryInfo iiB)
-
isSimilar
private static boolean isSimilar(java.lang.String a, java.lang.String b)
-
add
public void add(ImageryInfo info)
Add a new imagery entry.- Parameters:
info- imagery entry to add
-
remove
public void remove(ImageryInfo info)
Remove an imagery entry.- Parameters:
info- imagery entry to remove
-
save
public void save()
Save the list of imagery entries to preferences.
-
getLayers
public java.util.List<ImageryInfo> getLayers()
List of usable layers- Returns:
- unmodifiable list containing usable layers
-
getDefaultLayers
public java.util.List<ImageryInfo> getDefaultLayers()
List of available default layers- Returns:
- unmodifiable list containing available default layers
-
getAllDefaultLayers
public java.util.List<ImageryInfo> getAllDefaultLayers()
List of all available default layers (including mirrors)- Returns:
- unmodifiable list containing available default layers
- Since:
- 11570
-
addLayer
public static void addLayer(ImageryInfo info)
-
addLayers
public static void addLayers(java.util.Collection<ImageryInfo> infos)
-
getUniqueId
public java.lang.String getUniqueId(ImageryInfo info)
Get unique id for ImageryInfo. This takes care, that no id is used twice (due to a user error)- Parameters:
info- the ImageryInfo to look up- Returns:
- null, if there is no id or the id is used twice, the corresponding id otherwise
-
getLayer
public ImageryInfo getLayer(java.lang.String id)
Returns imagery layer info for the given id.- Parameters:
id- imagery layer id.- Returns:
- imagery layer info for the given id, or
null - Since:
- 13797
-
-