extends java.lang.Object
implements
GeoElement
A Graphic consists of a
Geometry
, optional
attributes
, and is drawn on a map using a
symbol or renderer.
Graphics are used to represent temporary data, such as the results of a query or an analysis, or to highlight
existing content in a map. They are often used to display data that changes location regularly, because they are held
in memory instead of being persisted to the map. They are displayed on a map via a
GraphicsOverlay
.
Each graphic must have a
setGeometry(Geometry)
describing the location and the shape of the graphic. The
geometry of the graphic will be re-projected on the fly to the
SpatialReference
of the map if it has a
different SpatialReference. Re-projection can be costly - ideally, the geometry should have the same SpatialReference
as the map to maximize performance.
Optionally, a Graphic can have a set of attributes providing information associated with the graphic, stored in a
collection of key/value pairs returned from
getAttributes()
. A range of attribute data types are supported,
including primitive data types (Boolean, Integer, Long, Short, Float, Double, String), dates (Calendar) and
universally unique identifiers (UUID). Graphic attributes can be displayed in a Popup.
Graphics are drawn using the Symbol set on the Graphic, or with the Renderer set on the GraphicsOverlay that
contains it. If both properties are set, the Symbol of the Graphic takes precedence over any Renderer set on the
GraphicsOverlay. A graphic can have any type of geometry, although the symbol type must be appropriate to the
geometry type; a
MarkerSymbol
is used for points and multipoint,
LineSymbol
for polylines, and a
FillSymbol
for polygons or envelopes.
A graphic can be selected or deselected using
setSelected(boolean)
; selected graphics are drawn with a
highlight halo. You can also change the visibility of a graphic using
setVisible(boolean)
.
Since:
100.0.0
See Also:
GraphicsOverlay
,
SpatialReference
,
Symbol
,
Renderer
Graphic
(
Geometry
geometry,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Creates a new graphic with the given geometry and attributes.
Graphic
(
Geometry
geometry,
java.util.Map<java.lang.String,java.lang.Object> attributes,
Symbol
symbol)
Creates new graphic with the given geometry, attributes, and symbol.
Graphic
public Graphic(Geometry geometry)
Creates a new graphic with the given geometry.
Parameters:
geometry
- the geometry
Throws:
java.lang.IllegalArgumentException
- if the geometry is null
Since:
100.0.0
public Graphic(double latitude,
double longitude)
Creates a new graphic with a point defined in the WGS 84 SpatialReference.
Parameters:
latitude
- the latitude
longitude
- the longitude
Since:
100.0.0
public Graphic(Geometry geometry,
Symbol symbol)
Creates a new graphic with the given geometry and symbol.
Parameters:
geometry
- the geometry
symbol
- the symbol
Throws:
java.lang.IllegalArgumentException
- if the geometry or symbol is null
Since:
100.0.0
Graphic
public Graphic(Geometry geometry,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Creates a new graphic with the given geometry and attributes.
Parameters:
geometry
- the geometry
attributes
- the attributes of the graphic. Note that the values are copied. To make changes use getAttributes.
Throws:
java.lang.IllegalArgumentException
- if geometry or attributes is null
Since:
100.0.0
Graphic
public Graphic(Geometry geometry,
java.util.Map<java.lang.String,java.lang.Object> attributes,
Symbol symbol)
Creates new graphic with the given geometry, attributes, and symbol.
Parameters:
geometry
- the geometry
attributes
- the attributes of the graphic. Note that the values are copied. To make changes use getAttributes.
symbol
- the symbol
Throws:
java.lang.IllegalArgumentException
- if geometry, attributes, or symbol is null
Since:
100.0.0
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Gets a java.util.Map of all the available attributes as name value pairs.
Attribute values are returned as Object instances, but the underlying value type is based on the
Field.Type
.
Specified by:
getAttributes
in interface
GeoElement
Returns:
all the available attributes as name value pairs.
public Geometry getGeometry()
Gets the geometry of this geoelement.
Specified by:
getGeometry
in interface
GeoElement
Returns:
the geometry of this geoelement
setGeometry
public void setGeometry(Geometry geometry)
Sets the GeoElement's geometry.
Specified by:
setGeometry
in interface
GeoElement
Parameters:
geometry
- the geometry to set
getSymbol
public Symbol getSymbol()
Gets the symbol. The symbol type will match with the geometry type of the graphic. The
rendering of the symbol takes precedence over any Renderer that may be set already on the
GraphicsOverlay.
Returns:
the symbol
Since:
100.0.0
setSymbol
public void setSymbol(Symbol symbol)
Sets the symbol. The symbol type must match the geometry type of the graphic. The rendering of the symbol takes precedence over any Renderer that may be set already on the GraphicsOverlay.
Parameters:
symbol
- the new symbol
Since:
100.0.0
setVisible
public void setVisible(boolean visible)
Controls the visibility of the graphic.
Parameters:
visible
- true, to make visible
Since:
100.0.0
setSelected
public void setSelected(boolean selected)
Controls if the graphic is selected or not
Parameters:
selected
- true, to select
Since:
100.0.0
getZIndex
public int getZIndex()
Gets the z-index. Graphics with higher z-index values are drawn on top of lower z-index graphics.
A graphic's z-index is most relevant for display in a two dimensional map. For dynamic 3D rendering (in a scene),
graphic display order is determined by the distance to the camera rather than by z-index. Z-index, however, is
considered when using static rendering in a scene (draping graphics on the surface, in other words).
If z-index is not set, graphics will usually render in the order in which they were added to the graphics
overlay, the first added is rendered first and subsequent ones on top. In rare cases, the rendering algorithm may
change the display order to provide more efficient rendering. If ordering is important, set the z-index explicitly
on graphics. You can also place graphics of the same geometry type in their own graphics overlay and manage the
order of the overlays in the
MapView
or
SceneView
.
Returns:
the z-index
Since:
100.0.0
setZIndex
public void setZIndex(int index)
Sets the z-index. Graphics with higher z-index values are drawn on top of lower z-index graphics.
A graphic's z-index is most relevant for display in a two dimensional map. For dynamic 3D rendering (in a scene),
graphic display order is determined by the distance to the camera rather than by z-index. z-index, however, is
considered when using static rendering in a scene (draping graphics on the surface, in other words).
Parameters:
index
- the new z-index
Since:
100.0.0
getGraphicsOverlay
public GraphicsOverlay getGraphicsOverlay()
Gets the graphics overlay that contains this graphic. Will be null if the graphic is not in an overlay.
Returns:
the graphics overlay
Since:
100.0.0