Adding support for a new data format to Lucy involves multiple concepts:

  • An add-on must at least provide an ILcdModelDecoder for reading the data of the format.

  • If the data needs to be visualized in a view, a layer factory is needed.

  • If workspace support is required, the add-on also needs to provide ALcyWorkspaceObjectCodec codecs to store and restore the models and layers.

  • In addition, an add-on can provide ILcyCustomizerPanelFactory factories for customizing the models, domain objects and layers created by the model decoders and layer factories.

All these concepts are grouped in the support classes of the com.luciad.lucy.format package. This package provides an abstract factory definition, ALcyFormat, and wrappers to implement some common functionalities.

ALcyFormat offers support for model handling, and also supports visualization in the GXY view. Support for the visualization of a format in a Lightspeed view is provided by the ALcyLspFormat class, though.

For example, the TLcyGeoJsonAddOn handles model support and GXY view visualization for the GeoJSON data format, but the TLcyLspGeoJsonFormatAddOn handles functionality related to the visualization of GeoJSON data in a Lightspeed view.

ALcyFormat

The ALcyFormat class follows the Abstract Factory design pattern. It defines several factory methods for concepts that are required to add support for a new data format. You must implement or override these methods with a sub-class. See the Support custom data documentation for an example of an ALcyFormat implementation.

You can pass the concrete factory implementation to TLcyFormatTool, which adds all the concepts created by the factory to the Lucy back-end.

There are several specializations of ALcyFormat that already provide some functionality that is commonly required:

  • ALcyGeneralFormat : this specialization adds workspace support for the models and domain objects of the format. For this support, it assumes that the source name of the model can be retrieved from the model descriptor of the models and that the model decoder always decodes the model elements in the same order. There are some additional assumptions that are documented in the reference documentation of ALcyGeneralFormat.

    In addition to the workspace support, the ALcyGeneralFormat reads the asynchronous paint hint from the ALcyProperties specified at construction.

  • ALcyFileFormat : this sub-class of ALcyGeneralFormat adds support for creating file type descriptors and file type descriptor groups from the ALcyProperties specified at construction.

ALcyFormatWrapper

The Lucy framework provides some common format-related functionality in the form of ALcyFormatWrapper wrappers. The availability of wrappers allows add-ons to re-use format-supporting functionality by wrapping their ALcyFormat. For instance, the TLcyAsynchronousFormatWrapper wrapper provides asynchronous painting functionality for the wrapped ALcyFormat.

The article Adding support for custom static data to a Lightspeed view illustrates the usage and purpose of a few of those format wrappers.

Each of the wrappers in the following ALcyFormatWrapper list makes certain assumptions that are documented in the reference documentation of their classes. Make sure to read the reference documentation of those wrappers to verify that your format corresponds to these assumptions:

  • TLcySafeGuardFormatWrapper: this wrapper ensures that all layer factories, encoders, type providers, workspace codecs, customizer panel factories and so on, operate only on layers and models created by the wrapped format. This means that you don’t need these checks in the wrapped ALcyFormat, resulting in less cluttered and more maintainable code in the wrapped format.

  • TLcyAsynchronousFormatWrapper: this wrapper wraps all the necessary factories and providers of the wrapped format to support asynchronous painting of the layers. By using this class, you allow the base format to focus on the regular appearance of the layer, leaving the asynchronous painting work to this wrapper. By using this wrapper, you also ensures that all layer-related concepts are properly wrapped, so that the customizer panels, workspace codecs, layer selection transfer handlers, and so on, all work in conjunction with the asynchronous painting functionality.

  • TLcyMutableFileFormatWrapper: this wrapper adds workspace support for saving mutable models, for example data that can be graphically edited by the end user.

  • TLcyModelListToTreeNodeFormatWrapper: this wrapper converts instances of TLcdModelList to instances of ILcdModelTreeNode after the creation of the model.

  • TLcyGXYLayerTreeNodeFormatWrapper2: this wrapper provides the necessary support to save and load a workspace containing ILcdLayerTreeNode instances.