It is possible to persist the style and other properties of layers, so that you can use the saved style to create a layer later on. For instance, you can save the colors in which the polygons were drawn, and whether the layer was marked as editable or not.

An ILcdGXYLayerEncoder stores the state of a certain layer to a certain destination, so that this state can be restored later by a corresponding ILcdGXYLayerDecoder.

ILcyLucyEnv provides a centralized mechanism to register and manage such decoders and encoders. The methods addGXYLayerEncoder and removeGXYLayerEncoder allow you to register and unregister layer encoders with the Lucy environment. As a result, those layer encoders become available throughout the Lucy application.

For example, the TLcyMapAddOn uses this mechanism to provide the File → Save Layer Style and File → Save Layer Style As menu items. Some of the data add-ons that come with Lucy also check if a file with saved layer properties is available next to the data file and restore the properties from that file for the layers they create.

You can retrieve a composite layer encoder from ILcyLucyEnv using the method getCompositeGXYLayerEncoder. This composite layer encoder is essentially a layer encoder that combines all registered layer encoders, which means it can encode the state of each layer that a registered layer encoder can encode individually. To encode the properties of a layer, the composite layer encoder finds the first registered layer encoder that can encode the given layer and uses that specific encoder to actually encode the properties of the layer.

Typically, an add-on only registers a layer encoder and decoder if it also registers the layer factory for the same layer type. This makes sense because the layer encoder is tightly coupled to the layer factory, and the layer encoder needs to know how the layer is set up to be able to save the state of the layer. Most format add-ons that come with Lucy add a layer encoder for their format.