com.esri.android.map
Class Layer

java.lang.Object
  extended by com.esri.android.map.Layer
Direct Known Subclasses:
DynamicLayer, GraphicsLayer, GroupLayer, TiledLayer

public abstract class Layer
extends Object

The base layer for all layers that can be added into MapView.

Since:
1.0

Field Summary
protected  UserCredentials credentials
          Gets the direct access of the credentials; You can access the credentials by the getCredentials() or setCredentials(UserCredentials); but those two methods copy the instance internally.
protected  long nativeHandle
           
protected  Map<Integer,PopupInfo> popUpInfos
           
protected  Object serviceInfo
           
 
Constructor Summary
  Layer()
          Instantiates an object of Layer.
protected Layer(boolean initLayer)
           
protected Layer(long handle)
          Instantiates an object of Layer.
 
Method Summary
protected  void changeStatus(OnStatusChangedListener.STATUS status)
          Changes the STATUS of the layer and notifies the listener.
protected abstract  long create()
           
protected  void finalize()
           
 UserCredentials getCredentials()
          Gets a copy of the credentials attached to the Layer.
 SpatialReference getDefaultSpatialReference()
          Gets the defaultSpatialReference of the Layer.
protected  float getDpi()
           
 Polygon getExtent()
          Gets the current extent.
 Envelope getFullExtent()
          Returns the full extent of the layer.
 int getHeight()
          Gets the height of the Layer in screen units.
 long getID()
          Return the Layer runtime ID which is a long integer.
protected  Envelope getInitialExtent()
          Returns the initial extent of the layer.
 String getName()
          Gets the name of the layer.
 float getOpacity()
          Gets the opacity of the Layer.
 Layer getParent()
          Returns parent layer if the layer is in a group layer otherwise returning null.
protected  ExecutorService getPoolExecutor()
          Returns the ThreadPoolExecutor based on the context.
 PopupInfo getPopupInfo(int sublayerId)
          Gets the PopupInfo associated with the sub-layer id.
 String getQueryUrl(int subLayerId)
           
 double getResolution()
          Gets the resolution of the Layer.
protected  ExecutorService getServiceExecutor()
          Returns the ThreadPoolExecutor based on the context.
 SpatialReference getSpatialReference()
          Gets the current spatial reference of the Layer.
 String getTitle()
          Gets the title of the Layer.
 String getUrl()
          Gets the URL of the map service associated with the layer.
 int getUrlHashCode()
          A convenience method that returns the hash code of the map service URL.
 int getWidth()
          Gets the width of the Layer in screen units.
protected abstract  void initLayer()
          Initializes the layer.
 boolean isInitialized()
          Gets the initialized of the Layer.
 boolean isRecycled()
          Returns true or false if the Layer object has been recycled.
 boolean isShowLegend()
          Returns true if legend of the layer will be shown up; by default it is true; The property is usually defined in the web map, a operation layer legend could be on or off.
 boolean isVisible()
          Gets the visibility of the Layer.
 boolean isWebMapBaselayer()
          Returns true if the layer is used as base layer in a web map.
protected
<T> T
loadServiceInfo(Callable<T> task)
          If the Layer is loaded as a WebMapLayer and the OnWebMapLoadListener is specified, the service information will be loaded interactively.
protected  long lock()
           
 void recycle()
          Releases resources referenced by the Layer so that they can be recycled.
 void reinitializeLayer(UserCredentials usercredentials)
          Re-initializes the layer with the given credentials.
protected  void setCredentials(UserCredentials credentials)
          Sets the credentials of the Layer.
protected  void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
          Sets the defaultSpatialReference of the Layer.
protected  void setFullExtent(Envelope extent)
           
protected  void setInitialExtent(Envelope e)
          Sets the initial extent of layer.
 void setName(String name)
          Sets the layer name.
 void setOnStatusChangedListener(OnStatusChangedListener onStatusChangedListener)
          Sets the onStatusChangedListener.
 void setOpacity(float opacity)
          Sets the opacity of the Layer.
 void setPopupInfos(Map<Integer,PopupInfo> popUpInfos)
          Sets the popup infos.
 void setQueryUrls(Map<Integer,String> queryUrls)
           
protected  void setUrl(String url)
          Sets the URL of the map service associated with the layer.
 void setVisible(boolean visible)
          Sets the visibility of the Layer.
protected  void unlock(long handle)
           
protected  void updateSpatialReferenceStatus(int SRStatus)
          The callback method is invoked when the layer is added to map.
protected  boolean verifyCredentials()
          Returns true if the credentials is valid.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nativeHandle

protected volatile long nativeHandle

popUpInfos

protected Map<Integer,PopupInfo> popUpInfos

credentials

protected UserCredentials credentials
Gets the direct access of the credentials; You can access the credentials by the getCredentials() or setCredentials(UserCredentials); but those two methods copy the instance internally.


serviceInfo

protected Object serviceInfo
Constructor Detail

Layer

protected Layer(boolean initLayer)

Layer

public Layer()
Instantiates an object of Layer.

Since:
1.0

Layer

protected Layer(long handle)
Instantiates an object of Layer.

Method Detail

loadServiceInfo

protected <T> T loadServiceInfo(Callable<T> task)
                     throws Exception
If the Layer is loaded as a WebMapLayer and the OnWebMapLoadListener is specified, the service information will be loaded interactively.

Parameters:
task - the Task to load the service information.
Returns:
the service information.
Throws:
Exception

create

protected abstract long create()

initLayer

protected abstract void initLayer()
Initializes the layer. The implementation should submit the OnStatusChangedListener.STATUS event accordingly.


reinitializeLayer

public void reinitializeLayer(UserCredentials usercredentials)
Re-initializes the layer with the given credentials.

Parameters:
usercredentials - the new credentials to try.
Since:
1.0

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

recycle

public void recycle()
Releases resources referenced by the Layer so that they can be recycled.

Since:
1.0

isRecycled

public boolean isRecycled()
Returns true or false if the Layer object has been recycled.

Returns:
boolean
Since:
1.0

isVisible

public boolean isVisible()
Gets the visibility of the Layer.

Returns:
true if visible.
Since:
1.0

setVisible

public void setVisible(boolean visible)
Sets the visibility of the Layer.

Parameters:
visible - The visibility to set.
Since:
1.0

getOpacity

public float getOpacity()
Gets the opacity of the Layer.

Returns:
the opacity.
Since:
1.0

setOpacity

public void setOpacity(float opacity)
Sets the opacity of the Layer.

Parameters:
opacity - the opacity to set.
Since:
1.0

setOnStatusChangedListener

public void setOnStatusChangedListener(OnStatusChangedListener onStatusChangedListener)
Sets the onStatusChangedListener. When initialize a Layer, the OnStatusChangedListener notifies you the status changes for OnStatusChangedListener.STATUS.INITIALIZED or OnStatusChangedListener.STATUS.INITIALIZATION_FAILED. When the initialization is failed, you can use the OnStatusChangedListener.STATUS.getError() to get the error details.

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

changeStatus

protected void changeStatus(OnStatusChangedListener.STATUS status)
Changes the STATUS of the layer and notifies the listener.

Parameters:
status - the new STATUS.

isInitialized

public boolean isInitialized()
Gets the initialized of the Layer.

Returns:
Returns the initialized.
Since:
1.0

getName

public String getName()
Gets the name of the layer. The name is the name of the service if the layer is associated with a service, otherwise it is null. You should not call this method until the layer is initialized.

Returns:
the name of the associated service or null otherwise.
Since:
1.0

setName

public void setName(String name)
Sets the layer name.

Parameters:
name - a String
Since:
1.0

setUrl

protected void setUrl(String url)
Sets the URL of the map service associated with the layer.

Parameters:
url - the URL pointing to your map service.

getUrl

public String getUrl()
Gets the URL of the map service associated with the layer.

Returns:
the URL as a string.
Since:
1.0

setQueryUrls

public void setQueryUrls(Map<Integer,String> queryUrls)
Parameters:
queryUrls -

getQueryUrl

public String getQueryUrl(int subLayerId)
Parameters:
subLayerId -
Returns:
the queryUrl for the sub-layer ID

getUrlHashCode

public int getUrlHashCode()
A convenience method that returns the hash code of the map service URL. The hash codes for map service URLs are cached and this method spares the effort of the developer programmatically calculating the hash code.

Returns:
integer of the hashcode
Since:
1.0

setInitialExtent

protected void setInitialExtent(Envelope e)
Sets the initial extent of layer.

Parameters:
e - --an Envelope object.

getCredentials

public UserCredentials getCredentials()
Gets a copy of the credentials attached to the Layer.

Returns:
Returns the credentials.
Since:
1.0

setCredentials

protected void setCredentials(UserCredentials credentials)
Sets the credentials of the Layer. The layer holds the copy of the given instance.

Parameters:
credentials - The credentials to set.

getInitialExtent

protected Envelope getInitialExtent()
Returns the initial extent of the layer. Returns the full extent if the initial extent is not valid.

Returns:
an Envelope object

setFullExtent

protected void setFullExtent(Envelope extent)

getExtent

public Polygon getExtent()
Gets the current extent.

Returns:
a polygon which represents the current extent.
Since:
1.0

getFullExtent

public Envelope getFullExtent()
Returns the full extent of the layer. Returns NULL if the layer does not have a full extent.

Returns:
an Envelope object
Since:
1.0

updateSpatialReferenceStatus

protected void updateSpatialReferenceStatus(int SRStatus)
The callback method is invoked when the layer is added to map. 0 - Spatial Reference Invalid 1 - Spatial Reference NotNeeded 2 - Spatial Reference Projected 3 - Spatial Reference Good

Parameters:
SRStatus - an integer indicating the spatial reference status of layer

getID

public long getID()
Return the Layer runtime ID which is a long integer. A zero will be returned if the Layer object is invalid.

Returns:
a long integer.
Since:
1.0

getTitle

public String getTitle()
Gets the title of the Layer. WebMap may define title of a layer, when the layer is instantiated from a WebMap, it may have a tile.

Returns:
Returns the title.
Since:
1.0

getPopupInfo

public PopupInfo getPopupInfo(int sublayerId)
Gets the PopupInfo associated with the sub-layer id.

Parameters:
sublayerId - the sublayer id
Returns:
PopupInfo
Since:
1.0

setPopupInfos

public void setPopupInfos(Map<Integer,PopupInfo> popUpInfos)
Sets the popup infos.

Parameters:
popUpInfos - the popup infos
Since:
1.0

getSpatialReference

public SpatialReference getSpatialReference()
Gets the current spatial reference of the Layer.

Returns:
spatial reference.
Since:
1.0

getResolution

public double getResolution()
Gets the resolution of the Layer.

Returns:
resolution.
Since:
1.0

getWidth

public int getWidth()
Gets the width of the Layer in screen units.

Returns:
width.
Since:
1.0

getHeight

public int getHeight()
Gets the height of the Layer in screen units.

Returns:
height.
Since:
1.0

getDefaultSpatialReference

public SpatialReference getDefaultSpatialReference()
Gets the defaultSpatialReference of the Layer.

Returns:
Returns the defaultSpatialReference.
Since:
1.0

isWebMapBaselayer

public boolean isWebMapBaselayer()
Returns true if the layer is used as base layer in a web map.

Returns:
boolean
Since:
1.0

isShowLegend

public boolean isShowLegend()
Returns true if legend of the layer will be shown up; by default it is true; The property is usually defined in the web map, a operation layer legend could be on or off.

Returns:
boolean
Since:
2.0

getParent

public Layer getParent()
Returns parent layer if the layer is in a group layer otherwise returning null.

Returns:
Layer a Layer object
Since:
2.0

setDefaultSpatialReference

protected void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
Sets the defaultSpatialReference of the Layer.

Parameters:
defaultSpatialReference - The defaultSpatialReference to set.

getDpi

protected float getDpi()

verifyCredentials

protected boolean verifyCredentials()
Returns true if the credentials is valid.

Returns:

lock

protected long lock()

unlock

protected void unlock(long handle)

getPoolExecutor

protected ExecutorService getPoolExecutor()
Returns the ThreadPoolExecutor based on the context.


getServiceExecutor

protected ExecutorService getServiceExecutor()
Returns the ThreadPoolExecutor based on the context.



Copyright © 2010. All Rights Reserved.