Class ArcGISScene

  • All Implemented Interfaces:
    Loadable

    public final class ArcGISScene
    extends Object
    implements Loadable
    An ArcGISScene contains the layers of mapping data which are visualized in a SceneView.

    In an MVC architecture, an ArcGISScene represents the model and a SceneView represents the view.

    An ArcGISScene specifies how the geographic data is organized, and a SceneView renders the data on the screen and allows users to interact with it.

    An ArcGISScene contains a BaseMap, a Surface, usually one or more operational layers, and potentially tables:

    • A Basemap is a map layer that helps orient the user of the map. Typically it sits behind operational layers and shows features, such as roads and parcel boundaries, to give context to operational layers. Basemaps can also contain layers which are drawn over the top operational layers such as label layers.
    • A Surface is a collection of ElevationSource that determines how elevation is handled in the scene. It also contains the BackgroundGrid for the ArcGISScene.
    • An operational layer provides content that is of unique interest to the app and the task at hand, such as data about earthquakes, traffic, or weather for example. Its content might change frequently.
    • A table contains data potentially related to the Scene or one of the operational layers within the scene.

    An ArcGISScene can be manually created by adding layers or it can be derived from a web scene stored an an ArcGIS Portal. It can also be created from a JSON string with fromJson(String).

    Since:
    100.0.0 for JavaSE and 100.1.0 for Android
    See Also:
    Layer, Basemap
    • Constructor Detail

      • ArcGISScene

        public ArcGISScene()
        Creates an empty ArcGISScene instance.
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
      • ArcGISScene

        public ArcGISScene​(Basemap basemap)
        Creates an ArcGISScene instance which will contain just a basemap.
        Parameters:
        basemap - the Basemap used with this ArcGISScene
        Throws:
        IllegalArgumentException - if the basemap is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Basemap
      • ArcGISScene

        public ArcGISScene​(Basemap basemap,
                           Surface baseSurface)
        Creates an ArcGISScene instance which will contain a basemap and a base surface.
        Parameters:
        basemap - the Basemap used with this ArcGISScene
        baseSurface - the Surface to use as the base surface of this scene
        Throws:
        IllegalArgumentException - if the basemap is null
        IllegalArgumentException - if the base surface is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Basemap, Surface
      • ArcGISScene

        public ArcGISScene​(Basemap.Type basemapType)
        Creates an ArcGISScene instance which will contain just a basemap.
        Parameters:
        basemapType - the type of Basemap used with this ArcGISScene
        Throws:
        IllegalArgumentException - if the basemapType is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Basemap.Type
      • ArcGISScene

        public ArcGISScene​(ArcGISScene.SceneViewTilingScheme sceneViewTilingScheme)
        Creates an ArcGISScene instance which will use the specified tiling scheme for tiled layers.
        Parameters:
        sceneViewTilingScheme - the tiling scheme for tiled layers
        Throws:
        IllegalArgumentException - if the sceneViewTilingScheme is null
        Since:
        100.2.1
      • ArcGISScene

        public ArcGISScene​(PortalItem portalItem)
        Creates an ArcGISScene instance based on a PortalItem.

        If the portal item is not in LoadStatus.LOADED state it will be loaded automatically when this ArcGISScene instance is loaded.

        If the loaded portalItem is not of type PortalItem.Type.WEB_SCENE the ArcGISScene will fail to load.

        Parameters:
        portalItem - the PortalItem associated with this ArcGISScene instance
        Throws:
        IllegalArgumentException - if the portalItem is null
        Since:
        100.3.0
        See Also:
        PortalItem
      • ArcGISScene

        public ArcGISScene​(String webSceneUrl)
        Creates an ArcGISScene instance from a web scene URL. Example URLs:
        • http://www.arcgis.com/home/item.html?id=[web_scene_id]
        • http://www.arcgis.com/home/webscene/viewer.html?webscene=[web_scene_id]
        • http://www.arcgis.com/sharing/rest/content/items/[web_scene_id]/data
        • http://www.arcgis.com/sharing/rest/content/items/[web_scene_id]?f=pjson
        Parameters:
        webSceneUrl - the URL of the web scene on ArcGIS Online or an on-premises portal
        Throws:
        IllegalArgumentException - if the URL is null or empty
        IllegalArgumentException - if the URL does not match the basic URL types
        Since:
        100.3.0
    • Method Detail

      • fromJson

        public static ArcGISScene fromJson​(String json)
        Creates an ArcGISScene instance from a JSON string.
        Parameters:
        json - the JSON representation of an ArcGISScene
        Returns:
        an ArcGISScene instance deserialized from the JSON string
        Throws:
        IllegalArgumentException - if json is null or empty
        Since:
        100.3.0
      • getUnknownJson

        public Map<String,​Object> getUnknownJson()
        If this object was created from JSON, this method gets unknown data from the source JSON. Unknown JSON is a Map of values that were in the source JSON but are not known by the Runtime and therefore not exposed in the API.
        Returns:
        an unmodifiable Map containing unknown JSON data. The keys are Strings containing names. The types of the values depend on the types of tokens within the JSON as follows:
        • a Map<String, Object> represents an object in the JSON
        • a List<Object> represents an array in the JSON
        • a String represents a string in the JSON
        • a Double represents a number in the JSON
        • a Boolean represents true or false in the JSON
        • null represents null in the JSON
        Since:
        100.3.0
      • getUnsupportedJson

        public Map<String,​Object> getUnsupportedJson()
        If this object was created from JSON, this method gets unsupported data from the source JSON. Unsupported JSON is a Map of values that are supported by webscenes and known to the version of the webscene specification the API supports getVersion(), but are not explicitly exposed through the Runtime API.
        Returns:
        an unmodifiable Map containing unsupported JSON data. The keys are Strings containing names. The types of the values depend on the types of tokens within the JSON as follows:
        • a Map<String, Object> represents an object in the JSON
        • a List<Object> represents an array in the JSON
        • a String represents a string in the JSON
        • a Double represents a number in the JSON
        • a Boolean represents true or false in the JSON
        • null represents null in the JSON
        Since:
        100.3.0
      • getBasemap

        public Basemap getBasemap()
        Gets the Basemap of this ArcGISScene.
        Returns:
        the Basemap of this ArcGISScene, which provides the geographical context
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Basemap
      • setBasemap

        public void setBasemap​(Basemap basemap)
        Sets the Basemap of this ArcGISScene.
        Parameters:
        basemap - the Basemap of this ArcGISScene, which provides the geographical context
        Throws:
        IllegalArgumentException - if basemap is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Basemap
      • setBaseSurface

        public void setBaseSurface​(Surface baseSurface)
        Sets the base surface of this scene.
        Parameters:
        baseSurface - the base surface of this ArcGISScene
        Throws:
        IllegalArgumentException - if baseSurface is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Surface
      • getBaseSurface

        public Surface getBaseSurface()
        Gets the base surface of this ArcGISScene.
        Returns:
        the current base surface, can be null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Surface
      • getItem

        public Item getItem()
        Gets the associated Item of this ArcGISScene.
        Returns:
        the associated Item or null if this ArcGISScene is not associated with an Item
        Since:
        100.3.0
      • getTables

        public List<FeatureTable> getTables()
        Gets the tables in this ArcGISScene. The list is modifiable, that is, tables can be added and removed. Tables are not loaded by default. Tables are loaded internally when asynchronous operations like query are performed. Alternatively, they can be loaded by calling FeatureTable.loadAsync().
        Returns:
        a modifiable list of tables
        Since:
        100.3.0
      • setInitialViewpoint

        public void setInitialViewpoint​(Viewpoint viewpoint)
        Sets the initial viewpoint of the ArcGISScene.
        Parameters:
        viewpoint - the initial viewpoint, which determines the initial visible extent of this ArcGISScene when added to a SceneView
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        Viewpoint, setInitialViewpoint(com.esri.arcgisruntime.mapping.Viewpoint)
      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the SpatialReference of this ArcGISScene.
        Returns:
        the SpatialReference of this ArcGISScene
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
        See Also:
        SpatialReference
      • getSceneViewTilingScheme

        public ArcGISScene.SceneViewTilingScheme getSceneViewTilingScheme()
        Gets the tiling scheme to use for tiled layers.
        Returns:
        the tiling scheme to use for tiled layers
        Since:
        100.2.1
      • addBasemapChangedListener

        public void addBasemapChangedListener​(ArcGISScene.BasemapChangedListener listener)
        Adds a BasemapChangedListener to this ArcGISScene that gets invoked when the Basemap has changed.

        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.

        Parameters:
        listener - a BasemapChangedListener that gets invoked when the Basemap has changed
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
      • removeBasemapChangedListener

        public boolean removeBasemapChangedListener​(ArcGISScene.BasemapChangedListener listener)
        Removes a BasemapChangedListener from this ArcGISScene.
        Parameters:
        listener - the BasemapChangedListener to remove
        Returns:
        true if the BasemapChangedListener has been removed, otherwise false
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0 for JavaSE and 100.1.0 for Android
      • getLoadSettings

        public LoadSettings getLoadSettings()
        Gets a load settings properties object that can be used to make changes to how feature layers loaded by this scene are rendered.
        Returns:
        the load settings
        Since:
        100.2.0
        See Also:
        LoadSettings
      • setLoadSettings

        public void setLoadSettings​(LoadSettings loadSettings)
        Sets the load settings for this map. The load settings change how feature layers loaded by this scene are rendered.
        Parameters:
        loadSettings - the load settings
        Throws:
        IllegalArgumentException - if loadSettings is null
        Since:
        100.2.0
        See Also:
        LoadSettings
      • getVersion

        public String getVersion()
        Gets the version of this ArcGISScene. This is the current version of the web scene specification supported by the Runtime API.
        Returns:
        the version of this ArcGISScene
        Since:
        100.3.0
      • 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
      • 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 loadAsync or retryLoadAsync.

        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.
      • cancelLoad

        public void cancelLoad()
        Description copied from interface: Loadable
        Cancels a pending load operation.

        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
      • 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
      • retryLoadAsync

        public void retryLoadAsync()
        Description copied from interface: Loadable
        Tries to reload the metadata of the loadable resource asynchronously, but only if the resource failed to load previously (LoadStatus.FAILED_TO_LOAD state) or wasn't loaded to begin with ( LoadStatus.NOT_LOADED state).

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

        Specified by:
        retryLoadAsync in interface Loadable
      • 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, use the Loadable.addLoadStatusChangedListener(LoadStatusChangedListener) method instead.

        Specified by:
        addDoneLoadingListener in interface Loadable
        Parameters:
        listener - a Runnable that is invoked upon completion of the load operation
      • 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
      • 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
      • 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