Class ALcyLspStyleFileFormat

Direct Known Subclasses:
ALcyLspStyleFormat

public abstract class ALcyLspStyleFileFormat extends ALcyLspGeneralFormat

This ALcyLspFormat is designed for layers where the layer style is stored into a style file. The format allows to configure a default style file which will be applied to every layer created in the layer factory. It also supports to store a style file next to the source file of the model. Those style files will be applied on the layer created for that model.

It is up to the extensions of this class to create the ILcyLayerStyleProvider and ILcyLayerStyleCodec. When your layer uses an ILspCustomizableStyler, it might be better to extend from ALcyLspStyleFormat directly. That format provides default implementations for the layer style provider and codec.

Configuration options

This format checks for the following properties in the ALcyProperties:


   # The path to the file containing the default style to apply on each created layer
   shortPrefix.defaultStyleFile = path/to/defaultStyleFile.sty
 

Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper before plugging it into the Lucy back-end.

Since:
2012.1
See Also:
  • Field Details

    • DEFAULT_STYLE_FILE_SUFFIX

      public static final String DEFAULT_STYLE_FILE_SUFFIX

      Suffix to use in the properties to specify the location of the default style file. This style will be applied on every layer created by the layer factory of this format. The createLayerStyleCodecs() will be used to apply this style on the layer.

      Note that the default style file should be included in one of the created file type descriptors. If this is not the case, the default style file will be simply ignored.

      The complete key to be used in the properties is the short prefix of the format + DEFAULT_STYLE_FILE_SUFFIX.

      See Also:
  • Constructor Details

    • ALcyLspStyleFileFormat

      protected ALcyLspStyleFileFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aProperties, ILcdFilter<ILcdModel> aModelFilter)
      Create a new style file format
      Parameters:
      aLucyEnv - The Lucy back-end
      aLongPrefix - The long prefix of this format
      aShortPrefix - The short prefix of this format
      aProperties - The properties
      aModelFilter - Filter used to determine whether a model can be handled by this format. When the model can be handled by this format, it should be accepted by the filter. Filter must not be null. null models will never be passed to the filter, but always rejected.
  • Method Details

    • canHandleModel

      public final boolean canHandleModel(ILcdModel aModel)
      Description copied from class: ALcyLspFormat

      Returns true if and only if the given model can be visualized by this format.

      Specified by:
      canHandleModel in class ALcyLspFormat
      Parameters:
      aModel - The model to check
      Returns:
      true if and only if the given model can be visualized by this format.
    • createLayerFactory

      protected final ILspLayerFactory createLayerFactory()

      Creates a layer factory for this format, based on a layer factory created by createLayerFactoryImpl. This method may return null.

      Specified by:
      createLayerFactory in class ALcyLspFormat
      Returns:
      The ILspLayerFactory for this format. May be null
      See Also:
    • createLayerStyleCodecFileTypeDescriptors

      protected ALcyFileTypeDescriptor[] createLayerStyleCodecFileTypeDescriptors()

      Creates ALcyFileTypeDescriptors for the ILcyLayerStyleCodecs. The length of the returned array must be equal to that of ALcyLspFormat.createLayerStyleCodecs().

      The default implementation returns a zero-length array.

      This format uses these ALcyFileTypeDescriptor instances to determine whether a style file is located next to source file of a layer, and apply that style when such a layer is created in the layer factory. The layer factory will only try to find style files with an extension defined by the returned ALcyFileTypeDescriptors of this method.

      Another example usage of these ALcyFileTypeDescriptor instances is the File | Save layer style action which is available in Lucy. It allows to save the style of a layer to a file ending with an extension as specified by these ALcyFileTypeDescriptors. When no ALcyFileTypeDescriptors are available (or only null ALcyFileTypeDescriptors) it will not be possible to save the layer style to file.

      The default implementation returns a file type descriptor based on the info contained in the properties of this format, or a default file type descriptor in case the properties do not contain this info. The file type descriptor can be configured in the configuration file as follows (where "shortPrefix." stands for the short prefix of this format):

         shortPrefix.style.fileTypeDescriptor.displayName=...
         shortPrefix.style.fileTypeDescriptor.defaultExtension=...
         shortPrefix.style.fileTypeDescriptor.filters=...
         shortPrefix.style.fileTypeDescriptor.groupIDs=...
       

      Warning: when overriding this method, make sure to either return an array of length 1 or to override createLayerStyleCodecs() ()} as well.

      Overrides:
      createLayerStyleCodecFileTypeDescriptors in class ALcyLspFormat
      Returns:
      An array of ALcyFileTypeDescriptor instances. Must not be null and its length must be equal to the length of the array of layer style encoders created by this format. May contain null.
      See Also:
    • createLayerStyleCodecs

      protected ILcyLayerStyleCodec[] createLayerStyleCodecs()

      Creates the ILcyLayerStyleCodec instances which can encode/decode the style of the layers created by the layer factory of this format.

      The default implementation returns an empty array.

      The default implementation returns an array containing the ILcyLayerStyleCodec created in createLayerStyleCodecImpl().

      Warning: when overriding this method, make sure to either return an array of length 1 or to override createLayerStyleCodecFileTypeDescriptors() as well.

      Overrides:
      createLayerStyleCodecs in class ALcyLspFormat
      Returns:
      an array of ILcyLayerStyleCodec instances. Must not be null. The array may be empty, but must not contain null.
      See Also:
    • createLayerFactoryImpl

      protected abstract ILspLayerFactory createLayerFactoryImpl()
      Creates the layer factory for this format. The default style will automatically be applied on each layer created by this factory. A style file located next to the model source file will be applied on the created layers as well.
      Returns:
      the layer factory for this format. May be null
    • createLayerStyleCodecImpl

      protected abstract ILcyLayerStyleCodec createLayerStyleCodecImpl()
      Creates the actual ILcyLayerStyleCodec
      Returns:
      a new ILcyLayerStyleCodec for the layers of this format. Must not be null.
      See Also: