Class OffsetBookmark
java.lang.Object
org.openstreetmap.josm.data.imagery.OffsetBookmark
Class to save a displacement of background imagery as a bookmark.
Known offset bookmarks will be stored in the preferences and can be
restored by the user in later sessions.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct new empty OffsetBookmark.OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, double dx, double dy) Create a newOffsetBookmarkobject using (0, 0) as centerOffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, double dx, double dy, double centerLon, double centerLat) Create a newOffsetBookmarkby specifying all values.OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, EastNorth displacement, ILatLon center) Create a newOffsetBookmarkobject -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanAdds a bookmark.static voidbookmarkOffset(String name, AbstractTileSourceLayer<?> layer) Add a bookmark for the displacement of that layerstatic OffsetBookmarkfromPropertiesMap(Map<String, String> properties) Creates an offset bookmark from a properties map.static OffsetBookmarkgetBookmarkByIndex(int index) Returns the bookmark at the given index.static OffsetBookmarkgetBookmarkByName(ImageryLayer layer, String name) Gets a bookmark that is usable on the given layer by it's name.static List<OffsetBookmark>Returns all bookmarks.static intReturns the number of bookmarks.Get center/reference point of the bookmark.Get displacement in EastNorth coordinates of the original projection.getDisplacement(Projection proj) Get displacement in EastNorth coordinates of a given projection.Get the id of the imagery for which this bookmark was created.Get the name of the imagery for which this bookmark was created.getName()Get the name of this bookmark.Get the projection code for which this bookmark was created.booleanCheck if bookmark has a valid center.booleanisUsable(ImageryLayer layer) Test if an image is usable for the given imagery layer.static voidLoad the global list of bookmarks from preferences.static booleanRemoves a bookmark.(package private) static voidsanitizeBookmarks(List<OffsetBookmark> bookmarks) static voidStores the bookmarks in the settings.voidsetDisplacement(EastNorth displacement) Update the displacement of this imagery.voidsetImageryId(String imageryId) Sets the id of the imageryvoidsetImageryName(String imageryName) Sets the name of the imageryvoidSet the name of the bookmarkvoidsetProjectionCode(String projectionCode) Set the projection code for which this bookmark was createdConverts the offset bookmark to a properties map.
-
Field Details
-
allBookmarks
-
projection_code
-
imagery_id
-
imagery_name
Imagery localized name. Locale insensitiveimagery_idis preferred. -
name
-
dx
-
dy
-
center_lon
-
center_lat
-
-
Constructor Details
-
OffsetBookmark
public OffsetBookmark()Construct new empty OffsetBookmark. Only used for preferences handling. -
OffsetBookmark
public OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, double dx, double dy) Create a newOffsetBookmarkobject using (0, 0) as centerThe use of the
OffsetBookmark(String, String, String, String, EastNorth, ILatLon)constructor is preferred.- Parameters:
projectionCode- The projection for which this object was createdimageryId- The id of the imagery on the layer (locale insensitive)imageryName- The name of the imagery on the layer (locale sensitive)name- The name of the new bookmarkdx- The x displacementdy- The y displacement- Since:
- 13797
-
OffsetBookmark
public OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, EastNorth displacement, ILatLon center) Create a newOffsetBookmarkobject- Parameters:
projectionCode- The projection for which this object was createdimageryId- The id of the imagery on the layer (locale insensitive)imageryName- The name of the imagery on the layer (locale sensitive)name- The name of the new bookmarkdisplacement- The displacement in east/north space.center- The point on earth that was used as reference to align the image.- Since:
- 13797
-
OffsetBookmark
public OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, double dx, double dy, double centerLon, double centerLat) Create a newOffsetBookmarkby specifying all values.The use of the
OffsetBookmark(String, String, String, String, EastNorth, ILatLon)constructor is preferred.- Parameters:
projectionCode- The projection for which this object was createdimageryId- The id of the imagery on the layer (locale insensitive)imageryName- The name of the imagery on the layer (locale sensitive)name- The name of the new bookmarkdx- The x displacementdy- The y displacementcenterLon- The point on earth that was used as reference to align the image.centerLat- The point on earth that was used as reference to align the image.- Since:
- 13797
-
-
Method Details
-
isUsable
Test if an image is usable for the given imagery layer.- Parameters:
layer- The layer to use the image at- Returns:
trueif it is usable on the projection of the layer and the imagery name matches.
-
getProjectionCode
Get the projection code for which this bookmark was created.- Returns:
- The projection.
-
getName
Get the name of this bookmark. This name can e.g. be displayed in menus.- Returns:
- The name
-
getImageryId
Get the id of the imagery for which this bookmark was created. It is used to match the bookmark to the right layers.- Returns:
- The imagery identifier
- Since:
- 13797
-
getImageryName
Get the name of the imagery for which this bookmark was created. It is used to match the bookmark to the right layers if id is missing.- Returns:
- The name
-
getDisplacement
Get displacement in EastNorth coordinates of the original projection.- Returns:
- the displacement
- See Also:
-
getDisplacement
Get displacement in EastNorth coordinates of a given projection. Displacement will be converted to the given projection, with respect to the center (reference point) of this bookmark.- Parameters:
proj- the projection- Returns:
- the displacement, converted to that projection
-
getCenter
Get center/reference point of the bookmark. Basically this is the place where it was created and is valid. The center may be unrecorded (seehasCenter(), in which case a dummy center (0,0) will be returned.- Returns:
- the center
-
hasCenter
Check if bookmark has a valid center.- Returns:
- true if bookmark has a valid center
-
setProjectionCode
Set the projection code for which this bookmark was created- Parameters:
projectionCode- The projection
-
setName
Set the name of the bookmark- Parameters:
name- The name- See Also:
-
setImageryName
Sets the name of the imagery- Parameters:
imageryName- The name- See Also:
-
setImageryId
Sets the id of the imagery- Parameters:
imageryId- The identifier- Since:
- 13797
- See Also:
-
setDisplacement
Update the displacement of this imagery.- Parameters:
displacement- The displacement
-
loadBookmarks
Load the global list of bookmarks from preferences. -
sanitizeBookmarks
-
saveBookmarks
Stores the bookmarks in the settings. -
getBookmarks
Returns all bookmarks.- Returns:
- all bookmarks (unmodifiable collection)
- Since:
- 11651
-
getBookmarksSize
Returns the number of bookmarks.- Returns:
- the number of bookmarks
- Since:
- 11651
-
addBookmark
Adds a bookmark.- Parameters:
ob- bookmark to add- Returns:
true- Since:
- 11651
-
removeBookmark
Removes a bookmark.- Parameters:
ob- bookmark to remove- Returns:
trueif this list contained the specified element- Since:
- 11651
-
getBookmarkByIndex
Returns the bookmark at the given index.- Parameters:
index- bookmark index- Returns:
- the bookmark at the given index
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())- Since:
- 11651
-
getBookmarkByName
Gets a bookmark that is usable on the given layer by it's name.- Parameters:
layer- The layer to use the bookmark atname- The name of the bookmark- Returns:
- The bookmark if found,
nullif not.
-
bookmarkOffset
Add a bookmark for the displacement of that layer- Parameters:
name- The bookmark namelayer- The layer to store the bookmark for
-
toPropertiesMap
Converts the offset bookmark to a properties map. The map contains all the information to restore the offset bookmark.- Returns:
- properties map of all data
- Since:
- 12134
- See Also:
-
fromPropertiesMap
Creates an offset bookmark from a properties map.- Parameters:
properties- the properties map- Returns:
- corresponding offset bookmark
- Since:
- 12134
- See Also:
-