Class DictionaryRenderer
- java.lang.Object
-
- com.esri.arcgisruntime.symbology.Renderer
-
- com.esri.arcgisruntime.symbology.DictionaryRenderer
-
- All Implemented Interfaces:
JsonSerializable
public final class DictionaryRenderer extends Renderer
Defines a renderer based on aSymbolStyle
.The DictionaryRenderer uses attributes from source data (such as fields of features in a feature table or attributes of graphics in a graphics overlay) to display unique multilayer symbols based on those attributes. This is achieved through an associated DictionarySymbolStyle.
The DictionarySymbolStyle is created using a given specification such as "mil2525d". Each specification depends on attribute names that define the symbology and text of each feature. For example, the mil2525d specification looks for attributes named "identity", "symbolset", "symbolentity", and "modifier1", among many others. These attributes reference different symbols in the style file that are assembled to create a unique symbol. In order to display features using the DictionaryRenderer, you must make sure the DictionaryRenderer and associated DictionarySymbolStyle know which attributes in your data to use. This can be achieved in multiple ways:
- Pre-author your data so that the attribute names match the attributes needed by the specification. In the case of the mil2525d specification, author a feature service (or other data source) with a field named "identity", another named "symbolset", and so on. In this scenario, you create a FeatureTable from the source data, create a FeatureLayer from the FeatureTable, apply the DictionaryRenderer to the FeatureLayer, and the symbols are generated automatically and applied to the layer in the view. The same workflow applies for Graphics in a GraphicsOverlay. Ideally when creating graphics on the fly, you can give the attributes names that match the specification. When fields in the FeatureTable and attributes in Graphics have expected names, the DictionaryRenderer automatically finds them.
- Manually map your attribute names to those expected by the specification. You can map as many attribute names as necessary for the specification, but only need to map attribute names that do not match the specification (all matching attribute names will be automatically matched by the renderer). For example, an expected attribute "symbolset" might appear as the "symbol_set" field in your FeatureTable. In this scenario, you can create a ServiceFeatureTable from a feature service, create a FeatureLayer from that feature table, create a DictionaryRenderer by manually mapping the "symbol_set" name to the "symbolset" name expected by the specification, and finally apply the renderer to the FeatureLayer.
A DictionaryRenderer can be applied to pre-authored data, such as feature services, mobile geodatabases (generated from ArcMap or a sync-enabled feature service), and feature layers in a mobile map package. You can also apply it to a
GraphicsOverlay
, which allow for on-the-fly graphic generation.- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
- See Also:
DictionarySymbolStyle
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.esri.arcgisruntime.symbology.Renderer
Renderer.SceneProperties
-
-
Constructor Summary
Constructors Constructor Description DictionaryRenderer(DictionarySymbolStyle dictionarySymbolStyle)
Creates an instance of DictionaryRenderer.DictionaryRenderer(DictionarySymbolStyle dictionarySymbolStyle, Map<String,String> symbologyFieldOverrides, Map<String,String> textFieldOverrides)
Creates an instance of DictionaryRenderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DictionarySymbolStyle
getDictionarySymbolStyle()
Gets the dictionary symbol style to be applied by the renderer.ArcadeExpression
getScaleExpression()
Gets an arcade expression object with an expression for scaling symbols in a dictionary renderer.Symbol
getSymbol(Feature feature)
This operation is not supported.Symbol
getSymbol(Graphic graphic)
This operation is not supported.Map<String,String>
getSymbologyFieldOverrides()
Gets the map of a symbology attribute and its override used to fetch a symbol from the dictionary symbol style.Map<String,String>
getTextFieldOverrides()
Gets the map of a text attribute and its override used to fetch symbol text and placement from the dictionary symbol style.double
getTextVisibilityMaxScale()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteaddouble
getTextVisibilityMinScale()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadboolean
isTextVisible()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadvoid
setDictionarySymbolStyle(DictionarySymbolStyle dictionarySymbolStyle)
Sets the dictionary symbol style to be applied by the renderer.void
setScaleExpression(ArcadeExpression scaleExpression)
Sets an arcade expression object with an expression for scaling symbols in a dictionary renderer.void
setTextVisibilityMaxScale(double maxScale)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadvoid
setTextVisibilityMinScale(double minScale)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadvoid
setTextVisible(boolean visible)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings instead-
Methods inherited from class com.esri.arcgisruntime.symbology.Renderer
fromJson, getRotationExpression, getRotationType, getSceneProperties, getSymbol, getSymbol, getUnknownJson, getUnsupportedJson, setRotationExpression, setRotationType, toJson
-
-
-
-
Constructor Detail
-
DictionaryRenderer
public DictionaryRenderer(DictionarySymbolStyle dictionarySymbolStyle)
Creates an instance of DictionaryRenderer.- Parameters:
dictionarySymbolStyle
- dictionary symbol style, can't be null- Throws:
IllegalArgumentException
- if dictionarySymbolStyle is null- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android for JavaSE and 100.2.0 for Android
-
DictionaryRenderer
public DictionaryRenderer(DictionarySymbolStyle dictionarySymbolStyle, Map<String,String> symbologyFieldOverrides, Map<String,String> textFieldOverrides)
Creates an instance of DictionaryRenderer.- Parameters:
dictionarySymbolStyle
- dictionary symbol style, can't be nullsymbologyFieldOverrides
- symbology fields to be overriddentextFieldOverrides
- text fields to be overridden- Throws:
IllegalArgumentException
- if dictionarySymbolStyle or symbologyFieldOverrides or textFieldOverrides is null- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
-
Method Detail
-
getDictionarySymbolStyle
public DictionarySymbolStyle getDictionarySymbolStyle()
Gets the dictionary symbol style to be applied by the renderer.- Returns:
- the dictionary symbol style to be applied by the renderer
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
setDictionarySymbolStyle
public void setDictionarySymbolStyle(DictionarySymbolStyle dictionarySymbolStyle)
Sets the dictionary symbol style to be applied by the renderer.- Parameters:
dictionarySymbolStyle
- dictionary symbol style- Throws:
IllegalArgumentException
- if dictionarySymbolStyle is null- Since:
- 100.5.0
-
getScaleExpression
public ArcadeExpression getScaleExpression()
Gets an arcade expression object with an expression for scaling symbols in a dictionary renderer.ArcadeExpression
is evaluated at rendering time. If the expression is not valid or results in an invalid value, symbols will not be scaled and will display at their original size. For example to scale symbols based on attribute value, ArcadeExpression object's expression property can be set to something like `iif($feature.Symbol_Set == 40, 2.5, 1) //Scale symbol size 2.5 times when symbol_set is 40`.- Returns:
- an arcade expression object with an expression for scaling symbols in a dictionary renderer, or null if none
- Since:
- 100.11.0
-
setScaleExpression
public void setScaleExpression(ArcadeExpression scaleExpression)
Sets an arcade expression object with an expression for scaling symbols in a dictionary renderer.ArcadeExpression
is evaluated at rendering time. If the expression is not valid or results in an invalid value, symbols will not be scaled and will display at their original size. For example to scale symbols based on attribute value, ArcadeExpression object's expression property can be set to something like `iif($feature.Symbol_Set == 40, 2.5, 1) //Scale symbol size 2.5 times when symbol_set is 40`.- Parameters:
scaleExpression
- an arcade expression object with an expression for scaling symbols in a dictionary renderer (May be null)- Since:
- 100.11.0
-
getSymbologyFieldOverrides
public Map<String,String> getSymbologyFieldOverrides()
Gets the map of a symbology attribute and its override used to fetch a symbol from the dictionary symbol style.A
DictionarySymbolStyle
uses a collection of expected attribute names to build a symbol based on input values. When initialized, fields in the input dataset are mapped to the expected attribute names using case-insensitive matching. If your data uses a different name for an expected symbol attribute, use theSymbologyFieldOverrides
to map an expected field to the correct field in your data. You can also exclude an expected field by providing an empty string for it in the overrides. Empty by default.In case your source data's symbology field names do not match what the DictionarySymbolStyle specification expects, use this to override. For example, if the expected name in specification is "symbolset", and the value in your field's name is "symbol_set", set the override as:
getSymbologyFieldOverrides().put("symbolset", "symbol_set");
- Returns:
- The map of a symbology attribute and its override used to fetch a symbol from the dictionary symbol style, empty by default
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
getTextFieldOverrides
public Map<String,String> getTextFieldOverrides()
Gets the map of a text attribute and its override used to fetch symbol text and placement from the dictionary symbol style.A DictionarySymbolStyle uses a collection of expected attribute names to build a symbol based on input values. When initialized, fields in the input dataset are mapped to the expected attribute names using case-insensitive matching. If your data uses a different name for an expected text attribute, use the TextFieldOverrides to map an expected field to the correct field in your data. You can also exclude an expected field by providing an empty string for it in the overrides. Empty by default
In case your source data's text field names do not match what the DictionarySymbolStyle specification expects, use this method to override. For example, if the expected name in specification is "staffcomment", and the value is your field's name is "staff_comment", set the override as:
getTextFieldOverrides().put("staffcomment", "staff_comment");
- Returns:
- the map of a text attribute and its override used to fetch symbol text and placement from the dictionary symbol style.
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
isTextVisible
@Deprecated public boolean isTextVisible()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadIndicates the visibility for the text on the symbol.- Returns:
- the visibility for the text on the symbol. Default is true
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
setTextVisible
@Deprecated public void setTextVisible(boolean visible)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadSets the visiblity for the text on the symbol.- Parameters:
visible
- text visibility- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
getTextVisibilityMinScale
@Deprecated public double getTextVisibilityMinScale()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadGets the minimum scale (2D) or distance (3D) at which the symbol's text will be visible.The return value is scale if the view is a Map, and distance (in meters) if the view is a Scene.
- Returns:
- The minimum scale (2D) or distance (3D) at which the symbol's text will be visible. Default is 0.0
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
setTextVisibilityMinScale
@Deprecated public void setTextVisibilityMinScale(double minScale)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadThe minimum scale (2D) or distance (3D) at which the symbol's text will be visible.Use this property to apply scale dependency for the text in the symbols. This value is scale if the view is a Map, and distance (in meters) if the view is a Scene.
- Parameters:
minScale
- min scale- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
getTextVisibilityMaxScale
@Deprecated public double getTextVisibilityMaxScale()
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadGets the maximum scale (2D) or distance (3D) at which the symbol's text will be visible.- Returns:
- The maximum scale (2D) or distance (3D) at which the symbol's text will be visible. Default is 0.0
- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
setTextVisibilityMaxScale
@Deprecated public void setTextVisibilityMaxScale(double maxScale)
Deprecated.as of 100.6.0, use theDictionarySymbolStyleConfiguration
settings insteadSet the maximum scale (2D) or distance (3D) at which the symbol's text will be visible.Use this property to apply scale dependency for the text in the symbols. This value is scale if the view is a Map, and distance (in meters) if the view is a Scene.
- Parameters:
maxScale
- max scale- Since:
- 100.0.0 for JavaSE and 100.2.0 for Android
-
getSymbol
public Symbol getSymbol(Feature feature)
This operation is not supported.Instead, use
SymbolStyle.getSymbolAsync(List)
} orSymbolStyle.searchSymbolsAsync(SymbolStyleSearchParameters)
}.- 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:
UnsupportedOperationException
-
getSymbol
public Symbol getSymbol(Graphic graphic)
This operation is not supported.Instead, use
SymbolStyle.getSymbolAsync(List)
} orSymbolStyle.searchSymbolsAsync(SymbolStyleSearchParameters)
.- 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:
UnsupportedOperationException
-
-