com.esri.map
Class Layer

java.lang.Object
  extended by com.esri.map.Layer
Direct Known Subclasses:
ArcGISLocalTiledLayer, ArcGISTiledMapServiceLayer, BingMapsLayer, DynamicLayer, GraphicsLayer, GroupLayer, MessageGroupLayer, OpenStreetMapLayer

public abstract class Layer
extends Object

This class contains methods that the JMap/Map will need to call on individual Layer classes to change extent, draw, etc.


Nested Class Summary
static class Layer.LayerStatus
           
 
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  int _progress
          Default this to 100 so that layers that don't stream, such as feature layers will always contribute 100% to the total streaming progress for the map.
protected  ArrayList<Double> _resolutionList
          The _resolution list.
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
 void addLayerInitializeCompleteListener(LayerInitializeCompleteListener listener)
          Add a listener for the LayerCreateComplete event.
protected abstract  void createNativeLayer()
           
protected  void finalize()
           
protected  void fireLayerCreateCompleteEvent()
          Fire layer create complete event.
protected  void fireLayerCreateErrorEvent(Exception e)
           
protected  void fireLayerCreateErrorEvent(String error)
          Fire layer create error event.
 String getCopyrightText()
          Gets the copyright text.
protected  UserCredentials getCredentialsInternal()
          This method should be used internally whenever credentials are required.
 SpatialReference getDefaultSpatialReference()
          Gets the defaultSpatialReference of the Layer.
 String getDescription()
          Gets the description.
 Exception getException()
           
 Envelope getExtent()
          Gets the current extent.
 Envelope getFullExtent()
          Returns the full extent of the layer.
protected  Envelope getInitialExtent()
          Returns the initial extent of the layer.
 String getInitializationError()
           
protected  long getLayerHandle()
           
abstract  LayerLegendInfoCollection getLegend()
           
 JMap getMap()
          Gets the parent component.
protected  MapServer getMapServer()
           
protected  void getMapServerInfo(String url, UserCredentials credentials)
          Gets the map server info.
protected  void getMapServerLegendInfo(String url, List<DynamicLayerInfo> dynamicLayerInfos)
           
 double getMaxScale()
          Gets the maximum scale at which this layer will be displayed.
 double getMinScale()
          Gets the minimum scale at which this layer will be displayed.
 String getName()
           
 float getOpacity()
          Gets the opacity of the Layer.
 ArcGISPopupInfo getPopupInfo(int sublayerId)
           
 double getResolution()
          Gets the resolution of the Layer.
 List<Double> getResolutionList()
          Get a list of resolutions for each defined zoom level for the layer.
 String getServiceDescription()
          Gets the service description.
 SpatialReference getSpatialReference()
          Gets the current spatial reference of the Layer.
 Layer.LayerStatus getStatus()
          Gets the status of this 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.
protected abstract  void init(boolean isVisible, int[] visibleLayers, String title, float opacity)
          This method is called only when composing a Map from a Web Map.
 void initializeAsync()
          Asynchronously initializes the layer, allowing the application to remain responsive while the layer initializes.
protected abstract  void initializeNativeLayer()
           
protected  LayerLegendInfoCollection internalGetLayerLegendInfos(String url, List<DynamicLayerInfo> dynamicLayerInfos)
           
protected abstract  void internalInit()
           
protected  boolean isHidingNoDataTiles()
           
protected  boolean isInitialized()
           
protected  boolean isReady()
          Returns true if this layer is initialized.
 boolean isShowingCopyright()
          Returns whether this layer's copyright should be shown.
 boolean isVisible()
          Gets the visibility of the Layer.
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 reinitializeAsync(UserCredentials userCredentials)
          Asynchronously re-initializes a failed layer that has failed due to missing credentials.
 void removeLayerInitializeCompleteListener(LayerInitializeCompleteListener listener)
          Remove a listener for the LayerCreateComplete event.
 void setCopyrightText(String copyrightText)
          Sets the copyright text.
protected  void setCredentials(UserCredentials credentials)
          Sets the credentials of the Layer.
protected  void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
          Sets the defaultSpatialReference of the Layer.
 void setDescription(String description)
          Sets the description.
protected  void setError(String errorMessage)
          Sets the error.
protected  void setException(Exception e)
           
protected  void setFullExtent(Envelope extent)
           
protected  void setInitialExtent(Envelope e)
          Sets the initial extent of layer.
protected  void setLayerHandle(long layerHandle)
           
protected  void setMap(JMap parent)
          Every layer is provided a reference to the parent JComponent that contains that layer.
protected  void setMapServer(MapServer _mapServer)
           
 void setName(String name)
          Sets the name.
 void setOpacity(float opacity)
          Sets the opacity of the Layer.
 void setPopupInfos(Map<Integer,ArcGISPopupInfo> popupInfos)
           
 void setServiceDescription(String serviceDescription)
          Sets the description.
 void setShowingCopyright(boolean show)
          Sets whether to show this layer's copyright.
protected  void setStatus(Layer.LayerStatus status)
          Sets the status.
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_progress

protected int _progress
Default this to 100 so that layers that don't stream, such as feature layers will always contribute 100% to the total streaming progress for the map.


_resolutionList

protected ArrayList<Double> _resolutionList
The _resolution list.


_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.


Layer

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

Method Detail

getLayerHandle

protected long getLayerHandle()

getPopupInfo

public ArcGISPopupInfo getPopupInfo(int sublayerId)

setPopupInfos

public void setPopupInfos(Map<Integer,ArcGISPopupInfo> popupInfos)

setLayerHandle

protected void setLayerHandle(long layerHandle)

getStatus

public Layer.LayerStatus getStatus()
Gets the status of this layer. For example uninitialized or initialized.

Returns:
the status

setStatus

protected void setStatus(Layer.LayerStatus status)
Sets the status.

Parameters:
status - the new status

isReady

protected boolean isReady()
Returns true if this layer is initialized. The layer is ready to navigate.

Returns:
true, if is ready

isInitialized

protected boolean isInitialized()

isShowingCopyright

public boolean isShowingCopyright()
Returns whether this layer's copyright should be shown. Note that copyright will not be shown if the corresponding JMap copyright is not showing.

Since:
10.1.1
See Also:
JMap.isShowingCopyright(), JMap.setShowingCopyright(boolean)

setShowingCopyright

public void setShowingCopyright(boolean show)
Sets whether to show this layer's copyright. Note that copyright will not be shown if the corresponding JMap copyright is not showing.

Parameters:
show - true to show copyright, false otherwise.
Since:
10.1.1
See Also:
JMap.isShowingCopyright(), JMap.setShowingCopyright(boolean)

getCopyrightText

public String getCopyrightText()
Gets the copyright text. For service layers this is defined by the service when the layer initializes.

Returns:
the copyright text

setCopyrightText

public void setCopyrightText(String copyrightText)
Sets the copyright text. To display this copyright text, consider using a MapOverlay.

Parameters:
copyrightText - the new copyright text

getDescription

public String getDescription()
Gets the description. The description is defined by the service when the layer initializes.

Returns:
the description

setDescription

public void setDescription(String description)
Sets the description.

Parameters:
description - the new description

getName

public String getName()

setName

public void setName(String name)
Sets the name. The name is defined by the service when the layer initializes so this method is typically used after the service layer is initialized.

Parameters:
name - the new name

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.

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

getServiceDescription

public String getServiceDescription()
Gets the service description.

Returns:
the service description

setServiceDescription

public void setServiceDescription(String serviceDescription)
Sets the description.

Parameters:
serviceDescription - the new description

getInitializationError

public String getInitializationError()

getMapServerInfo

protected void getMapServerInfo(String url,
                                UserCredentials credentials)
                         throws Exception
Gets the map server info.

Parameters:
url - the URL
Throws:
Exception
PeProjectionException

getMapServerLegendInfo

protected void getMapServerLegendInfo(String url,
                                      List<DynamicLayerInfo> dynamicLayerInfos)

setError

protected void setError(String errorMessage)
Sets the error.

Parameters:
errorMessage - the new error

setException

protected void setException(Exception e)

addLayerInitializeCompleteListener

public void addLayerInitializeCompleteListener(LayerInitializeCompleteListener listener)
Add a listener for the LayerCreateComplete event. If the layer is already initialized or is in error then the listener will be immediately called.

Parameters:
listener - Class implementing LayerCreateCompleteListener

removeLayerInitializeCompleteListener

public void removeLayerInitializeCompleteListener(LayerInitializeCompleteListener listener)
Remove a listener for the LayerCreateComplete event.

Parameters:
listener - Class implementing LayerCreateCompleteListener

initializeAsync

public void initializeAsync()
Asynchronously initializes the layer, allowing the application to remain responsive while the layer initializes.


internalInit

protected abstract void internalInit()

reinitializeAsync

public void reinitializeAsync(UserCredentials userCredentials)
Asynchronously re-initializes a failed layer that has failed due to missing credentials. If the layer shows successful initialization status then this method does nothing.

Parameters:
userCredentials - the user credentials

getException

public Exception getException()

getMap

public JMap getMap()
Gets the parent component. Every layer is provided a reference to the parent JComponent that contains that layer. Layers can use the existence or absence of a parent to determine if are being used in a JMap.

Returns:
the parent component

setMap

protected void setMap(JMap parent)
Every layer is provided a reference to the parent JComponent that contains that layer. Layers can use the existence or absence of a parent to determine if are being used in a JMap.

Parameters:
parent - the new parent component

getResolution

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

Returns:
resolution.

isHidingNoDataTiles

protected boolean isHidingNoDataTiles()

init

protected abstract void init(boolean isVisible,
                             int[] visibleLayers,
                             String title,
                             float opacity)
This method is called only when composing a Map from a Web Map. The web map contains properties that every layer should be initialized with, up front.

Parameters:
isVisible -
visibleLayers -
title -
opacity -

fireLayerCreateCompleteEvent

protected void fireLayerCreateCompleteEvent()
Fire layer create complete event.


fireLayerCreateErrorEvent

protected void fireLayerCreateErrorEvent(String error)
Fire layer create error event.

Parameters:
error - the error

fireLayerCreateErrorEvent

protected void fireLayerCreateErrorEvent(Exception e)

getResolutionList

public List<Double> getResolutionList()
Get a list of resolutions for each defined zoom level for the layer. This list is ordered with the lowest resolution (most zoomed out) first and the highest (most zoomed in) last. This list applies to ArcGISTiledMapServiceLayers only; otherwise the list is empty.

Returns:
List of resolutions defined for each zoom level of this layer.

getDefaultSpatialReference

public SpatialReference getDefaultSpatialReference()
Gets the defaultSpatialReference of the Layer. For service layers this is defined by the service.

Returns:
Returns the defaultSpatialReference.

setDefaultSpatialReference

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

Parameters:
defaultSpatialReference - The defaultSpatialReference to set.

getSpatialReference

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

Returns:
spatial reference.

getMinScale

public double getMinScale()
Gets the minimum scale at which this layer will be displayed. For service layers this is defined by the service. For a GraphicsLayer there is no minimum scale.

Returns:
the minimum scale

getMaxScale

public double getMaxScale()
Gets the maximum scale at which this layer will be displayed. For service layers this is defined by the service. For a GraphicsLayer there is no maximum scale.

Returns:
the maximum scale

updateSpatialReferenceStatus

protected void updateSpatialReferenceStatus(int SRStatus)

createNativeLayer

protected abstract void createNativeLayer()

initializeNativeLayer

protected abstract void initializeNativeLayer()

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.


isVisible

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

Returns:
true if visible.

setVisible

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

Parameters:
visible - The visibility to set.

getOpacity

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

Returns:
the opacity.

setOpacity

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

Parameters:
opacity - the opacity to set.

setInitialExtent

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

Parameters:
e - --an Envelope object.

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 Envelope getExtent()
Gets the current extent.

Returns:
a polygon which represents the current extent.

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

lock

protected long lock()

unlock

protected void unlock(long handle)

getMapServer

protected MapServer getMapServer()

setMapServer

protected void setMapServer(MapServer _mapServer)

getLegend

public abstract LayerLegendInfoCollection getLegend()

internalGetLayerLegendInfos

protected LayerLegendInfoCollection internalGetLayerLegendInfos(String url,
                                                                List<DynamicLayerInfo> dynamicLayerInfos)

getCredentialsInternal

protected UserCredentials getCredentialsInternal()
This method should be used internally whenever credentials are required. Use this rather than getCredentials as it returns a reference rather than a copy.

Returns:
a reference to the current user credentials
Since:
10.1.1

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.

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


Copyright © 2012. All Rights Reserved.