Class BasicLayerFactory

  • All Implemented Interfaces:
    Factory

    public class BasicLayerFactory
    extends BasicFactory
    A factory that creates Layer instances.
    • 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:
        • a URL
        • a File
        • a InputStream
        • Element
        • a String holding a file name, a name of a resource on the classpath, or a string representation of a URL

        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:

        • "WMS" for layers that draw their data from a WMS web service.
        • "WWTileService" for layers that draw their data from a WorldWind tile service.
        • "Offline" for layers that draw their data only from the local cache.
        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 source. 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).
      • doCreateFromCapabilities

        protected Layer doCreateFromCapabilities​(OGCCapabilities 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.
      • 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.
      • 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.
      • 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.
      • 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.
      • createShapefileLayer

        protected Layer createShapefileLayer​(org.w3c.dom.Element domElement,
                                             AVList params)
        Creates a shapefile layer described by an XML layer description. This delegates layer construction to the factory class associated with the configuration key "gov.nasa.worldwind.avkey.ShapefileLayerFactory".
        Parameters:
        domElement - the XML element describing the layer to create. The element must contain the shapefile location, and may contain elements specifying shapefile attribute mappings, shape attributes to assign to created shapes, and layer properties.
        params - any parameters to apply when creating the layer.
        Returns:
        a new layer