Class Symbol
- 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 base class to represent symbols.A symbol defines display properties for features and graphics (collectively referred to as geoelements). A geoelement has a geometry (location and shape), and optional descriptive information. For features and graphics to appear on a map, they must be assigned a symbol.
ArcGIS Runtime uses two models for defining symbols in your map: simple and advanced (multilayer). In general, simple symbols are single-layer symbols that provide basic symbols, 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. Both of these are more fully described as follows:
- Simple symbols follow the web map specification; you work with them through the simple symbol classes in the API.
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.
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 ArcGIS Runtime and ArcGIS Pro, you can use advanced symbols exclusively. Advanced symbols are vectorized in ArcGIS Runtime clients, thereby scaling 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:
- 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ListenableFuture<Image>
createSwatchAsync(int backgroundColor)
Creates a swatch asynchronously with the given background color.ListenableFuture<Image>
createSwatchAsync(int backgroundColor, float screenScale)
Creates a swatch asynchronously with the given background color and screen scale.ListenableFuture<Image>
createSwatchAsync(int width, int height, float screenScale, int backgroundColor)
Creates a swatch asynchronously with the given width, height, screen scale and background color.ListenableFuture<Image>
createSwatchAsync(int width, int height, float screenScale, int backgroundColor, Geometry geometry)
Creates a scaled swatch asynchronously from a Geometry object.ListenableFuture<Image>
createSwatchAsync(int width, int height, int backgroundColor, Geometry geometry)
Creates a swatch asynchronously from a Geometry object.static Symbol
fromJson(String json)
Creates a Symbol instance from a JSON string.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.String
toJson()
Serializes this object to a JSON string.
-
-
-
Method Detail
-
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 interfaceJsonSerializable
- Returns:
- a JSON string
-
getUnknownJson
public Map<String,Object> getUnknownJson()
Description copied from interface:JsonSerializable
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.- Specified by:
getUnknownJson
in interfaceJsonSerializable
- 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
- a
-
getUnsupportedJson
public Map<String,Object> getUnsupportedJson()
Description copied from interface:JsonSerializable
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.- Specified by:
getUnsupportedJson
in interfaceJsonSerializable
- 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
- a
-
createSwatchAsync
public ListenableFuture<Image> createSwatchAsync(int width, int height, float screenScale, int backgroundColor, Geometry geometry)
Creates a scaled swatch asynchronously from a Geometry object. The specified geometry should be in density-independent pixels (dps) 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 dpheight
- height of the image in dpscreenScale
- 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 0xAARRGGBBgeometry
- geometry of the swatch- Returns:
- a ListenableFuture that represents the async operation of creating the swatch
- Throws:
IllegalArgumentException
- if geometry is nullIllegalArgumentException
- if width is less than 1IllegalArgumentException
- if height is less than 1IllegalArgumentException
- if screenScale is 0 or less- Since:
- 100.3.0
-
createSwatchAsync
public ListenableFuture<Image> createSwatchAsync(int width, int height, int backgroundColor, Geometry geometry)
Creates a swatch asynchronously from a Geometry object. The specified geometry should be in density-independent pixels (dps) 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 theGeoView
. 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 dpheight
- height of the image in dpbackgroundColor
- background color of the swatch as 0xAARRGGBBgeometry
- 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 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 theGeoView
. 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(int backgroundColor, float screenScale)
Creates a swatch asynchronously with the given background color and screen scale.- Parameters:
backgroundColor
- background color of the swatch as 0xAARRGGBBscreenScale
- 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(int width, int height, float screenScale, int backgroundColor)
Creates a swatch asynchronously with the given width, height, screen scale and background color.- Parameters:
width
- width of the image in dpheight
- height of the image in dpscreenScale
- 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
-
-