public abstract class

Renderer

extends Object
implements JsonSerializable
java.lang.Object
   ↳ com.esri.arcgisruntime.symbology.Renderer
Known Direct Subclasses

Class Overview

Base class for Renderers and used to draw Features or Graphics to a GeoView.

Renderers can be set to a setRenderer(Renderer) or a setRenderer(Renderer), which hold Features or Graphics respectively. Once a Renderer is set, the properties of that Renderer will determine how those Features or Graphics are drawn to the GeoView. A Renderer can specify that all Features or Graphics will be drawn with the same Symbol or with a different Symbol.

When both a Renderer and Symbol are set, the Symbol takes precedence.

GraphicsOverlays can contain Graphics with different geometry dimensions. However, a Renderer can only be used to draw symbols with the same dimension of geometry, therefore a Renderer used with a graphics overlay can only draw graphics of a single geometry dimension.

Properties of a Renderer:

  • RotationType, how a Symbol is rotated along the x-axis or y-axis.
  • RotationExpression, a value that specifies the angle of rotation.
  • Symbol, used to draw a Feature or Graphic

Summary

Nested Classes
class Renderer.SceneProperties This represents renderer properties applicable only to an ArcGISScene. 
Public Methods
static Renderer fromJson(String json)
Creates a Renderer instance from a JSON string.
String getRotationExpression()
Gets a value that specifies the angle of rotation.
RotationType getRotationType()
Gets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.
Renderer.SceneProperties getSceneProperties()
Gets the renderer scene properties object that can be used to make changes to how GeoElement are displayed in a SceneView.
abstract Symbol getSymbol(Graphic graphic)
Gets the Symbol used to display the given Graphic.
abstract Symbol getSymbol(Feature feature)
Gets the Symbol used to display the given Feature.
Map<String, Object> getUnknownJson()
If this object was created from JSON, this method gets unknown data from the source JSON.
Map<String, Object> getUnsupportedJson()
If this object was created from JSON, this method gets unsupported data from the source JSON.
void setRotationExpression(String rotationExpression)
Sets the rotation expression.
void setRotationType(RotationType rotationType)
Sets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.
String toJson()
Serializes this object to a JSON string.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.esri.arcgisruntime.io.JsonSerializable

Public Methods

public static Renderer fromJson (String json)

Creates a Renderer instance from a JSON string.

Parameters
json a JSON string that represents a Renderer
Returns
  • a Renderer instance
Throws
IllegalArgumentException if json is null or empty

public String getRotationExpression ()

Gets a value that specifies the angle of rotation.

Default value is null.

Returns
  • the rotation expression

public RotationType getRotationType ()

Gets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.

Default value is UNKNOWN.

Returns
  • the rotation type of this Symbol

public Renderer.SceneProperties getSceneProperties ()

Gets the renderer scene properties object that can be used to make changes to how GeoElement are displayed in a SceneView.

Returns
  • the renderer properties applicable only to an ArcGISScene

public abstract Symbol getSymbol (Graphic graphic)

Gets the Symbol used to display the given Graphic.

Parameters
graphic the Graphic to get a Symbol from, not null
Returns
  • the Symbol of the Graphic that was passed
Throws
IllegalArgumentException if Graphic is null

public abstract Symbol getSymbol (Feature feature)

Gets the Symbol used to display the given Feature.

Parameters
feature the Feature to get a Symbol from, not null
Returns
  • the Symbol of the Feature that was passed
Throws
IllegalArgumentException if Feature is null

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

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 webmaps and known to the version of the webmap specification the API supports (see system requirements), 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

public void setRotationExpression (String rotationExpression)

Sets the rotation expression.

This is a constant value or an expression that derives the angle of rotation based on the Feature attribute value. When an attribute name is specified in the rotation expression, it's enclosed in square brackets, for example: [Rotation].

Example of setting a rotation expression with a SimpleRenderer:

 GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
 mapView.getGraphicsOverlays().add(graphicsOverlay);
 
 Point randomPoint = new Point(2000000, 2000000);
 Graphic graphic = new Graphic(randomPoint);
 graphic.getAttributes().put("Rotation", 45);
 graphicsOverlay.getGraphics().add(graphic);

 SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.BLUE, 5, SimpleMarkerSymbol.Style.TRIANGLE);
 SimpleRenderer simpleRenderer = new SimpleRenderer(symbol);
 simpleRenderer.setRotationExpression("[Rotation]");
 graphicsOverlay.setRenderer(simpleRenderer);
 

Parameters
rotationExpression the new rotation expression

public void setRotationType (RotationType rotationType)

Sets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.

If ARITHMETIC, rotation is along the x-axis, with positive rotation being counter-clockwise.

If GEOGRAPHIC, rotation is along the y-axis, with positive rotation being clockwise.

Parameters
rotationType the new rotation type for this Symbol, not null
Throws
IllegalArgumentException if input is null

public String toJson ()

Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.

Returns
  • a JSON string