com.esri.android.map
Class GraphicsLayer

java.lang.Object
  extended by com.esri.android.map.Layer
      extended by com.esri.android.map.GraphicsLayer
Direct Known Subclasses:
ArcGISFeatureLayer

public class GraphicsLayer
extends Layer

The GraphicsLayer class represents a layer that contains one or more Graphic features. The MapView can contain one or more graphic layers.

The following is an example of how you can work with the GraphicsLayer class in Java.

Java usage:

 //GraphicsLayer class is used to define the Layer that is added to the
 //MapView object.
 MapView mv = new MapView(this);
 mv.addLayer(new GraphicsLayer());
 setContentView(mv);
 

Since:
1.0

Field Summary
 
Fields inherited from class com.esri.android.map.Layer
credentials, nativeHandle, popUpInfos, serviceInfo
 
Constructor Summary
  GraphicsLayer()
          The constructor is used if your are instantiating an empty GraphicsLayer (see the class description for an example of this usage).
protected GraphicsLayer(boolean initLayer)
          The constructor is used internally to allow more controls over the layer initialization process.
protected GraphicsLayer(long handle)
          The constructor is used internally to allow more controls over the layer initialization process.
  GraphicsLayer(SpatialReference sr, Envelope fullextent)
          The constructor with spatial reference and full extent.
 
Method Summary
 int addGraphic(Graphic graphic)
          Adds a graphic into GraphicsLayer.
 int[] addGraphics(Graphic[] graphics)
          Adds an array of Graphic.
protected  long create()
           
 android.graphics.Bitmap createSymbolImage(Symbol symbol, Geometry geometry, int width, int height, int color)
          Returns a swatch image of the given geometry rendered with the specified symbol.
 android.graphics.Bitmap[] createSymbolImages(Symbol[] symbol, Geometry[] geometry, int width, int height, int color)
          Returns a swatch image array of for the given geometries rendered with the symbols.
 Graphic getGraphic(int uid)
          Retrives a graphic instance using a unique ID.
 int[] getGraphicIDs()
          Retrieves an array of unique IDs representing all graphics in this layer.
 int[] getGraphicIDs(float x, float y, int tolerance)
          Returns the graphics near the Point.
 int[] getGraphicIDs(float x, float y, int tolerance, int numberOfResults)
          Returns the graphics near the Point.
 double getMaxScale()
          Gets max scale.
 double getMinScale()
          Gets min scale.
 int getNumberOfGraphics()
          Returns number of graphics.
 Renderer<Graphic> getRenderer()
          Gets the renderer of the GraphicsLayer.
protected  void initLayer()
          Initializes the layer.
 void moveAllGraphics(Point from, Point to)
          Moves all graphics by offset determined by from point and to point.
 void removeAll()
          Removes all graphics.
 void removeGraphic(int id)
          Removes graphic using a unique ID.
 void setGraphicVisible(int uid, boolean visible)
          Sets visibility of a graphic with a unique id.
 void setMaxScale(double maxScale)
          Sets max scale.
 void setMinScale(double minScale)
          Sets min scale.
 void setRenderer(Renderer<Graphic> renderer)
          Sets the renderer of the GraphicsLayer.
 void updateGraphic(int id, Geometry geometry)
          Updates the geometry of a graphic specified by id with a geometry.
 void updateGraphic(int id, Graphic graphic)
          Updates a graphic specified by an id with attributes of another graphic instance.
 void updateGraphic(int id, InfoTemplate infoTemplate)
          Updates the infotemplate of a graphic specified by id with an infotemplate.
 void updateGraphic(int id, Map<String,Object> attributes)
          Updates the attributes of a graphic specified by id with an attribute map.
 void updateGraphic(int id, Symbol symbol)
          Updates the symbol attribute of a graphic specified by id with a symbol.
 
Methods inherited from class com.esri.android.map.Layer
changeStatus, finalize, getCredentials, getDefaultSpatialReference, getDpi, getExtent, getFullExtent, getHeight, getID, getInitialExtent, getName, getOpacity, getParent, getPoolExecutor, getPopupInfo, getQueryUrl, getResolution, getServiceExecutor, getSpatialReference, getTitle, getUrl, getUrlHashCode, getWidth, isInitialized, isRecycled, isShowLegend, isVisible, isWebMapBaselayer, loadServiceInfo, lock, recycle, reinitializeLayer, setCredentials, setDefaultSpatialReference, setFullExtent, setInitialExtent, setName, setOnStatusChangedListener, setOpacity, setPopupInfos, setQueryUrls, setUrl, setVisible, unlock, updateSpatialReferenceStatus, verifyCredentials
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsLayer

public GraphicsLayer()
The constructor is used if your are instantiating an empty GraphicsLayer (see the class description for an example of this usage).

This constructor assumes you have another layer as the bottom most layer defined for the MapView. In this instance the GraphicsLayer cannot be the bottom most layer.

Since:
1.0

GraphicsLayer

protected GraphicsLayer(boolean initLayer)
The constructor is used internally to allow more controls over the layer initialization process.


GraphicsLayer

protected GraphicsLayer(long handle)
The constructor is used internally to allow more controls over the layer initialization process.


GraphicsLayer

public GraphicsLayer(SpatialReference sr,
                     Envelope fullextent)
The constructor with spatial reference and full extent.

Parameters:
sr - The default spatial reference GraphicsLayer uses
fullextent - The full extent of GraphicsLayer
Since:
1.0
Method Detail

create

protected long create()
Specified by:
create in class Layer

initLayer

protected void initLayer()
Description copied from class: Layer
Initializes the layer. The implementation should submit the OnStatusChangedListener.STATUS event accordingly.

Specified by:
initLayer in class Layer

moveAllGraphics

public void moveAllGraphics(Point from,
                            Point to)
Moves all graphics by offset determined by from point and to point.

Parameters:
from - From point
to - To point
Since:
1.0

removeAll

public void removeAll()
Removes all graphics.

Since:
1.0

addGraphic

public int addGraphic(Graphic graphic)
Adds a graphic into GraphicsLayer.

Parameters:
graphic - Graphic object
Returns:
A unique ID representing the added Graphic if adding is successful. -1 if adding fails.
Since:
1.0

addGraphics

public int[] addGraphics(Graphic[] graphics)
Adds an array of Graphic.

Parameters:
graphics - An array of Graphic.
Returns:
An array of unique IDs representing newly added Graphics if adding is successful.
Since:
1.0

getGraphic

public Graphic getGraphic(int uid)
Retrives a graphic instance using a unique ID.

Parameters:
uid - Unique ID representing a graphic
Returns:
A graphic instance if a graphic with the same UID exists, otherwise a null is returned.
Since:
1.0

getGraphicIDs

public int[] getGraphicIDs()
Retrieves an array of unique IDs representing all graphics in this layer.

Returns:
an array of unique IDs
Since:
1.0

getMaxScale

public double getMaxScale()
Gets max scale. When map zooms in beyond max scale, graphics are not visible.

Returns:
max scale.
Since:
1.0

getMinScale

public double getMinScale()
Gets min scale. When map zooms out beyond min scale, graphics are not visible.

Returns:
min scale
Since:
1.0

setMaxScale

public void setMaxScale(double maxScale)
Sets max scale.

Parameters:
maxScale - max scale.
Since:
1.0

setMinScale

public void setMinScale(double minScale)
Sets min scale.

Parameters:
minScale - min scale.
Since:
1.0

getNumberOfGraphics

public int getNumberOfGraphics()
Returns number of graphics.

Returns:
number of graphics
Since:
1.0

removeGraphic

public void removeGraphic(int id)
Removes graphic using a unique ID.

Parameters:
id - Unique ID representing a Graphic.
Since:
1.0

updateGraphic

public void updateGraphic(int id,
                          Graphic graphic)
Updates a graphic specified by an id with attributes of another graphic instance.

Parameters:
id - Unique ID representing an existing graphic.
graphic - Graphic instance whose attributes is used in update.
Since:
1.0

updateGraphic

public void updateGraphic(int id,
                          Geometry geometry)
Updates the geometry of a graphic specified by id with a geometry.

Parameters:
id - Unique ID representing an existing graphic.
geometry - Geometry instance used for update.
Since:
1.0

updateGraphic

public void updateGraphic(int id,
                          Symbol symbol)
Updates the symbol attribute of a graphic specified by id with a symbol.

Parameters:
id - Unique ID representing an existing graphic.
symbol - Symbol instance used for update.
Since:
1.0

updateGraphic

public void updateGraphic(int id,
                          InfoTemplate infoTemplate)
                   throws Exception
Updates the infotemplate of a graphic specified by id with an infotemplate.

Parameters:
id - Unique ID representing an existing graphic.
infoTemplate - InfoTemplate instance used for update.
Throws:
Exception - the exception
Since:
1.0

updateGraphic

public void updateGraphic(int id,
                          Map<String,Object> attributes)
Updates the attributes of a graphic specified by id with an attribute map.

Parameters:
id - Unique ID representing an existing graphic.
attributes - Attribute map used for update.
Since:
1.0

setGraphicVisible

public void setGraphicVisible(int uid,
                              boolean visible)
Sets visibility of a graphic with a unique id.

Parameters:
uid - Unique ID representing an existing graphic.
visible - False if graphic is invisible.
Since:
1.0

getRenderer

public Renderer<Graphic> getRenderer()
Gets the renderer of the GraphicsLayer.

Returns:
Returns the renderer.
Since:
1.0

setRenderer

public void setRenderer(Renderer<Graphic> renderer)
Sets the renderer of the GraphicsLayer.

Parameters:
renderer - The renderer to set.
Since:
1.0

getGraphicIDs

public int[] getGraphicIDs(float x,
                           float y,
                           int tolerance)
Returns the graphics near the Point. The point is specified by the x,y in pixels.

Parameters:
x - the x screen coordinates of the point for searching.
y - the y screen coordinates of the point for searching.
tolerance - the search tolerance in pixels
Returns:
the first 10 graphics within the search tolerance.
Since:
1.0

getGraphicIDs

public int[] getGraphicIDs(float x,
                           float y,
                           int tolerance,
                           int numberOfResults)
Returns the graphics near the Point. The point is specified by the x,y in pixels.

Parameters:
x - the x screen coordinates of the point for searching.
y - the y screen coordinates of the point for searching.
tolerance - the search tolerance in pixels
numberOfResults - the maximum number of result can be returned.
Returns:
the graphics within the search tolerance.
Since:
1.0

createSymbolImage

public android.graphics.Bitmap createSymbolImage(Symbol symbol,
                                                 Geometry geometry,
                                                 int width,
                                                 int height,
                                                 int color)
Returns a swatch image of the given geometry rendered with the specified symbol.

Parameters:
symbol - to render the geometry with.
geometry - the geometry to render in the swatch.
width - the width of the swatch in pixels.
height - the height of the swatch in pixels.
color - the background color in ARGB format.
Returns:
the swatch Bitmap or null.
Since:
1.0

createSymbolImages

public android.graphics.Bitmap[] createSymbolImages(Symbol[] symbol,
                                                    Geometry[] geometry,
                                                    int width,
                                                    int height,
                                                    int color)
Returns a swatch image array of for the given geometries rendered with the symbols.

Parameters:
symbol - a symbol array
geometry - a geometry array
width - the width of the swatch in pixels.
height - the height of the swatch in pixels.
color - the background color in ARGB format.
Returns:
a Bitmap array
Since:
1.0


Copyright © 2010. All Rights Reserved.