java.lang.Object
com.esri.arcgisruntime.symbology.Renderer
All Implemented Interfaces:
JsonSerializable
Direct Known Subclasses:
ClassBreaksRenderer, DictionaryRenderer, HeatmapRenderer, SimpleRenderer, UniqueValueRenderer, UnsupportedRenderer

public abstract class Renderer extends Object implements JsonSerializable
A base class for renderers that use a collection of one or more symbols to display features in a Layer or graphics in a GraphicsOverlay.

If the renderer contains more than a single symbol, it uses the rules to determine the symbol to apply to each geoelement, based on one or several attribute values. There are three basic types of renderers:

  • SimpleRenderer - simple renderers use a single symbol for all geoelements.
  • UniqueValueRenderer - unique value renders define a different symbol for each unique value of an attribute.
  • ClassBreaksRenderer - class break renderers define a different symbol for each range of numeric values.

To symbolize and display the geoelements, set the renderer with FeatureLayer.setRenderer(Renderer) or GraphicsOverlay.setRenderer(Renderer).

A GraphicsOverlay can contain graphics with different geometry dimensions, such as a Point and Polygon. A Renderer, however, can only provide symbols with one geometry dimension. Therefore, if you apply a renderer to a graphics overlay, only graphics with the specified geometry dimension are displayed. All other graphics are not visible.

If you apply a Symbol directly to a graphic, the symbol displays in preference to the GraphicsOverlay.rendererProperty().

For raster data, rendering is handled by a RasterRenderer.

Since:
100.0.0
See Also:
  • Method Details

    • fromJson

      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
      Since:
      100.0.0
    • toJson

      public String toJson()
      Description copied from interface: JsonSerializable
      Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.
      Specified by:
      toJson in interface JsonSerializable
      Returns:
      a JSON string
    • getUnknownJson

      public Map<String,Object> getUnknownJson()
      Description copied from interface: JsonSerializable
      Gets unknown data from the source JSON.

      Unknown JSON is a Map of values not defined in the ArcGIS specification used to create this object but found in the source JSON. If the object is written back to JSON, any unknown JSON data is not persisted. The ArcGIS specification may be for a web map, web scene, REST API, and so on.

      Specified by:
      getUnknownJson in interface JsonSerializable
      Returns:
      an unmodifiable Map containing unknown data from the source JSON
    • getUnsupportedJson

      public Map<String,Object> getUnsupportedJson()
      Description copied from interface: JsonSerializable
      Gets unsupported data from the source JSON.

      Unsupported JSON is a Map of values defined in the ArcGIS specification used to create this object but not currently used in this API. If the object is written back to JSON, any unsupported JSON data is persisted. The ArcGIS specification may be from a web map, web scene, REST API, and so on.

      Specified by:
      getUnsupportedJson in interface JsonSerializable
      Returns:
      an unmodifiable Map containing unsupported data from the source JSON
    • getSymbol

      public Symbol getSymbol(DynamicEntity dynamicEntity)
      Returns the symbol that is used to visualize the given dynamic entity.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      dynamicEntity - the dynamic entity
      Returns:
      a Symbol, or null if none
      Throws:
      NullPointerException - if dynamicEntity is null
      Since:
      200.1.0
    • getSymbol

      public Symbol getSymbol(DynamicEntity dynamicEntity, boolean applyAttributeOverrides)
      Returns the symbol that is used to visualize the given dynamic entity with override attributes from the renderer.

      If applyAttributeOverrides is set to true, this method will get the symbol from the renderer and override the symbol properties with the overrides available on the renderer. These include visual variable size, color, opacity and rotation. If the override expression or attributes contain any information not known to either the renderer or dynamic entity (such as "scale"), that override will not be applied. If the override attributes are applied successfully, a symbol with overridden properties will be returned else the original symbol will be returned.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      dynamicEntity - the dynamic entity
      applyAttributeOverrides - if set to true, this applies the override attributes from the renderer to the symbol
      Returns:
      a Symbol, or null if none
      Throws:
      NullPointerException - if dynamicEntity is null
      Since:
      200.1.0
    • getSymbol

      public Symbol getSymbol(DynamicEntityObservation dynamicEntityObservation)
      Returns the symbol that is used to visualize the given dynamic entity observation.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      dynamicEntityObservation - the dynamic entity observation
      Returns:
      a Symbol, or null if none
      Throws:
      NullPointerException - if dynamicEntityObservation is null
      Since:
      200.1.0
    • getSymbol

      public Symbol getSymbol(DynamicEntityObservation dynamicEntityObservation, boolean applyAttributeOverrides)
      Returns the symbol that is used to visualize the given dynamic entity observation with override attributes from the renderer.

      If applyAttributeOverrides is set to true, this method will get the symbol from the renderer and override the symbol properties with the overrides available on the renderer. These include visual variable size, color, opacity and rotation. If the override expression or attributes contain any information not known to either the renderer or observation (such as "scale"), that override will not be applied. If the override attributes are applied successfully, a symbol with overridden properties will be returned else the original symbol will be returned.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      dynamicEntityObservation - the dynamic entity observation
      applyAttributeOverrides - if set to true, this applies the override attributes from the renderer to the symbol
      Returns:
      a Symbol, or null if none
      Throws:
      NullPointerException - if dynamicEntityObservation is null
      Since:
      200.1.0
    • getSymbol

      public abstract Symbol getSymbol(Feature feature)
      Returns the symbol that is used to visualize the given feature.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      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
      Since:
      100.0.0
    • getSymbol

      public abstract Symbol getSymbol(Graphic graphic)
      Returns the symbol that is used to visualize the given graphic.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      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
      Since:
      100.0.0
    • getSymbol

      public Symbol getSymbol(Feature feature, boolean applyAttributeOverrides)
      Returns the symbol that is used to visualize the given feature with override expressions from renderer.

      If applyAttributeOverrides is set to true, this method will get the symbol from the renderer and override the symbol properties with the overrides available on the renderer. These include visual variable size, color, opacity and rotation. If the override expression or attributes contain any information not known to either the renderer or observation (such as "scale"), that override will not be applied. If the override attributes are applied successfully, a symbol with overridden properties will be returned otherwise the original symbol will be returned.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      feature - the Feature to get a Symbol from, not null
      applyAttributeOverrides - true to apply override attributes from renderer
      Returns:
      the Symbol of the Feature that was passed
      Throws:
      IllegalArgumentException - if feature is null
      Since:
      100.5.0
    • getSymbol

      public Symbol getSymbol(Graphic graphic, boolean applyAttributeOverrides)
      Returns the symbol that is used to visualize the given graphic with override expressions from renderer.

      If applyAttributeOverrides is set to true, this method will get the symbol from the renderer and override the symbol properties with the overrides available on the renderer. These include visual variable size, color, opacity and rotation. If the override expression or attributes contain any information not known to either the renderer or observation (such as "scale"), that override will not be applied. If the override attributes are applied successfully, a symbol with overridden properties will be returned otherwise the original symbol will be returned.

      If the renderer is a DictionaryRenderer and its associated DictionarySymbolStyle references a style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a web style), this method returns null. If the layer has rendered and the symbol is already drawn on the view, this method returns a valid MultilayerSymbol. If you want to get the symbol before the layer is rendered, use DictionarySymbolStyle.getSymbolAsync(Map).

      Parameters:
      graphic - the Graphic to get a Symbol from, not null
      applyAttributeOverrides - true to apply override attributes from renderer
      Returns:
      the Symbol of the Graphic that was passed
      Throws:
      IllegalArgumentException - if graphic is null
      Since:
      100.5.0
    • getRotationType

      public RotationType getRotationType()
      Gets whether the rotation calculated from the getRotationExpression() is interpreted as arithmetic or geographic.

      The options are:

      RotationType.ARITHMETIC if an error occurs.

      Returns:
      the rotation type of this Symbol
      Since:
      100.0.0
      See Also:
    • setRotationType

      public void setRotationType(RotationType rotationType)
      Sets whether the rotation calculated from the getRotationExpression() is interpreted as arithmetic or geographic.

      The options are:

      Parameters:
      rotationType - the new rotation type for this Symbol, not null
      Throws:
      IllegalArgumentException - if input is null
      Since:
      100.0.0
    • getRotationExpression

      public String getRotationExpression()
      Gets the expression describing how attributes values are translated into a rotation to be applied to the GeoElement.

      When an attribute name is specified in the rotation expression, it is enclosed in square brackets, for example: [Rotation].

      Returns:
      the rotation expression
      Since:
      100.0.0
      See Also:
    • setRotationExpression

      public void setRotationExpression(String rotationExpression)
      Sets the expression describing how attributes values are translated into a rotation to be applied to the GeoElement.

      When an attribute name is specified in the rotation expression, it is 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
      Since:
      100.0.0
      See Also:
    • getSceneProperties

      public Renderer.SceneProperties getSceneProperties()
      Gets the scene view properties for the renderer.

      This can be used to make changes to how a GeoElement is displayed in a SceneView.

      Returns:
      the scene view properties for the renderer, which are applicable only to an ArcGISScene
      Since:
      100.0.0