public class

Graphic

extends Object
implements Serializable
java.lang.Object
   ↳ com.esri.core.map.Graphic
Known Direct Subclasses

Class Overview

The Graphic class is used to represent a feature that can have any of the following types:

Graphic objects are immutable, which means its state cannot change after construction. When a Graphic object is added to a GraphicsLayer via the GraphicsLayer#addGraphic(Graphic) method, this method returns a unique ID (UID) which you can then use to reference the added graphic for subsequent operations. Graphic objects are stateless so there is no guarantee that a feature in the GraphicsLayer exists after the request for the Graphic object is completed.

Graphic objects can be displayed, altered and removed using a GraphicsLayer (see the GraphicsLayer class for more details)

Summary

Fields
protected final Map<StringObject> attributes Name-value pairs of fields and their connected field values that are associated with the graphic.
Public Constructors
Graphic(Geometry geometry, Symbol symbol)
Instantiates a new Graphic object.
Graphic(Geometry geometry, Symbol symbol, int drawOrder)
Instantiates a new Graphic object.
Graphic(Geometry geometry, Symbol symbol, Map<StringObject> attributes, InfoTemplate infoTemp)
Instantiates a new Graphic object.
Graphic(Geometry geometry, Symbol symbol, Map<StringObject> attributes, int drawOrder)
Public Methods
static Graphic fromJson(JsonParser parser)
Convenient method which parses the JSON representation of a graphic into a graphic object.
String[] getAttributeNames()
Gets the name of all the attributes.
Object getAttributeValue(String key)
Gets the attribute value by the given name.
Map<StringObject> getAttributes()
Returns all attributes of the graphic as a read-only collection.
int getDrawOrder()
Returns the draw order.
Geometry getGeometry()
Gets the geometry that defines the graphic.
InfoTemplate getInfoTemplate()
Returns the template.@deprecated
SpatialReference getSpatialReference()
Returns the spatial reference.
Symbol getSymbol()
Gets the symbol for the graphic.
int getUid()
Gets unique ID.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final Map<StringObject> attributes

Name-value pairs of fields and their connected field values that are associated with the graphic.

Public Constructors

public Graphic (Geometry geometry, Symbol symbol)

Instantiates a new Graphic object.

Parameters
geometry the geometry to draw;
symbol the symbol to draw the geometry with.

public Graphic (Geometry geometry, Symbol symbol, int drawOrder)

Instantiates a new Graphic object.

Parameters
geometry the geometry to draw;
symbol the symbol to draw the geometry with.
drawOrder the draw order; higher valued graphics appear on top of lower valued graphics.

public Graphic (Geometry geometry, Symbol symbol, Map<StringObject> attributes, InfoTemplate infoTemp)

Instantiates a new Graphic object. The uid defaults to -1.

Parameters
geometry The geometry to draw.
symbol The symbol to draw the geometry with.
attributes The name-value pairs of fields and their connected field values that are associated with the graphic.
infoTemp The InfoTemplate object.

public Graphic (Geometry geometry, Symbol symbol, Map<StringObject> attributes, int drawOrder)

Parameters
geometry The geometry to draw.
symbol The symbol to draw the geometry with.
attributes The name-value pairs of fields and their connected field values that are associated with the graphic.
drawOrder the draw order; higher valued graphics appear on top of lower valued graphics.

Public Methods

public static Graphic fromJson (JsonParser parser)

Convenient method which parses the JSON representation of a graphic into a graphic object.

Parameters
parser Parser initialized with a graphic JSON String.
Returns
  • Graphic object.
Throws
Exception Exception if parsing fails.

public String[] getAttributeNames ()

Gets the name of all the attributes. Attributes are name-value pairs of fields and field values associated with the graphic.

Returns
  • the attribute names

public Object getAttributeValue (String key)

Gets the attribute value by the given name.

Parameters
key the key
Returns
  • the attribute value

public Map<StringObject> getAttributes ()

Returns all attributes of the graphic as a read-only collection.

Returns
  • the attributes

public int getDrawOrder ()

Returns the draw order.

Returns
  • the draw order of this graphic.

public Geometry getGeometry ()

Gets the geometry that defines the graphic.

Returns
  • the geometry

public InfoTemplate getInfoTemplate ()

Returns the template.@deprecated

Returns
  • the info template

public SpatialReference getSpatialReference ()

Returns the spatial reference.

Returns
  • the spatial reference of this graphic.

public Symbol getSymbol ()

Gets the symbol for the graphic.

Returns
  • the symbol

public int getUid ()

Gets unique ID.

Returns
  • the uid