NASA World Wind

gov.nasa.worldwind.layers
Class BasicLayerFactory

java.lang.Object
  extended by gov.nasa.worldwind.BasicFactory
      extended by gov.nasa.worldwind.layers.BasicLayerFactory
All Implemented Interfaces:
Factory

public class BasicLayerFactory
extends BasicFactory

A factory that creates Layer instances.


Constructor Summary
BasicLayerFactory()
          Creates an instance of BasicLayerFactory; otherwise does nothing.
 
Method Summary
 java.lang.Object createFromConfigSource(java.lang.Object configSource, AVList params)
          Creates a layer or layer list from a general configuration source.
 java.lang.Object createFromDataConfig(DataConfiguration dataConfig, AVList params)
          Creates a layer from a data configuration.
protected  Layer createFromLayerDocument(org.w3c.dom.Element domElement, AVList params)
          Create a layer described by an XML layer description.
protected  LayerList createLayerList(org.w3c.dom.Element[] layerElements, AVList params)
          Create a list of layers described by an array of XML layer description elements.
protected  LayerList[] createLayerLists(org.w3c.dom.Element[] elements, AVList params)
          Create a collection of layer lists and their included layers described by an array of XML layer-list description elements.
protected  Layer createTiledImageLayer(org.w3c.dom.Element domElement, AVList params)
          Create a TiledImageLayer layer described by an XML layer description.
protected  Layer doCreateFromCapabilities(Capabilities caps, AVList params)
          Implemented by subclasses to perform the actual object creation.
protected  Layer doCreateFromDataConfig(DataConfiguration dataConfig, AVList params)
           
protected  java.lang.Object doCreateFromElement(org.w3c.dom.Element domElement, AVList params)
          Create the objects described in an XML element containing layer and/or layer-list descriptions.
 
Methods inherited from class gov.nasa.worldwind.BasicFactory
create, createFromCapabilities
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLayerFactory

public BasicLayerFactory()
Creates an instance of BasicLayerFactory; otherwise does nothing.

Method Detail

createFromConfigSource

public java.lang.Object createFromConfigSource(java.lang.Object configSource,
                                               AVList params)
Creates a layer or layer list from a general configuration source. The source can be one of the following:

For tiled image layers, this maps the serviceName attribute of the Layer/Service element of the XML configuration file to the appropriate base tiled image layer type. Service types recognized are:

Specified by:
createFromConfigSource in interface Factory
Overrides:
createFromConfigSource in class BasicFactory
Parameters:
configSource - the configuration source. See above for supported types.
params - key-value parameters to override or supplement the information provided in the specified configuration. May be null.
Returns:
a layer or layer list.
Throws:
java.lang.IllegalArgumentException - if the configuration file name is null or an empty string.
WWUnrecognizedException - if the layer service type is unrecognized.
WWRuntimeException - if object creation fails. The exception indicating the source of the failure is included as the Throwable.initCause(Throwable).

createFromDataConfig

public java.lang.Object createFromDataConfig(DataConfiguration dataConfig,
                                             AVList params)
Creates a layer from a data configuration.

Maps the Layer/layerType configuration parameter to the appropriate layer type. Layer types recognized are:

For tiled image layers, this maps the Layer/Service/serviceName configuration property to the appropriate base tiled image layer type. Service types recognized are:

Specified by:
createFromDataConfig in interface Factory
Overrides:
createFromDataConfig in class BasicFactory
Parameters:
dataConfig - the configuration information describing the component.
params - key-value parameters which override or supplement the information provided in the specified configuration. A null reference is permitted.
Returns:
a layer.
Throws:
java.lang.IllegalArgumentException - if the data configuration is null.
WWUnrecognizedException - if the service type is unrecognized.
WWRuntimeException - if object creation fails. The exception indicating the source of the failure is included as the Throwable.initCause(Throwable).

createFromLayerDocument

protected Layer createFromLayerDocument(org.w3c.dom.Element domElement,
                                        AVList params)
Create a layer described by an XML layer description.

Parameters:
domElement - the XML element describing the layer to create.
params - any parameters to apply when creating the layer.
Returns:
a new layer
Throws:
WWUnrecognizedException - if the layer type or service type given in the describing element is unrecognized.
See Also:
createTiledImageLayer(org.w3c.dom.Element, gov.nasa.worldwind.avlist.AVList).

createLayerList

protected LayerList createLayerList(org.w3c.dom.Element[] layerElements,
                                    AVList params)
Create a list of layers described by an array of XML layer description elements.

Any exceptions occurring during creation of the layers are logged and not re-thrown. The layers associated with the exceptions are not included in the returned layer list.

Parameters:
layerElements - the XML elements describing the layers to create.
params - any parameters to apply when creating the layers.
Returns:
a layer list containing the specified layers.

createLayerLists

protected LayerList[] createLayerLists(org.w3c.dom.Element[] elements,
                                       AVList params)
Create a collection of layer lists and their included layers described by an array of XML layer-list description elements.

Any exceptions occurring during creation of the layer lists or their included layers are logged and not re-thrown. The layers associated with the exceptions are not included in the returned layer list.

Parameters:
elements - the XML elements describing the layer lists to create.
params - any parameters to apply when creating the included layers.
Returns:
an array containing the specified layer lists.

createTiledImageLayer

protected Layer createTiledImageLayer(org.w3c.dom.Element domElement,
                                      AVList params)
Create a TiledImageLayer layer described by an XML layer description.

Parameters:
domElement - the XML element describing the layer to create. The element must inculde a service name identifying the type of service to use to retrieve layer data. Recognized service types are "Offline", "WWTileService" and "OGC:WMS".
params - any parameters to apply when creating the layer.
Returns:
a new layer
Throws:
WWUnrecognizedException - if the service type given in the describing element is unrecognized.

doCreateFromCapabilities

protected Layer doCreateFromCapabilities(Capabilities caps,
                                         AVList params)
Description copied from class: BasicFactory
Implemented by subclasses to perform the actual object creation. This default implementation always returns null.

Overrides:
doCreateFromCapabilities in class BasicFactory
Parameters:
caps - the capabilities document.
params - a list of configuration properties. These properties override any specified in the capabilities document. The list should contain the AVKey.LAYER_NAMES property for services that define layers, indicating which named layers described in the capabilities document to create. If this argumet is null or contains no layers, the first named layer is used.
Returns:
the requested object.

doCreateFromDataConfig

protected Layer doCreateFromDataConfig(DataConfiguration dataConfig,
                                       AVList params)
                                throws java.lang.Exception
Throws:
java.lang.Exception

doCreateFromElement

protected java.lang.Object doCreateFromElement(org.w3c.dom.Element domElement,
                                               AVList params)
                                        throws java.lang.Exception
Create the objects described in an XML element containing layer and/or layer-list descriptions. Nested layer lists and included layers are created recursively.

Overrides:
doCreateFromElement in class BasicFactory
Parameters:
domElement - an XML element describing the layers and/or layer lists.
params - any properties to apply when creating the included layers.
Returns:
a Layer, LayerList or array of LayerLists, as described by the specified description.
Throws:
java.lang.Exception - if an exception occurs during creation. Exceptions occurring during creation of internal layers or layer lists are not re-thrown but are logged. The layer or layer list associated with the exception is not contained in the returned object.

NASA World Wind