Class TLcyLspVectorFormat


public class TLcyLspVectorFormat extends ALcyLspStyleFormat

Extension of ALcyLspStyleFormat for simple vector formats. It provides a custom implementation of the createLayerFactoryImpl() method, which supports most ILcdShape objects. This layer factory allows to make small changes to the created layers before they leave the layer factory by calling customizeLayer for each layer it creates.

Extensions of this class can override the customizeLayer method but this only makes sense for small changes (e.g. setting the layer labeled by default). When you have to set another painter, ... it is recommended to extend from ALcyLspStyleFileFormat directly.

This format assumes all objects can be draped. You can adjust the draping settings in the default style file associated to the format (see DEFAULT_STYLE_FILE_SUFFIX). In case you have different draping settings for individual objects you should extend from ALcyLspStyleFormat directly and implement a custom styler.

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

Since:
2012.0
See Also:
  • Constructor Details

    • TLcyLspVectorFormat

      public TLcyLspVectorFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aPreferences, ILcdFilter<ILcdModel> aModelFilter)
      Create a new vector format
      Parameters:
      aLucyEnv - The Lucy back-end
      aLongPrefix - The long prefix of this format.
      aShortPrefix - The short prefix of this format
      aPreferences - The preferences
      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

    • createLayerFactoryImpl

      protected final ILspLayerFactory createLayerFactoryImpl()
      Description copied from class: ALcyLspStyleFormat

      Creates the layer factory for this format. This method will be called from the ALcyLspStyleFileFormat.createLayerFactory() method. This factory must not return ILcdLayerTreeNode instances. In case you want to support empty nodes, consider using a TLcyLspLayerTreeNodeFormatWrapper.

      Layer requirements

      The layers returned by this layer factory should match the following requirements:

      Layer styling

      The default style of this format as defined in the default style file will be automatically applied on each layer. If a style is present next to the model source file of the layer, this style will be applied as well. It is not necessary to include this functionality in the layer factory returned by this method.

      Note however that an SLD style file can only be applied on layers which use SLD styling, and customizable styler based style files can only be applied on layers which use an ILspCustomizableStyler. This means that the layer factory decides which kind of styling is available for which layer.

      To facilitate this, this format has a utility method to check whether SLD styling can be found for a certain model. The layer factory can opt to use this method to decide between SLD based styling or customizable styler based styling.

      An example implementation of this method could be:

      
       return new ALspSingleLayerFactory() {
           @Override
           public ILspLayer createLayer(ILcdModel aModel) {
             //This example implementation assumes the data is vector data
             TLcdSLDFeatureTypeStyle featureTypeStyle = retrieveFeatureTypeStyle(aModel);
      
             if(featureTypeStyle == null){
               //create a customizable styler with default styles and set it on the layer
               TLspCustomizableStyler bodyStyler = new TLspCustomizableStyler(
                   TLspLineStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN)
                                             .color(Color.WHITE)
                                             .width(2)
                                             .build(),
                   TLspFillStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN)
                                             .color(new Color(255, 255, 0, 128))
                                             .build(),
                   TLspIconStyle.newBuilder().icon(new TLcdSymbol(TLcdSymbol.FILLED_RECT, 5)).build()
               );
      
               return TLspShapeLayerBuilder.newBuilder()
                           .model(aModel)
                           .bodyStyler(TLspPaintState.REGULAR, bodyStyler)
                           .build();
             } else {
               //Create a layer which uses SLD styling
               return TLspShapeLayerBuilder.newBuilder()
                           .model(aModel)
                           .sldStyle(featureTypeStyle)
                           .build();
             }
           }
      
           @Override
           public boolean canCreateLayers(ILcdModel aModel) {
             //the format should be wrapped with a TLcyLspSafeGuardFormatWrapper so we can just return true
             return true;
           }
        };
       
      Specified by:
      createLayerFactoryImpl in class ALcyLspStyleFormat
      Returns:
      The layer factory for this format. May be null
    • customizeLayer

      protected void customizeLayer(ILspInteractivePaintableLayer aLayer)

      Each layer created by the layer factory of this format is passed to this method. Overriding this method allows to make changes to the created layers, for example adjusting the visibility of the labels.

      If you need to make major changes to the layer (for example setting a new styler), it is recommended to extend from ALcyLspStyleFormat directly instead of using this format.

      Warning: the layers must fulfil the requirements documented in the createLayerFactoryImpl() method.

      Parameters:
      aLayer - The layer created by the layer factory.