Class ArcGISSublayer

java.lang.Object
com.esri.arcgisruntime.layers.ArcGISSublayer
All Implemented Interfaces:
RemoteResource, LayerContent, Loadable, PopupSource
Direct Known Subclasses:
ArcGISMapImageSublayer, ArcGISTiledSublayer, SubtypeSublayer

public abstract class ArcGISSublayer extends Object implements Loadable, RemoteResource, LayerContent, PopupSource
A base class for ArcGIS sublayer classes such as ArcGISMapImageSublayer, ArcGISTiledSublayer and SubtypeSublayer.

Some layers, such as ArcGISMapImageLayer, ArcGISTiledLayer, and SubtypeFeatureLayer, represent a collection of layers that are referred to as sublayers. For example, ArcGISMapImageLayer represents the collection of ArcGISMapImageLayer.getSublayers().

If one of the sublayers is a group layer (where the ArcGISMapServiceSublayerInfo.getServiceType() is ArcGISMapServiceSublayerInfo.ServiceType.GROUP_LAYER, for example), it will also have a collection of sublayers. Use getSublayers() to obtain the collection of sublayers. If one of these sublayers is a group layer it will also contain a collection of sublayers, and so on.

Note: Some of the sublayer properties can only be accessed once the sublayer has loaded.

Since:
100.0.0
See Also:
  • Property Details

  • Method Details

    • getId

      public long getId()
      Gets the ID that uniquely identifies this sublayer.
      Returns:
      the ID of this sublayer
      Since:
      100.0.0
    • getSublayers

      public ListenableList<ArcGISSublayer> getSublayers()
      Gets the collection of sublayers of a sublayer.

      This collection is usually empty unless the parent layer is loaded. Modifying this collection has no effect unless this sublayer is associated with an ArcGIS map service that supports dynamic layers. "Supports Dynamic Layers" must be set to true in the ArcGIS MapServer REST Services Directory.

      Returns:
      the collection of sublayers of a sublayer
      Since:
      100.0.0
    • getMinScale

      public double getMinScale()
      Gets the minimum viewing level at which this sublayer can be visible on a map.
      Returns:
      the minimum scale that this sublayer will be visible
      Since:
      100.0.0
    • getMaxScale

      public double getMaxScale()
      Gets the maximum viewing level at which this sublayer can be visible on a map.
      Returns:
      the maximum scale that this sublayer will be visible
      Since:
      100.0.0
    • getDefinitionExpression

      public String getDefinitionExpression()
      A SQL statement where clause that stipulates a subset of features to be displayed.

      The definition expression string uses the SQL-92 where clause syntax. Be sure to escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. For more information, see the ArcGIS Blog article Querying Feature Services Date-Time Queries.

      Returns:
      the definition expression
      Since:
      100.1.0
    • getMapServiceSublayerInfo

      public ArcGISMapServiceSublayerInfo getMapServiceSublayerInfo()
      Gets the metadata for this sublayer.
      Returns:
      the metadata, or null if this sublayer is not loaded
      Since:
      100.1.0
    • getOpacity

      public float getOpacity()
      Gets the opacity of this sublayer.
      Returns:
      the opacity
      Since:
      100.1.0
    • getRenderer

      public Renderer getRenderer()
      Gets the renderer for this sublayer.
      Returns:
      the renderer, or null if the sublayer is not loaded
      Since:
      100.1.0
    • setRenderer

      protected void setRenderer(Renderer renderer)
      Allows sub-classes to set the renderer reference e.g. ArcGISMapImageSublayer allows a renderer to be set.
      Parameters:
      renderer - the renderer to set
      Since:
      100.1.0
    • canScaleSymbols

      public boolean canScaleSymbols()
      True if the sublayer renderers its symbols based on scale, false otherwise.
      Returns:
      true if the text and symbols will change as the map scale varies, false otherwise
      Since:
      100.1.0
    • isLabelsEnabled

      public boolean isLabelsEnabled()
      True if the sublayer's labels are enabled, false otherwise.
      Returns:
      true if labels are enabled, false otherwise
      Since:
      100.1.0
    • getName

      public String getName()
      Gets the name property of this sublayer.
      Specified by:
      getName in interface LayerContent
      Returns:
      the name of this sublayer
      Since:
      100.0.0
    • getPopupDefinition

      public PopupDefinition getPopupDefinition()
      Gets the PopupDefinition defined in the ArcGISSublayer definition or set via setPopupDefinition(PopupDefinition), or null if one is not defined and one has not been set.
      Specified by:
      getPopupDefinition in interface PopupSource
      Returns:
      the ArcGISSublayer's PopupDefinition
      Since:
      100.0.0
      See Also:
    • setPopupDefinition

      public void setPopupDefinition(PopupDefinition popupDefinition)
      Sets the PopupDefinition for the ArcGISSublayer, overriding the previous one (for example, the one defined in the ArcGISSublayer definition).
      Specified by:
      setPopupDefinition in interface PopupSource
      Parameters:
      popupDefinition - the PopupDefinition to set
      Since:
      100.0.0
      See Also:
    • isPopupEnabled

      public boolean isPopupEnabled()
      Description copied from interface: PopupSource
      Checks if the pop-up definition returned from PopupSource.getPopupDefinition() is enabled or disabled.
      Specified by:
      isPopupEnabled in interface PopupSource
      Returns:
      true if the pop-up definition is enabled; false otherwise. Will return false if an error occurs.
      See Also:
    • setPopupEnabled

      public void setPopupEnabled(boolean enabled)
      Description copied from interface: PopupSource
      Sets whether the pop-up definition returned from PopupSource.getPopupDefinition() is enabled or disabled.
      Specified by:
      setPopupEnabled in interface PopupSource
      Parameters:
      enabled - true to enable the PopupDefinition; false otherwise
      See Also:
    • isVisible

      public boolean isVisible()
      Indicates if the sublayer is visible on the map.

      The visibility of a sublayer can change if it is manually set, setVisible(boolean), or the map's scale is outside of the sublayer's scale.

      Specified by:
      isVisible in interface LayerContent
      Returns:
      true if sublayer is visible; false otherwise
      Since:
      100.0.0
      See Also:
    • setVisible

      public void setVisible(boolean isVisible)
      Shows or hides this sublayer from a map.

      The default value for a sublayer's visibility is set to true.

      Specified by:
      setVisible in interface LayerContent
      Parameters:
      isVisible - true makes the sublayer visible, false makes it invisible
      Since:
      100.0.0
      See Also:
    • fetchLegendInfosAsync

      public ListenableFuture<List<LegendInfo>> fetchLegendInfosAsync()
      Gets properties from the legend information of this sublayer.

      These properties allow access to a Feature's name and symbol.

      Specified by:
      fetchLegendInfosAsync in interface LayerContent
      Returns:
      a listenable future that supplies a list of legend information.
      Since:
      100.0.0
      See Also:
    • canShowInLegend

      public boolean canShowInLegend()
      Description copied from interface: LayerContent
      Checks if this layer will be listed in the legend.
      Specified by:
      canShowInLegend in interface LayerContent
      Returns:
      true if this layer will be visible in the legend; false otherwise
    • setCanShowInLegend

      public void setCanShowInLegend(boolean canShowInLegend)
      Description copied from interface: LayerContent
      Sets whether or not this layer should be visible in the legend.
      Specified by:
      setCanShowInLegend in interface LayerContent
      Parameters:
      canShowInLegend - true to show in the legend; false to omit it from the legend
    • getSubLayerContents

      public ListenableList<LayerContent> getSubLayerContents()
      Description copied from interface: LayerContent
      Returns a list of sub layers, if any. If there are no sub-layers, an empty list will be returned. This list cannot be used to add or remove sub-layers.
      Specified by:
      getSubLayerContents in interface LayerContent
      Returns:
      a read only list of sub-layers, if any
    • isVisibleAtScale

      public boolean isVisibleAtScale(double scale)
      Description copied from interface: LayerContent
      Checks if this layer has effective visibility at the given scale. This effective visibility takes care of the effective visibility of the parents at the specified scale.
      Specified by:
      isVisibleAtScale in interface LayerContent
      Parameters:
      scale - the scale the visibility has to be calculated for
      Returns:
      true if the layer will be visible at the given scale; false otherwise
    • canChangeVisibility

      public boolean canChangeVisibility()
      Description copied from interface: LayerContent
      Checks whether we can change the visibility of this layer.
      Specified by:
      canChangeVisibility in interface LayerContent
      Returns:
      true if we can change this layer's visibility; false otherwise
    • getLoadStatus

      public LoadStatus getLoadStatus()
      Description copied from interface: Loadable
      Returns the LoadStatus of the loadable resource.
      Specified by:
      getLoadStatus in interface Loadable
      Returns:
      the LoadStatus of the loadable resource
      Since:
      100.1.0
    • getLoadError

      public ArcGISRuntimeException getLoadError()
      Description copied from interface: Loadable
      Returns the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state, either due to calling the Loadable.loadAsync() or Loadable.retryLoadAsync() method.

      If the resource subsequently transitions to LoadStatus.LOADED (for example, if a call to retryLoadAsync completes successfully) the error is cleared out.

      Specified by:
      getLoadError in interface Loadable
      Returns:
      the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state.
      Since:
      100.1.0
    • loadAsync

      public void loadAsync()
      Description copied from interface: Loadable
      Loads the metadata of the loadable resource asynchronously.

      The load status changes from LoadStatus.NOT_LOADED to LoadStatus.LOADING. A listener can be added via Loadable.addDoneLoadingListener(java.lang.Runnable) that is invoked upon completion of the asynchronous load operation.

      If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.

      If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOAD and the error can be retrieved by calling Loadable.getLoadError().

      This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (LoadStatus.LOADING state) when loadAsync is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED or LoadStatus.FAILED_TO_LOAD state) when loadAsync is called, the done loading listener is immediately invoked when added to the loadable resource.

      If a loadable resource has failed to load, calling loadAsync on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource, Loadable.retryLoadAsync() needs to be used.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling Loadable.cancelLoad().

      Specified by:
      loadAsync in interface Loadable
      Since:
      100.1.0
    • retryLoadAsync

      public void retryLoadAsync()
      Description copied from interface: Loadable
      Loads or retries loading metadata for the object asynchronously.

      Will retry loading the metadata if the object's load status is LoadStatus.FAILED_TO_LOAD. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.

      For more details on the load process see Loadable.loadAsync().

      Specified by:
      retryLoadAsync in interface Loadable
      Since:
      100.1.0
    • cancelLoad

      public void cancelLoad()
      Description copied from interface: Loadable
      Cancels loading metadata for the object.

      Cancels loading the metadata if the object is loading, and always invokes the done loading listener.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled, a CancellationException will be returned from Loadable.getLoadError().

      Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.

      This method does nothing if the resource is not in LoadStatus.LOADING state.

      Specified by:
      cancelLoad in interface Loadable
      Since:
      100.1.0
    • addDoneLoadingListener

      public void addDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Adds a listener to the loadable resource that is invoked when loading has completed.

      The listener may be added at any point, whether the loadable resource has already completed loading or not.

      • For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
      • For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.

      Alternatively, to be notified when there is any change in the load status, add a listener to the Loadable.loadStatusProperty() instead.

      Specified by:
      addDoneLoadingListener in interface Loadable
      Parameters:
      listener - a Runnable that is invoked upon completion of the load operation
      Since:
      100.1.0
    • removeDoneLoadingListener

      public boolean removeDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Removes a done loading listener from the loadable resource.
      Specified by:
      removeDoneLoadingListener in interface Loadable
      Parameters:
      listener - the listener to be removed
      Returns:
      true if the listener was removed, otherwise false
      Since:
      100.1.0
    • addLoadStatusChangedListener

      public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Adds a LoadStatusChangedListener to the loadable resource that is invoked whenever the load status changes.

      Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

      The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable) method.

      Specified by:
      addLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be added
      Since:
      100.1.0
    • removeLoadStatusChangedListener

      public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Removes a LoadStatusChangedListener from the loadable resource.
      Specified by:
      removeLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be removed
      Returns:
      true if the listener was removed, otherwise false
      Since:
      100.1.0
    • loadStatusProperty

      public ReadOnlyObjectProperty<LoadStatus> loadStatusProperty()
      Description copied from interface: Loadable
      The load status.
      Specified by:
      loadStatusProperty in interface Loadable
      Returns:
      the loadStatus property
      See Also:
    • loadErrorProperty

      public ReadOnlyObjectProperty<ArcGISRuntimeException> loadErrorProperty()
      Description copied from interface: Loadable
      The load error.
      Specified by:
      loadErrorProperty in interface Loadable
      Returns:
      the loadError property
      See Also:
    • setCredential

      public void setCredential(Credential credential)
      Sets the credential used to authenticate the user with the sublayer.
      Specified by:
      setCredential in interface RemoteResource
      Parameters:
      credential - the credential used to authenticate the user with the sublayer
      Since:
      100.1.0
    • getCredential

      public Credential getCredential()
      Gets the credential used to authenticate the user with the sublayer.
      Specified by:
      getCredential in interface RemoteResource
      Returns:
      the credential used to authenticate the user with the sublayer
      Since:
      100.1.0
    • setRequestConfiguration

      public void setRequestConfiguration(RequestConfiguration requestConfiguration)
      Sets the configuration parameters used for sending a network request using this sublayer object. The global RequestConfiguration is used if no RequestConfiguration is set or null is set (see RequestConfiguration.getGlobalRequestConfiguration()).
      Specified by:
      setRequestConfiguration in interface RemoteResource
      Parameters:
      requestConfiguration - a RequestConfiguration containing the parameters to use
      Since:
      100.1.0
    • getRequestConfiguration

      public RequestConfiguration getRequestConfiguration()
      Gets the RequestConfiguration in use by this sublayer. If null is returned, it indicates that the global RequestConfiguration is used instead.
      Specified by:
      getRequestConfiguration in interface RemoteResource
      Returns:
      the RequestConfiguration, or null if none is set
      Since:
      100.1.0
    • getUri

      public String getUri()
      Gets the URL for this sublayer.
      Specified by:
      getUri in interface RemoteResource
      Returns:
      the URL, or null if the sublayer is not loaded
      Since:
      100.1.0
    • copy

      public abstract ArcGISSublayer copy()
      Creates a deep copy of this ArcGISSublayer instance.
      Returns:
      a deep copy of this ArcGISSublayer instance
      Since:
      100.1.0
    • copyTo

      protected void copyTo(ArcGISSublayer copy)
      Copies fields in this class to the copy instance.
      Parameters:
      copy - instance to copy the fields of this class to
      Since:
      100.1.0