- All Implemented Interfaces:
JsonSerializable
A unique value renderer contains a collection of UniqueValues
.
Each UniqueValueRenderer.UniqueValue
has a Symbol
and a collection of
Values
to define a value or combination of values.
This is typically used to visualize categories or data types. For example, you can use a unique value renderer to symbolize zoning designations: yellow for "Residential", purple for "Industrial", and green for both "Forests" and "Open land".
Properties of a UniqueValueRender:
- Field Names - what key, in a key/value pair, to look for when searching a geoelement's attributes.
- UniqueValues - tells which value, in a key/value pair, from a geoelement's attributes is assigned to what Symbol.
- Default Label - a default label that a geoelement will be given if not assigned a UniqueValue.
- Default Symbol - a default Symbol that a geoelement will be given if not assigned a UniqueValue.
Example of using a UniqueValueRenderer with a GraphicsOverlay:
// colors for symbols int BLACK = 0xFF000000; int RED = 0xFFFF0000; int BLUE = 0xFF0000FF; ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_LIGHT_GRAY); GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); mapView.getGraphicsOverlays().add(graphicsOverlay); SimpleMarkerSymbol redMarker = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, RED, 10); SimpleMarkerSymbol blueMarker = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.TRIANGLE, BLUE, 10); SimpleMarkerSymbol defaultMarker = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CROSS, BLACK, 10); UniqueValueRenderer uniqueValRenderer = new UniqueValueRenderer(null, null, null, defaultMarker); uniqueValRenderer.getFieldNames().add("COLOR"); List<Object> redValue = new ArrayList<>(); redValue.add("RED"); UniqueValueRenderer.UniqueValue redUV = new UniqueValueRenderer.UniqueValue("Color: Red", "Red", redMarker, redValue); uniqueValRenderer.getUniqueValues().add(redUV); List<Object> blueValue = new ArrayList<>(); blueValue.add("BLUE"); UniqueValueRenderer.UniqueValue blueUV = new UniqueValueRenderer.UniqueValue("Color: Blue", "Blue", blueMarker, blueValue); uniqueValRenderer.getUniqueValues().add(blueUV); graphicsOverlay.setRenderer(uniqueValRenderer); Point p1 = new Point(2000000, 2000000); Point p2 = new Point(3000000, 3000000); Graphic redGraphic = new Graphic(p1); Graphic blueGraphic = new Graphic(p2); redGraphic.getAttributes().put("COLOR", "RED"); blueGraphic.getAttributes().put("COLOR", "BLUE"); graphicsOverlay.getGraphics().add(redGraphic); graphicsOverlay.getGraphics().add(blueGraphic);Note 1: the field name must match the key for the Graphic Attribute:
uniqueValRenderer.getFieldNames().add("COLOR"); redGraphic.getAttributes().put("COLOR", "RED");Note 2: the UniqueValue must match the value of the Graphic Attribute:
List<Object> redValue = new ArrayList<>(); redValue.add("RED"); redGraphic.getAttributes().put("COLOR", "RED");
- Since:
- 100.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A UniqueValue object that is used in a UniqueValueRenderer.Nested classes/interfaces inherited from class com.esri.arcgisruntime.symbology.Renderer
Renderer.SceneProperties
-
Constructor Summary
ConstructorDescriptionCreates a new empty unique value renderer.UniqueValueRenderer
(Iterable<String> fieldNames, Iterable<UniqueValueRenderer.UniqueValue> uniqueValues, String defaultLabel, Symbol defaultSymbol) Creates a new unique value renderer. -
Method Summary
Modifier and TypeMethodDescriptionGets the label used for the default symbol.Gets the default symbol for values that don't match any of the unique values.Gets a collection of the field names/attribute keys that the unique values apply to.Returns the symbol that is used to visualize the given feature.Returns the symbol that is used to visualize the given graphic.Gets a collection of unique values used by the renderer to select a symbol.void
setDefaultLabel
(String defaultLabel) Sets the label used for the default symbol.void
setDefaultSymbol
(Symbol defaultSymbol) Sets the default symbol for values that don't match any of the unique values.Methods inherited from class com.esri.arcgisruntime.symbology.Renderer
fromJson, getRotationExpression, getRotationType, getSceneProperties, getSymbol, getSymbol, getSymbol, getSymbol, getSymbol, getSymbol, getUnknownJson, getUnsupportedJson, setRotationExpression, setRotationType, toJson
-
Constructor Details
-
UniqueValueRenderer
public UniqueValueRenderer()Creates a new empty unique value renderer.The default Symbol can be set by itself and any geoelements that use this Renderer will be drawn with that Symbol.
- Since:
- 100.0.0
-
UniqueValueRenderer
public UniqueValueRenderer(Iterable<String> fieldNames, Iterable<UniqueValueRenderer.UniqueValue> uniqueValues, String defaultLabel, Symbol defaultSymbol) Creates a new unique value renderer.Geoelements are rendered to the GeoView by matching their field names with the corresponding UniqueValue's value.
The default values are set to geoelements that use this Renderer if no UniqueValues are set or those geoelements that don't fall within the UniqueValues range
- Parameters:
fieldNames
- a collection of the field names/attribute keys that the unique values apply to, may be nulluniqueValues
- a collection of unique values used by the renderer to select a symbol, may be nulldefaultLabel
- the label used for the default symboldefaultSymbol
- the default symbol for values that don't match any of the unique values, may be null- Since:
- 100.0.0
-
-
Method Details
-
getDefaultLabel
Gets the label used for the default symbol.The default value is a empty string.
- Returns:
- the default label
- Since:
- 100.0.0
- See Also:
-
setDefaultLabel
Sets the label used for the default symbol.This label will represent a default name for any geoelement that doesn't have a label assigned to it.
A geoelement will have this default label applied to them if no values are set or they don't fall within the UniqueValues range.
- Parameters:
defaultLabel
- the default label, can be null- Since:
- 100.0.0
-
getDefaultSymbol
Gets the default symbol for values that don't match any of the unique values.The default value is null.
- Returns:
- the default Symbol used by this Renderer
- Since:
- 100.0.0
- See Also:
-
setDefaultSymbol
Sets the default symbol for values that don't match any of the unique values.A geoelement will be set to this default Symbol if no values are set or a geoelement doesn't fall within the UniqueValues range.
- Parameters:
defaultSymbol
- the default Symbol for this Renderer, can be null- Since:
- 100.0.0
-
getFieldNames
Gets a collection of the field names/attribute keys that the unique values apply to.These names will be used as a key, in a key/value pair, to search geoelements' attributes to locate which geoelements that this name is referring to.
The returned list is modifiable. If this Renderer has no field names then an empty iterable list will be returned. The list is also returned in the same order in which the corresponding list of UniqueValues are retrieved.
- Returns:
- a collection of the field names/attribute keys that the unique values apply to
- Since:
- 100.0.0
-
getUniqueValues
Gets a collection of unique values used by the renderer to select a symbol.These values tell what Symbol will be applied to what value. Each UniqueValue also comes with a Label and a description of what the UniqueValue does or represents.
The returned list is modifiable. If this Renderer has no UniqueValues then an empty iterable list will be returned.
- Returns:
- a collection of unique values used by the renderer to select a symbol
- Since:
- 100.0.0
-
getSymbol
Returns the symbol that is used to visualize the given feature.If the renderer is a
DictionaryRenderer
and its associatedDictionarySymbolStyle
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 validMultilayerSymbol
. If you want to get the symbol before the layer is rendered, useDictionarySymbolStyle.getSymbolAsync(Map)
.- Specified by:
getSymbol
in classRenderer
- 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
- See Also:
-
getSymbol
Returns the symbol that is used to visualize the given graphic.If the renderer is a
DictionaryRenderer
and its associatedDictionarySymbolStyle
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 validMultilayerSymbol
. If you want to get the symbol before the layer is rendered, useDictionarySymbolStyle.getSymbolAsync(Map)
.- Specified by:
getSymbol
in classRenderer
- 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
- See Also:
-