Class TLcyCompositeGXYLayerFactory

java.lang.Object
com.luciad.lucy.util.TLcyGenericComposite<ILcdGXYLayerFactory>
com.luciad.lucy.map.TLcyCompositeGXYLayerFactory
All Implemented Interfaces:
ILcdGXYLayerFactory, Iterable<ILcdGXYLayerFactory>

public class TLcyCompositeGXYLayerFactory extends TLcyGenericComposite<ILcdGXYLayerFactory> implements ILcdGXYLayerFactory

Composite implementation (see composite design pattern) of ILcdGXYLayerFactory. It keeps a list of associated ILcdGXYLayerFactorys: one can add and remove other ILcdGXYLayerFactorys to this ILcdGXYLayerFactory. When it is asked to create a layer, it loops over its associated ILcdGXYLayerFactorys to find the first one that returns a valid layer (means createGXYLayer does not return null). That layer will then be returned.

When creating a new TLcyCompositeGXYLayerFactory using the default constructor (see TLcyCompositeGXYLayerFactory()), the created instance will only work on/with the ILcdGXYLayerFactorys registered on this composite instance (see addGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory) and removeGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)).

When creating a new TLcyCompositeGXYLayerFactory using the constructor specifying an ILcyLucyEnv instance (see TLcyCompositeGXYLayerFactory(com.luciad.lucy.ILcyLucyEnv), the created instance will work on the Lucy back-end services. It will use all registered ILcdGXYLayerFactory instances of the Lucy back-end, adding and/or removing an ILcdGXYLayerFactory will add/remove the ILcdGXYLayerFactory as service from Lucy, ... .

Creating an ILcdGXYLayer for an ILcdModel using the back-end based implementation can be done by creating a new instance of this class:


 //Create a new instance whenever you need it.
 TLcyCompositeGXYLayerFactory factory = new TLcyCompositeGXYLayerFactory( aLucyEnv );
 ILcdGXYLayer layer = factory.createGXYLayer( aModel );
 //There is no need to keep a reference to the composite instance, you can create a new one
 //the next time you would need it
 factory = null;
 
  • Constructor Details

  • Method Details

    • addGXYLayerFactory

      public void addGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)

      Adds the given ILcdGXYLayerFactory to this composite layer factory. The ILcdGXYLayerFactory should only create ILcdGXYLayer's for ILcdModel's it knows about. It should not simply create a ILcdGXYLayer for every ILcdModel it gets passed in its createGXYLayer, but instead verify if the given ILcdModel is supported, e.g. by testing the ILcdModelDescriptor of the ILcdModel. If the ILcdModel passed in the createGXYLayer method is not supported, it should return null as specified in the ILcdGXYLayerFactory interface.

      If the constructor specifying an ILcyLucyEnv is used, the ILcdGXYLayerFactory will be registered as a service on the Lucy back-end (see ILcyLucyEnv.addService(Object, int)). When calling ILcyLucyEnv.getServices(Class) afterwards, aGXYLayerFactory will only be included in the returned list when the requested class was ILcdGXYLayerFactory.class.
      Note: if you want to remove the registered ILcdGXYLayerFactory afterwards, use removeGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory) and not ILcyLucyEnv.removeService(Object).

      Parameters:
      aGXYLayerFactory - The layer factory to add.
      See Also:
    • removeGXYLayerFactory

      public void removeGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)

      Removes the given ILcdGXYLayerFactory from this composite layer factory. If the given layer factory was never added before, nothing happens.

      If the constructor specifying an ILcyLucyEnv is used, the ILcdGXYLayerFactory will be removed as service from the Lucy back-end (see ILcyLucyEnv.removeService(Object)).
      Note: it is only possible to remove ILcdGXYLayerFactory instances which were registered using the addGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory) method.

      Parameters:
      aGXYLayerFactory - The layer factory to remove.
      See Also:
    • getGXYLayerFactoryCount

      public int getGXYLayerFactoryCount()

      Returns the number of currently registered layer factories.

      Returns:
      The number of associated ILcdGXYLayerFactorys.
    • getGXYLayerFactory

      public ILcdGXYLayerFactory getGXYLayerFactory(int aIndex)

      Returns the ILcdGXYLayerFactory at the given index.

      Returns:
      The associated ILcdGXYLayerFactory at the given index.
    • createGXYLayer

      public ILcdGXYLayer createGXYLayer(ILcdModel aModel)
      Implementation of ILcdGXYLayerFactory.createGXYLayer. Loops over all associated ILcdGXYLayerFactorys to find the first suitable layer factory. A layer factory is considered suitable when the invocation of its createGXYLayer method does not return null.
      Specified by:
      createGXYLayer in interface ILcdGXYLayerFactory
      Parameters:
      aModel - The model to create a layer for.
      Returns:
      The created layer, or null if no suitable layer factory could be found.
      See Also: