Class OffsetBookmark

java.lang.Object
org.openstreetmap.josm.data.imagery.OffsetBookmark

public class OffsetBookmark extends Object
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 Details

  • 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 new OffsetBookmark object using (0, 0) as center

      The use of the OffsetBookmark(String, String, String, String, EastNorth, ILatLon) constructor is preferred.

      Parameters:
      projectionCode - The projection for which this object was created
      imageryId - 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 bookmark
      dx - The x displacement
      dy - The y displacement
      Since:
      13797
    • OffsetBookmark

      public OffsetBookmark(String projectionCode, String imageryId, String imageryName, String name, EastNorth displacement, ILatLon center)
      Create a new OffsetBookmark object
      Parameters:
      projectionCode - The projection for which this object was created
      imageryId - 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 bookmark
      displacement - 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 new OffsetBookmark by 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 created
      imageryId - 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 bookmark
      dx - The x displacement
      dy - The y displacement
      centerLon - 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

      public boolean isUsable(ImageryLayer layer)
      Test if an image is usable for the given imagery layer.
      Parameters:
      layer - The layer to use the image at
      Returns:
      true if 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

      public String getName()
      Get the name of this bookmark. This name can e.g. be displayed in menus.
      Returns:
      The name
    • getImageryId

      public String 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

      public LatLon 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 (see hasCenter(), in which case a dummy center (0,0) will be returned.
      Returns:
      the center
    • hasCenter

      public boolean hasCenter()
      Check if bookmark has a valid center.
      Returns:
      true if bookmark has a valid center
    • setProjectionCode

      public void setProjectionCode(String projectionCode)
      Set the projection code for which this bookmark was created
      Parameters:
      projectionCode - The projection
    • setName

      public void setName(String name)
      Set the name of the bookmark
      Parameters:
      name - The name
      See Also:
    • setImageryName

      public void setImageryName(String imageryName)
      Sets the name of the imagery
      Parameters:
      imageryName - The name
      See Also:
    • setImageryId

      public void setImageryId(String imageryId)
      Sets the id of the imagery
      Parameters:
      imageryId - The identifier
      Since:
      13797
      See Also:
    • setDisplacement

      public void setDisplacement(EastNorth displacement)
      Update the displacement of this imagery.
      Parameters:
      displacement - The displacement
    • loadBookmarks

      public static void loadBookmarks()
      Load the global list of bookmarks from preferences.
    • sanitizeBookmarks

      static void sanitizeBookmarks(List<OffsetBookmark> bookmarks)
    • saveBookmarks

      public static void saveBookmarks()
      Stores the bookmarks in the settings.
    • getBookmarks

      public static List<OffsetBookmark> getBookmarks()
      Returns all bookmarks.
      Returns:
      all bookmarks (unmodifiable collection)
      Since:
      11651
    • getBookmarksSize

      public static int getBookmarksSize()
      Returns the number of bookmarks.
      Returns:
      the number of bookmarks
      Since:
      11651
    • addBookmark

      public static boolean addBookmark(OffsetBookmark ob)
      Adds a bookmark.
      Parameters:
      ob - bookmark to add
      Returns:
      true
      Since:
      11651
    • removeBookmark

      public static boolean removeBookmark(OffsetBookmark ob)
      Removes a bookmark.
      Parameters:
      ob - bookmark to remove
      Returns:
      true if this list contained the specified element
      Since:
      11651
    • getBookmarkByIndex

      public static OffsetBookmark getBookmarkByIndex(int index)
      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

      public static OffsetBookmark getBookmarkByName(ImageryLayer layer, String name)
      Gets a bookmark that is usable on the given layer by it's name.
      Parameters:
      layer - The layer to use the bookmark at
      name - The name of the bookmark
      Returns:
      The bookmark if found, null if not.
    • bookmarkOffset

      public static void bookmarkOffset(String name, AbstractTileSourceLayer<?> layer)
      Add a bookmark for the displacement of that layer
      Parameters:
      name - The bookmark name
      layer - 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

      public static OffsetBookmark fromPropertiesMap(Map<String,String> properties)
      Creates an offset bookmark from a properties map.
      Parameters:
      properties - the properties map
      Returns:
      corresponding offset bookmark
      Since:
      12134
      See Also: