Class Renderer
- 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
Base class for Renderers and used to draw Features or Graphics to a GeoView.Renderers can be set to a
FeatureLayer.setRenderer(com.esri.arcgisruntime.symbology.Renderer)
or aGraphicsOverlay.setRenderer(com.esri.arcgisruntime.symbology.Renderer)
, which hold Features or Graphics respectively. Once a Renderer is set, the properties of that Renderer will determine how those Features or Graphics are drawn to the GeoView. A Renderer can specify that all Features or Graphics will be drawn with the same Symbol or with a different Symbol.When both a Renderer and Symbol are set, the Symbol takes precedence.
GraphicsOverlays can contain Graphics with different geometry
dimensions
. However, a Renderer can only be used to draw symbols with the same dimension of geometry, therefore a Renderer used with a graphics overlay can only draw graphics of a single geometry dimension.Properties of a Renderer:
- RotationType, how a Symbol is rotated along the x-axis or y-axis.
- RotationExpression, a value that specifies the angle of rotation.
- Symbol, used to draw a Feature or Graphic
- Since:
- 100.0.0
- See Also:
FeatureLayer
,GraphicsOverlay
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Renderer.SceneProperties
This represents renderer properties applicable only to an ArcGISScene.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Renderer
fromJson(String json)
Creates a Renderer instance from a JSON string.String
getRotationExpression()
Gets a value that specifies the angle of rotation.RotationType
getRotationType()
Gets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.Renderer.SceneProperties
getSceneProperties()
Gets the scene view properties for the renderer.abstract Symbol
getSymbol(Feature feature)
Gets the Symbol used to display the given Feature.Symbol
getSymbol(Feature feature, boolean applyAttributeOverrides)
Returns the symbol that should be used to visualize the given feature with override expressions from renderer.abstract Symbol
getSymbol(Graphic graphic)
Gets the Symbol used to display the given Graphic.Symbol
getSymbol(Graphic graphic, boolean applyAttributeOverrides)
Returns the symbol that should be used to visualize the given graphic with override expressions from renderer.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.void
setRotationExpression(String rotationExpression)
Sets the rotation expression.void
setRotationType(RotationType rotationType)
Sets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.String
toJson()
Serializes this object to a JSON string.
-
-
-
Method Detail
-
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 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
-
getSymbol
public abstract Symbol getSymbol(Feature feature)
Gets the Symbol used to display the given Feature.- 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)
Gets the Symbol used to display the given Graphic.- 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 should be used to visualize the given feature with override expressions from renderer.If
applyAttributeOverrides
is set to true and the renderer contains an override expression, this method will return a symbol modified by the expression. If the expression cannot be properly evaluated due to missing fields or external data, then the original symbol is returned.- Parameters:
feature
- the Feature to get a Symbol from, not nullapplyAttributeOverrides
- 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 should be used to visualize the given graphic with override expressions from renderer.If
applyAttributeOverrides
is set to true and the renderer contains an override expression, this method will return a symbol modified by the expression. If the expression cannot be properly evaluated due to missing fields or external data, then the original symbol is returned.- Parameters:
graphic
- the Graphic to get a Symbol from, not nullapplyAttributeOverrides
- 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 the type of rotation that this Symbol uses to spin along the x-axis or y-axis.Default value is UNKNOWN.
- Returns:
- the rotation type of this Symbol
- Since:
- 100.0.0
- See Also:
setRotationType(com.esri.arcgisruntime.symbology.RotationType)
-
setRotationType
public void setRotationType(RotationType rotationType)
Sets the type of rotation that this Symbol uses to spin along the x-axis or y-axis.If
ARITHMETIC
, rotation is along the x-axis, with positive rotation being counter-clockwise.If
GEOGRAPHIC
, rotation is along the y-axis, with positive rotation being clockwise.- 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 a value that specifies the angle of rotation.Default value is null.
- Returns:
- the rotation expression
- Since:
- 100.0.0
- See Also:
setRotationExpression(java.lang.String)
-
setRotationExpression
public void setRotationExpression(String rotationExpression)
Sets the rotation expression.This is a constant value or an expression that derives the angle of rotation based on the Feature attribute value. When an attribute name is specified in the rotation expression, it's 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:
getRotationExpression()
-
getSceneProperties
public Renderer.SceneProperties getSceneProperties()
Gets the scene view properties for the renderer. The scene properties object can be used to make changes to howGeoElement
are displayed in a SceneView.- Returns:
- the scene view properties for the renderer, which are applicable only to an ArcGISScene
- Since:
- 100.0.0
-
-