Class Layer

java.lang.Object
com.massifmaps.layers.Layer
Direct Known Subclasses:
CelestialLayer, SolidLayer, TileLayer, VectorLayer

public class Layer extends Object
An abstract base class for all layers.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getMetaData

      public StringVariantMap getMetaData()
      Returns a copy of the layer meta data map. The changes you make to this map are NOT reflected in the actual meta data of the layer.
      Returns:
      A copy of the layer meta data map.
    • setMetaData

      public void setMetaData(StringVariantMap metaData)
      Sets a new meta data map for the layer. Old meta data values will be lost.
      Parameters:
      metaData - The new meta data map for this layer.
    • containsMetaDataKey

      public boolean containsMetaDataKey(String key)
      Returns true if the specified key exists in the layer meta data map.
      Parameters:
      key - The key to check.
      Returns:
      True if the meta data element exists.
    • getMetaDataElement

      public Variant getMetaDataElement(String key)
      Returns a layer meta data element corresponding to the key. If no value is found null variant is returned.
      Parameters:
      key - The key to use.
      Returns:
      The value corresponding to the key from the meta data map. If the key does not exist, empty variant is returned.
    • setMetaDataElement

      public void setMetaDataElement(String key, Variant element)
      Adds a new key-value pair to the layer meta data map. If the key already exists in the map,
      it's value will be replaced by the new value.
      Parameters:
      key - The new key.
      element - The new value.
    • getUpdatePriority

      public int getUpdatePriority()
      Returns the layer task priority of this layer.
      Returns:
      The priority level for the tasks of this layer.
    • setUpdatePriority

      public void setUpdatePriority(int priority)
      Sets the layer task priority. Higher priority layers get to load data before
      lower priority layers. Normal layers and tile layers have seperate task queues and thus
      don't compete with each other for task queue access. The default is 0.
      Parameters:
      priority - The new task priority for this layer, higher values get better access.
    • setCullDelay

      public void setCullDelay(int delay)
      Sets the layer culling delay. The culling delay is used to delay layer content rendering in case of user interaction,
      higher delay improves performance and battery life at the expense of interactivity. Default is 200ms-400ms, depending
      on layer type.
      Parameters:
      delay - The new culling delay in milliseconds.
    • getOpacity

      public float getOpacity()
      Returns the opacity of this layer.
      Returns:
      The opacity of this layer.
    • setOpacity

      public void setOpacity(float opacity)
      Set the opacity of the layer.
      Parameters:
      opacity - The opacity of the layer in range (0..1). 1.0 is the default value.
    • isVisible

      public boolean isVisible()
      Returns the visibility of this layer.
      Returns:
      True if the layer is visible.
    • setVisible

      public void setVisible(boolean visible)
      Sets the visibility of this layer.
      Parameters:
      visible - The new visibility state of the layer.
    • isPostProcessed

      public boolean isPostProcessed()
      Returns whether this layer goes through the post-process effect.
      Returns:
      True if the layer is post-processed. The default is true.
    • setPostProcessed

      public void setPostProcessed(boolean postProcessed)
      Sets whether this layer goes through the post-process effect set with
      MapRenderer::setPostProcessEffect. A layer that opts out is drawn AFTER the effect
      has resolved - so it keeps its own appearance over a stylized map - but still into
      the same depth buffer, so it is occluded by the terrain as usual. Such a layer takes
      no part in the terrain depth/draping arrangement, so this is meant for overlays
      (annotations, sky-anchored objects), not for the tile layers that paint the ground.
      Has no effect while no post-process effect is set.
      Parameters:
      postProcessed - The new post-processing state of the layer.
    • getVisibleZoomRange

      public MapRange getVisibleZoomRange()
      Returns the visible zoom range of this layer.
      Returns:
      The visible zoom range of this layer.
    • setVisibleZoomRange

      public void setVisibleZoomRange(MapRange range)
      Sets the visible zoom range for this layer. Current zoom level must be within this range for the layer to be visible.
      This range is half-open, thus layer is visible if range.min <= ZOOMLEVEL < range.max.
      Parameters:
      range - new visible zoom range
    • isUpdateInProgress

      public boolean isUpdateInProgress()
      Tests whether this layer is being currently updated.
      Returns:
      True when the layer is being updated or false when the layer is in steady state.
    • update

      public void update(CullState cullState)
      Updates the layer using new visibility information. This method is periodically called when the map view moves.
      The visibilty info is saved, so the data can be refreshed later.
      Parameters:
      cullState - The new visibilty information.
    • refresh

      public void refresh()
      Refreshes the layer using old stored visibility information. This method might be called if some of the layer data
      changes.
    • simulateClick

      public void simulateClick(int clickType, ScreenPos screenPos, ViewState viewState)
      Simulate click on this layer. This may trigger any event listeners attached to the layer.
      Parameters:
      clickType - The type of the click.
      screenPos - The screen position for the simulated click.
      viewState - The view state to use.