java.lang.Object
com.esri.arcgisruntime.symbology.Symbol
All Implemented Interfaces:
JsonSerializable
Direct Known Subclasses:
CompositeSymbol, FillSymbol, LineSymbol, MarkerSymbol, MultilayerSymbol, SceneSymbol

public class Symbol extends Object implements JsonSerializable
A symbol defines the appearance of features and graphics that are displayed in a GeoView.

Symbol is the base class for a number of different symbols, such as MarkerSymbol, LineSymbol, FillSymbol abd MultilayerSymbol, which are sub-classes for more specialized symbols.

You can specify the symbology of a single graphic using Graphic.setSymbol(Symbol). Alternatively, you can create a Renderer that contains a collection of symbols and rules. Each rule determines which symbol is applied to a graphic or feature depending on its attribute values. To symbolize graphics, apply a renderer to the GraphicsOverlay, and to symbolize features, apply the renderer to FeatureLayer.

There are two models for defining symbols in your map: simple and advanced (multilayer). In general, simple symbols are single-layer symbols that provide basic representations, such as marker, line, fill, text, or picture. Advanced symbols are composed of one or several layers that can be defined individually and combined to create complex representations.

These are described as follows:

  • Simple symbols follow the web map specification and you work with them through the simple symbol classes. These are also the symbols you get from web maps or from feature services when advanced symbology is turned off. Simple symbols can be created for points (MarkerSymbol), lines (LineSymbol), and polygons (FillSymbol). Each of the simple symbol types provides an enumeration of pre-defined styles that can be applied to the symbol.
  • Advanced symbols, accessed through multilayer symbol classes, follow the ArcGIS Pro symbol model. These symbols come from feature services (that use advanced symbology), mobile style files, the dictionary renderer, and mobile map packages. You can also build your own advanced symbols for points, lines, and polygons.

Simple symbology is the symbology of the web map. When authoring maps in ArcGIS Pro as web maps, your multilayer symbols will be converted to simple symbols. In general, point symbols are converted to picture marker symbols optimized for the web, and line and polygon symbols are simplified while representing the original symbol as closely as possible. If you are authoring a feature service from ArcGIS Pro or ArcGIS Desktop, however, both the original symbols and the simplified symbols are stored. This allows clients that support advanced symbols to render the features as originally symbolized, while those that do not support advanced symbols (such as ArcGIS Online Map Viewer) can use the simple symbols for display. Having both sets of symbols allows you to retain the advanced symbology where available and still share the feature service as widely as possible.

If your app works primarily with web maps that you want to look the same throughout the platform, your app should use the simple symbols API. Otherwise, make sure your users understand that advanced symbols render slightly differently on clients that don't support advanced symbology.

If your maps are used only with this API and ArcGIS Pro, you can use advanced symbols exclusively. When rendered by this API, advanced symbols are vectorized. This allows them to scale better on devices with high resolution screens.

You can call LoadSettings.setUseAdvancedSymbology(boolean) to control whether the map uses advanced symbols (when available) or always renders with simple symbols.

A swatch is an image that is used to display this symbol. Properties of a swatch include:

  • Height, length of image from bottom to top side.
  • Width, length of image from left to right side.
  • Dots Per Inch (dpi), the resolution of the image.
  • Color, interior color of the image.
  • Geometry, shape of the image.

Depending on the Geometry of a Graphic or Feature different types of symbols will be used.

Since:
100.0.0
See Also:
  • Method Details

    • fromJson

      public static Symbol fromJson(String json)
      Creates a Symbol instance from a JSON string.
      Parameters:
      json - a JSON string that represents a Symbol
      Returns:
      a Symbol 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
    • createSwatchAsync

      @Deprecated(since="200.0.0", forRemoval=true) public ListenableFuture<Image> createSwatchAsync(int width, int height, float screenScale, int backgroundColor, Geometry geometry)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a scaled swatch asynchronously from a Geometry object. The specified geometry should be in device-independent pixels (DIPs) with the point {0,0} corresponding to the center point of the swatch image. The x-axis increases toward the right hand side of the swatch image. The y-axis increases towards the top of the swatch image. The geometry type should correspond to the symbol type. For example, Points for MarkerSymbols, Polylines for LineSymbols and Polygons for FillSymbols. The spatial reference of the geometry is ignored.
      Parameters:
      width - width of the image in dp
      height - height of the image in dp
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      backgroundColor - background color of the swatch as 0xAARRGGBB
      geometry - geometry of the swatch
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if geometry is null
      IllegalArgumentException - if width is less than 1
      IllegalArgumentException - if height is less than 1
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      100.3.0
    • createSwatchAsync

      public ListenableFuture<Image> createSwatchAsync(int width, int height, float screenScale, Color backgroundColor, Geometry geometry)
      Creates a swatch image using the provided geometry, width, height, screen scale, and optional background color.

      The specified geometry should be in device-independent pixels (DIPs) with the point {0,0} corresponding to the center point of the swatch image. The x-axis increases toward the right hand side of the swatch image. The y-axis increases towards the top of the swatch image. The geometry type should correspond to the symbol type. For example, Points for MarkerSymbols, Polylines for LineSymbols and Polygons for FillSymbols. The spatial reference of the geometry is ignored.

      Parameters:
      width - the width of the swatch in device-independent pixels (DIPs)
      height - the height of the swatch in device-independent pixels (DIPs)
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      backgroundColor - background color of the swatch
      geometry - geometry of the swatch
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if geometry is null
      IllegalArgumentException - if width is less than 1
      IllegalArgumentException - if height is less than 1
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      200.0.0
    • createSwatchAsync

      @Deprecated(since="200.0.0", forRemoval=true) public ListenableFuture<Image> createSwatchAsync(int width, int height, int backgroundColor, Geometry geometry)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a swatch asynchronously from a Geometry object. The specified geometry should be in device-independent pixels (DIPs) with the point {0,0} corresponding to the center point of the swatch image. The x-axis increases toward the right hand side of the swatch image. The y-axis increases towards the top of the swatch image. The geometry type should correspond to the symbol type. For example, Points for MarkerSymbols, Polylines for LineSymbols and Polygons for FillSymbols. The spatial reference of the geometry is ignored.

      If this method is called on the JavaFX application thread then the swatch will be scaled based on the primary screen making the swatch appear the same size as it would in the GeoView. If not called on the JavaFX thread a default scale of 1.0 will be used which may result in a swatch bigger or smaller than the symbol would appear in the view.

      Parameters:
      width - width of the image in dp
      height - height of the image in dp
      backgroundColor - background color of the swatch as 0xAARRGGBB
      geometry - geometry of the swatch, not null
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if geometry is null, or if either width or height are less than 1
      Since:
      100.0.0
    • createSwatchAsync

      public ListenableFuture<Image> createSwatchAsync(int width, int height, Color backgroundColor, Geometry geometry)
      Creates a swatch asynchronously from a Geometry object. The specified geometry should be in device-independent pixels (DIPs) with the point {0,0} corresponding to the center point of the swatch image. The x-axis increases toward the right hand side of the swatch image. The y-axis increases towards the top of the swatch image. The geometry type should correspond to the symbol type. For example, Points for MarkerSymbols, Polylines for LineSymbols and Polygons for FillSymbols. The spatial reference of the geometry is ignored.

      If this method is called on the JavaFX application thread then the swatch will be scaled based on the primary screen making the swatch appear the same size as it would in the GeoView. If not called on the JavaFX thread a default scale of 1.0 will be used which may result in a swatch bigger or smaller than the symbol would appear in the view.

      Parameters:
      width - the width of the swatch in device-independent pixels (DIPs)
      height - the height of the swatch in device-independent pixels (DIPs)
      backgroundColor - background color of the swatch
      geometry - geometry of the swatch
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if geometry is null, or if either width or height are less than 1
      Since:
      200.0.0
    • createSwatchAsync

      @Deprecated(since="200.0.0", forRemoval=true) public ListenableFuture<Image> createSwatchAsync(int backgroundColor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of 200.0.0, replaced by createSwatchAsync(Color)
      Creates a swatch asynchronously with the given background color.

      If this method is called on the JavaFX application thread then the swatch will be scaled based on the primary screen making the swatch appear the same size as it would in the GeoView. If not called on the JavaFX thread a default scale of 1.0 will be used which may result in a swatch bigger or smaller than the symbol would appear in the view.

      Parameters:
      backgroundColor - background color of the swatch as 0xAARRGGBB
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Since:
      100.0.0
    • createSwatchAsync

      public ListenableFuture<Image> createSwatchAsync(Color backgroundColor)
      Creates a swatch asynchronously with the given background color.

      If this method is called on the JavaFX application thread then the swatch will be scaled based on the primary screen making the swatch appear the same size as it would in the GeoView. If not called on the JavaFX thread a default scale of 1.0 will be used which may result in a swatch bigger or smaller than the symbol would appear in the view.

      Parameters:
      backgroundColor - background color of the swatch
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Since:
      200.0.0
    • createSwatchAsync

      @Deprecated(since="200.0.0", forRemoval=false) public ListenableFuture<Image> createSwatchAsync(int backgroundColor, float screenScale)
      Deprecated.
      as of 200.0.0, replaced by createSwatchAsync(Color, float)
      Creates a swatch asynchronously with the given background color and screen scale.
      Parameters:
      backgroundColor - background color of the swatch as 0xAARRGGBB
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      100.3.0
    • createSwatchAsync

      public ListenableFuture<Image> createSwatchAsync(Color backgroundColor, float screenScale)
      Creates a swatch image using the provided screen scale, and optional background color.
      Parameters:
      backgroundColor - background color of the swatch
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      200.0.0
    • createSwatchAsync

      @Deprecated(since="200.0.0", forRemoval=true) public ListenableFuture<Image> createSwatchAsync(int width, int height, float screenScale, int backgroundColor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a swatch asynchronously with the given width, height, screen scale and background color.
      Parameters:
      width - width of the image in dp
      height - height of the image in dp
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      backgroundColor - background color of the swatch as 0xAARRGGBB
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      100.3.0
    • createSwatchAsync

      public ListenableFuture<Image> createSwatchAsync(int width, int height, float screenScale, Color backgroundColor)
      Creates a swatch image using the provided width, height, screen scale, and optional background color.
      Parameters:
      width - the width of the swatch in device-independent pixels (DIPs)
      height - the height of the swatch in device-independent pixels (DIPs)
      screenScale - This value is used to scale the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display.
      backgroundColor - background color of the swatch
      Returns:
      a ListenableFuture that represents the async operation of creating the swatch
      Throws:
      IllegalArgumentException - if screenScale is 0 or less
      Since:
      200.0.0