Class TLcdCompositeGXYLayerFactory

java.lang.Object
com.luciad.view.gxy.TLcdCompositeGXYLayerFactory
All Implemented Interfaces:
ILcdGXYLayerFactory

public class TLcdCompositeGXYLayerFactory extends Object implements ILcdGXYLayerFactory
Composite implementation of ILcdGXYLayerFactory. Any number of layer factories can be added to this composite; the createGXYLayer(com.luciad.model.ILcdModel) method will delegate to the first factory in the list whose createGXYLayer(com.luciad.model.ILcdModel) does not return null for the given input model.

ILcdGXYLayerFactory and TLcdServiceLoader

You can create a factory with good default behavior like so:

    ILcdGXYLayerFactory layerFactory =
        new TLcdCompositeGXYLayerFactory(TLcdServiceLoader.getInstance(ILcdGXYLayerFactory.class));
Using TLcdServiceLoader, it combines all layer factories of all available optional components. It can therefore provide sensible default behavior for almost all data formats. For example, the optional Ecdis maritime charts are styled correctly if this option is available. Do keep in mind that the exact behavior may change in future versions. So if you need full control, or if customization is desired, you're recommended to implement your own layer factories. Many examples are available as sample code. If you annotate them with LcdService and generate the services files using the annotation processor, your factories take precedence when using the default priority (or more important). Please refer to the developer's guide for more information on the annotation processor.

When adding layers to a GXY view for client side use (e.g. TLcdMapJPanel), you will likely want to wrap the layers with an asynchronous layer. That is not taken care of by the layer factories discovered using TLcdServiceLoader as it is undesired for server-side views. Refer to samples.common.formatsupport.GXYOpenSupport for examples on decorating layers with asynchronous behavior.

Since:
2013.0
  • Constructor Details

    • TLcdCompositeGXYLayerFactory

      public TLcdCompositeGXYLayerFactory()
      Creates a new, empty composite layer factory. This factory will not be able to create layers until delegate layer factories are added to the layer factory list.
    • TLcdCompositeGXYLayerFactory

      public TLcdCompositeGXYLayerFactory(Iterable<? extends ILcdGXYLayerFactory> aLayerFactories)
      Creates a new composite layer factory that lazily uses the given Iterable to delegate to.
      Parameters:
      aLayerFactories - a list of layer factories
    • TLcdCompositeGXYLayerFactory

      public TLcdCompositeGXYLayerFactory(ILcdGXYLayerFactory... aLayerFactories)
      Creates a new composite layer factory containing the supplied delegate factories.
      Parameters:
      aLayerFactories - delegate factories to be added to the composite
  • Method Details

    • getGXYLayerFactories

      public List<ILcdGXYLayerFactory> getGXYLayerFactories()
      Returns the list of delegate layer factories contained in this composite. If the composite does not use an Iterable, delegates can be added or removed by modifying this list.
      Returns:
      the list of delegate layer factories in this composite
    • createGXYLayer

      public ILcdGXYLayer createGXYLayer(ILcdModel aModel)
      Delegates to the first layer factory whose createGXYLayer() method does not return null for the given model.
      Specified by:
      createGXYLayer in interface ILcdGXYLayerFactory
      Parameters:
      aModel - the model for which a layer should be created
      Returns:
      a layer created by the selected delegate factory
      See Also: