public final class

SceneView

extends GeoView
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.esri.arcgisruntime.mapping.view.GeoView
         ↳ com.esri.arcgisruntime.mapping.view.SceneView

Class Overview

A SceneView renders the data from an ArcGISScene in an Android layout, and allows users to interact with the scene.

SceneView indirectly inherits from android's ViewGroup; in a Model View Controller (MVC) architecture, use it to represent the MVC view, and the ArcGISScene to represent the MVC model. You can define the size and layout properties of a SceneView in layout XML, or create it programmatically. In either case, call setScene to set the content to be displayed. The SceneView will automatically load the scene, its surface, basemap, operational layers, and display their contents on screen. Refer to the ArcGISScene class for more information.

SceneView inherits from GeoView and adds 3D specific methods for scene navigation that set the viewpoint on the scene by setting a Camera. For example, setViewpointCamera(Camera). More setViewpointCamera methods are available, including overloads where an animation duration can be specified. Use isNavigating or NavigationChangedListener to determine if navigation is ongoing or completed. Once navigation is complete, get the new camera from getCurrentViewpointCamera().

By default, you can pan, zoom, and rotate the scene using a set of standard gestures like double-tap and pinch; for more details see DefaultSceneViewOnTouchListener. You can also override standard gestures by creating your own touch listener class. To do this, either implement android.view.View.OnTouchListener, or inherit from DefaultSceneViewOnTouchListener, and pass an instance of your touch listener class to setOnTouchListener.

Summary

[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
SceneView(Context context)
Creates a SceneView using the given Context.
SceneView(Context context, AttributeSet attrs)
Creates a SceneView using the given Context, called when the SceneView is inflated from XML.
Public Methods
int getAmbientLightColor()
Gets the color of the ambient light.
ListenableList<AnalysisOverlay> getAnalysisOverlays()
Gets a modifiable list of the analysis overlays.
AtmosphereEffect getAtmosphereEffect()
Gets the atmosphere effect on the scene view.
CameraController getCameraController()
Gets the current camera controller.
Camera getCurrentViewpointCamera()
Gets the current viewpoint camera.
static long getMemoryLimit()
Gets the memory limit in bytes, that defines the total amount of memory a process can use to render scene data.
ArcGISScene getScene()
Gets the ArcGISScene displayed in this view.
SpatialReference getSpatialReference()
Gets the SpatialReference of this GeoView.
LightingMode getSunLighting()
Gets the type of sun lighting applied to the scene view.
Calendar getSunTime()
Gets the time that indicates the position of the sun.
LocationToScreenResult locationToScreen(Point location)
Returns the result of converting a scene location to a screen point contained in a LocationToScreenResult.
boolean onTouchEvent(MotionEvent event)
Point screenToBaseSurface(Point screenPoint)
Returns the scene location of a screen point on the base surface i.e.
ListenableFuture<Point> screenToLocationAsync(Point screenPoint)
Converts a screen coordinate to a coordinate within the scene view's spatial reference asynchronously.
void setAmbientLightColor(int color)
Sets the color of the ambient light.
void setAtmosphereEffect(AtmosphereEffect atmosphereEffect)
Sets the effect to be applied to the scene view's atmosphere.
void setCameraController(CameraController cameraController)
Sets the camera controller.
static void setMemoryLimit(long memoryLimitBytes)
Sets a memory limit in bytes, that defines the total amount of memory a process can use to render scene data.
void setOnTouchListener(View.OnTouchListener onTouchListener)
Sets the listener that handles touch gestures for this SceneView.
void setScene(ArcGISScene scene)
Sets the ArcGISScene to be displayed in this view.
void setSunLighting(LightingMode lightingMode)
Sets the type of sun lighting to be applied to the scene view.
void setSunTime(Calendar sunTime)
Sets the position of the sun based on time.
void setViewpointCamera(Camera camera)
Sets the viewpoint based on the given camera.
ListenableFuture<Boolean> setViewpointCameraAsync(Camera camera, float animationDuration)
Sets the viewpoint asynchronously with a specified animation duration.
ListenableFuture<Boolean> setViewpointCameraAsync(Camera camera)
Sets the viewpoint asynchronously, based on the given camera.
void setZOrderMediaOverlay(boolean isMediaOverlay)
Controls whether the SceneView is placed on top of another SceneView, MapView, or SurfaceView in the window (but still behind the window itself).
Protected Methods
final void interactionActivateFlick()
Activates a camera flick by performing an inertia based pan in the direction of the most recent pan operations.
final void interactionPan(float deltaX, float deltaY)
Pan the scene view relative to the screen point origin, set by calling interactionSetInteractionOrigin.
final void interactionPitch(double pitchDelta)
Rotate the camera around the origin that's set by interactionSetInteractionOrigin, only the pitch angle of the camera is updated, not the heading.
final void interactionRotate(double rotationDelta)
Rotate the camera around the origin that's set by interactionSetInteractionOrigin, only the heading angle of the camera is updated, not the pitch.
final void interactionSetInteracting(boolean interacting)
Sets if the view is being interacted with or not.
final void interactionSetInteractionOrigin(float x, float y)
Sets the interaction origin screen point, subsequent interactions pass delta changes from this point.
final void interactionZoomInAnimated(float x, float y)
Animated zoom in used for scene interaction e.g.
final void interactionZoomOutAnimated(float x, float y)
Animated zoom out used for scene interaction e.g.
final void interactionZoomToOrigin(double factor)
Zoom the camera towards or away from the origin that's set by interactionSetInteractionOrigin.
void onDrawFrame(GL10 gl)
Called to draw the current frame.
[Expand]
Inherited Methods
From class com.esri.arcgisruntime.mapping.view.GeoView
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public SceneView (Context context)

Creates a SceneView using the given Context. Call this constructor when creating a SceneView programmatically.

Parameters
context the Context the view is running in

public SceneView (Context context, AttributeSet attrs)

Creates a SceneView using the given Context, called when the SceneView is inflated from XML.

Parameters
context the Context the view is running in
attrs the attributes of the XML tag that is inflating the view

Public Methods

public int getAmbientLightColor ()

Gets the color of the ambient light.

Returns
  • an integer representing the color of the ambient light as 0xAARRGGBB

public ListenableList<AnalysisOverlay> getAnalysisOverlays ()

Gets a modifiable list of the analysis overlays. Add or remove analysis overlays from this list to modify what is displayed. The list returned can be empty but not null. You can add listeners to this list to monitor changes to the list.

An analysis overlay can only be in the list once.

Returns
  • the analysis overlays

public AtmosphereEffect getAtmosphereEffect ()

Gets the atmosphere effect on the scene view. The default value is HORIZON_ONLY.

Returns
  • the atmosphere effect on the scene view

public CameraController getCameraController ()

Gets the current camera controller. The default is an instance of GlobeCameraController.

Returns
  • the current camera controller

public Camera getCurrentViewpointCamera ()

Gets the current viewpoint camera.

Returns
  • the current viewpoint camera

public static long getMemoryLimit ()

Gets the memory limit in bytes, that defines the total amount of memory a process can use to render scene data. Note, the default value is determined upon initialization of the first SceneView instance that is being created by the process. Before any SceneView instance has been created, zero is returned. For some use cases you might want to choose to set a custom limit. See setMemoryLimit(long) for details.

The default value is determined as follows:

  • If getLargeMemoryClass() is greater than 1 gigabyte, this value is used.
  • Otherwise, check whether 45% of total system memory (totalMem) is less than 1 gigabyte. If so, this value is used.
  • Otherwise, use 1 gigabyte as the memory limit.

Returns
  • the memory limit in bytes, that defines the total amount of memory a process can use to render scene data

public ArcGISScene getScene ()

Gets the ArcGISScene displayed in this view.

Returns
  • the ArcGISScene

public SpatialReference getSpatialReference ()

Gets the SpatialReference of this GeoView. The SpatialReference of a GeoView defines how the coordinates of the data correspond to locations in the real world.

Returns
  • the SpatialReference of this GeoView

public LightingMode getSunLighting ()

Gets the type of sun lighting applied to the scene view.

Returns
  • the type of sun lighting, default is NO_LIGHT

public Calendar getSunTime ()

Gets the time that indicates the position of the sun.

Returns
  • the time that indicates the position of the sun, default is Fri Sep 22 2000 12:00:00 GMT+0000.

public LocationToScreenResult locationToScreen (Point location)

Returns the result of converting a scene location to a screen point contained in a LocationToScreenResult.

Parameters
location the scene location to convert to a screen point
Returns
  • the location to screen result
Throws
IllegalArgumentException if location is null

public boolean onTouchEvent (MotionEvent event)

public Point screenToBaseSurface (Point screenPoint)

Returns the scene location of a screen point on the base surface i.e. ignoring any elevation.

Parameters
screenPoint the screen point
Returns
  • the scene location on the base surface
Throws
IllegalArgumentException if screenPoint is null

public ListenableFuture<Point> screenToLocationAsync (Point screenPoint)

Converts a screen coordinate to a coordinate within the scene view's spatial reference asynchronously. This could be on the surface or on a feature such as a building or aircraft.

Parameters
screenPoint the screen point to use
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result
Throws
IllegalArgumentException if screenPoint is null

public void setAmbientLightColor (int color)

Sets the color of the ambient light.

Parameters
color the color of the ambient light as 0xAARRGGBB

public void setAtmosphereEffect (AtmosphereEffect atmosphereEffect)

Sets the effect to be applied to the scene view's atmosphere.

Parameters
atmosphereEffect the atmosphere effect
Throws
IllegalArgumentException if atmosphereEffect is null

public void setCameraController (CameraController cameraController)

Sets the camera controller. The default is an instance of GlobeCameraController.

Parameters
cameraController camera controller
Throws
IllegalArgumentException if cameraController is null

public static void setMemoryLimit (long memoryLimitBytes)

Sets a memory limit in bytes, that defines the total amount of memory a process can use to render scene data.

The memory limit is set by default and this should be sufficient for most use cases. For more details of how the default limit is determined see getMemoryLimit(). For some use cases you might want to choose to override the default to increase or reduce the limit. In this case, you need to set this value before instantiating any SceneView objects. If you choose to override this limit it is recommended to take into account the device's recommended memory limits that can be obtained from getLargeMemoryClass().

Parameters
memoryLimitBytes the memory limit in bytes, that defines the total amount of memory a process can use to render scene data
Throws
IllegalArgumentException if memoryLimitBytes is zero or negative

public void setOnTouchListener (View.OnTouchListener onTouchListener)

Sets the listener that handles touch gestures for this SceneView. For more information about the default gestures, see DefaultSceneViewOnTouchListener.

To change the way that the SceneView responds to default gestures, for example by performing an identify on a single-tap, or disabling interactive panning, use this method to set a custom touch listener onto the SceneView.

The easiest way to change only some of the default gestures is to create a custom touch listener that inherits DefaultSceneViewOnTouchListener, and override only the methods you want to change. Alternatively, directly implement the android.view.View.OnTouchListener interface, and provide the behaviour for all touch events. Then pass an instance to this method to replace the default listener with your custom listener.

Parameters
onTouchListener the new listener that will handle touch events for this SceneView
Throws
IllegalArgumentException if onTouchListener is null

public void setScene (ArcGISScene scene)

Sets the ArcGISScene to be displayed in this view.

Parameters
scene the new ArcGISScene, can be null

public void setSunLighting (LightingMode lightingMode)

Sets the type of sun lighting to be applied to the scene view. Note that LIGHT_AND_SHADOWS is currently not supported on Android and behaves the same as setting LIGHT.

Parameters
lightingMode the lighting mode to be applied for this scene view
Throws
IllegalArgumentException if lightingMode is null

public void setSunTime (Calendar sunTime)

Sets the position of the sun based on time.

Parameters
sunTime the time to use to calculate the sun's position
Throws
IllegalArgumentException if sunTime is null

public void setViewpointCamera (Camera camera)

Sets the viewpoint based on the given camera.

Parameters
camera the camera to set
Throws
IllegalArgumentException if camera is null

public ListenableFuture<Boolean> setViewpointCameraAsync (Camera camera, float animationDuration)

Sets the viewpoint asynchronously with a specified animation duration.

Parameters
camera the new viewpoint camera
animationDuration the animation duration in seconds
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result. Add a listener to the future to be notified when animation is finished. The result of the future indicates if the operation completed successfully (true) or has been interrupted before the given camera location has been reached (false), for example if the user interrupts the animation by interacting with the SceneView.
Throws
IllegalArgumentException if the camera is null

public ListenableFuture<Boolean> setViewpointCameraAsync (Camera camera)

Sets the viewpoint asynchronously, based on the given camera. This method uses the standard animation duration; alternatively use setViewpointCameraAsync(Camera, float) to control the animation duration.

Parameters
camera the new viewpoint camera
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result. Add a listener to the future to be notified when animation is finished. The result of the future indicates if the operation completed successfully (true) or has been interrupted before the given camera location has been reached (false), for example if the user interrupts the animation by interacting with the SceneView.
Throws
IllegalArgumentException if the camera is null

public void setZOrderMediaOverlay (boolean isMediaOverlay)

Controls whether the SceneView is placed on top of another SceneView, MapView, or SurfaceView in the window (but still behind the window itself). This could be used to place a SceneView on top of a MapView for example. Note that this must be set before the SceneView's containing window is attached to the window manager.

Parameters
isMediaOverlay true if this SceneView is placed on top of another regular surface view, otherwise false

Protected Methods

protected final void interactionActivateFlick ()

Activates a camera flick by performing an inertia based pan in the direction of the most recent pan operations.

This method triggers an automated inertia based pan as a result of previous calls to interactionSetInteractionOrigin and interactionPan. The direction and velocity of the inertia is calculated using a weighted average of the most recent pan operations. Note that flick will not activate if there were no recent pan operations or the velocity of those pans were deemed too slow.

protected final void interactionPan (float deltaX, float deltaY)

Pan the scene view relative to the screen point origin, set by calling interactionSetInteractionOrigin.

Parameters
deltaX the x delta in screen coordinates
deltaY the y delta in screen coordinates

protected final void interactionPitch (double pitchDelta)

Rotate the camera around the origin that's set by interactionSetInteractionOrigin, only the pitch angle of the camera is updated, not the heading.

Parameters
pitchDelta change in pitch

protected final void interactionRotate (double rotationDelta)

Rotate the camera around the origin that's set by interactionSetInteractionOrigin, only the heading angle of the camera is updated, not the pitch.

Parameters
rotationDelta change in heading

protected final void interactionSetInteracting (boolean interacting)

Sets if the view is being interacted with or not.

Parameters
interacting true to indicate interaction is happening, otherwise false

protected final void interactionSetInteractionOrigin (float x, float y)

Sets the interaction origin screen point, subsequent interactions pass delta changes from this point.

Parameters
x the x value of the screen coordinate
y the y value of the screen coordinate

protected final void interactionZoomInAnimated (float x, float y)

Animated zoom in used for scene interaction e.g. double tap.

Parameters
x the x value of the screen coordinate to zoom in on
y the y value of the screen coordinate to zoom in on

protected final void interactionZoomOutAnimated (float x, float y)

Animated zoom out used for scene interaction e.g. multi-pointer tap tap.

Parameters
x the x value of the screen coordinate to zoom out on
y the y value of the screen coordinate to zoom out on

protected final void interactionZoomToOrigin (double factor)

Zoom the camera towards or away from the origin that's set by interactionSetInteractionOrigin.

Parameters
factor the factor to zoom by

protected void onDrawFrame (GL10 gl)

Called to draw the current frame.

Parameters
gl the GL interface