Class OffsetBookmark


  • public class OffsetBookmark
    extends java.lang.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.
    • Constructor Detail

      • OffsetBookmark

        public OffsetBookmark()
        Construct new empty OffsetBookmark. Only used for preferences handling.
      • OffsetBookmark

        public OffsetBookmark​(java.lang.String projectionCode,
                              java.lang.String imageryId,
                              java.lang.String imageryName,
                              java.lang.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​(java.lang.String projectionCode,
                              java.lang.String imageryId,
                              java.lang.String imageryName,
                              java.lang.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​(java.lang.String projectionCode,
                              java.lang.String imageryId,
                              java.lang.String imageryName,
                              java.lang.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 Detail

      • 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

        public java.lang.String getProjectionCode()
        Get the projection code for which this bookmark was created.
        Returns:
        The projection.
      • getName

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

        public java.lang.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

        public java.lang.String 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

        public EastNorth getDisplacement​(Projection proj)
        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​(java.lang.String projectionCode)
        Set the projection code for which this bookmark was created
        Parameters:
        projectionCode - The projection
      • setName

        public void setName​(java.lang.String name)
        Set the name of the bookmark
        Parameters:
        name - The name
        See Also:
        getName()
      • setImageryName

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

        public void setImageryId​(java.lang.String imageryId)
        Sets the id of the imagery
        Parameters:
        imageryId - The identifier
        Since:
        13797
        See Also:
        getImageryId()
      • 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.
      • saveBookmarks

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

        public static java.util.List<OffsetBookmarkgetBookmarks()
        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:
        java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
        Since:
        11651
      • getBookmarkByName

        public static OffsetBookmark getBookmarkByName​(ImageryLayer layer,
                                                       java.lang.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​(java.lang.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

        public java.util.Map<java.lang.String,​java.lang.String> 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(java.util.Map)
      • fromPropertiesMap

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