Class TLcyLspFormatTool

java.lang.Object
com.luciad.lucy.util.ALcyTool
com.luciad.lucy.format.lightspeed.TLcyLspFormatTool
All Implemented Interfaces:
ILcdPropertyChangeSource

public class TLcyLspFormatTool extends ALcyTool

Support class to plug the format-related objects created by an ALcyLspFormat (e.g. ILspLayerFactory) into the ILcyLucyEnv. Call the plugInto(com.luciad.lucy.ILcyLucyEnv) method to plug all the format-related objects of the given ALcyLspFormat into the Lucy back-end.

Using this TLcyLspFormatTool to plug in an ALcyLspFormat will register most objects as service to the Lucy back-end. As a consequence, everything that is plugged in using this TLcyLspFormatTool should be unplugged using a TLcyLspFormatTool as well.

A typical usage might look like (for example in the ALcyAddOn#plugInto method):


   ALcyLspFormat format = ... ;
   TLcyLspFormatTool formatTool = new TLcyLspFormatTool( format );
   //plug in the whole format at once
   formatTool.plugInto( aLucyEnv );
 

When the format components are no longer needed, the same format tool can be used to unregister those instances (for example in the ALcyAddOn#unplugFrom method):


   //same TLcyLspFormatTool and Lucy back-end as used in the plugInto method
   formatTool.unplugFrom( aLucyEnv );
 

Note: when you want to create an add-on which plugs in an ALcyLspFormat you can as well extend from ALcyLspFormatAddOn directly, which does what is shown above.

Since:
2012.0
See Also:
  • Constructor Details

    • TLcyLspFormatTool

      public TLcyLspFormatTool(ALcyLspFormat aFormat)

      Creates a TLcyLspFormatTool for the given ALcyLspFormat.

      Parameters:
      aFormat - The ALcyLspFormat whose contents needs to be plugged into the Lucy back-end. Must not be null.
    • TLcyLspFormatTool

      public TLcyLspFormatTool(ALcyLspFormat aFormat, int aPriorityForAllObjects)

      Creates a TLcyLspFormatTool for the given ALcyLspFormat which will plug in all objects into the Lucy back-end using the specified priority.

      Parameters:
      aFormat - The ALcyLspFormat whose contents needs to be plugged into the Lucy back-end. Must not be null.
      aPriorityForAllObjects - The priority which will be used to plug in all the objects into the Lucy back-end. Lower values mean higher priorities. Common values are ILcyLucyEnv.PRIORITY_DEFAULTand ILcyLucyEnv.PRIORITY_FALLBACK.
      Since:
      2016.0
  • Method Details

    • getFormat

      public ALcyLspFormat getFormat()

      Returns the ALcyLspFormat for which this tool was created.

      Returns:
      the ALcyLspFormat for which this tool was created. Never null
    • plugInto

      public void plugInto(ILcyLucyEnv aLucyEnv)

      Plugs this tool. This method is usually called from ALcyAddOn#plugInto.

      Lets the format create all the format-related objects and plugs them into the given Lucy back-end.

      Overrides:
      plugInto in class ALcyTool
      Parameters:
      aLucyEnv - The environment to plug into.
    • unplugFrom

      public void unplugFrom(ILcyLucyEnv aLucyEnv)
      Description copied from class: ALcyTool

      Unplugs this tool. This method is usually called from ALcyAddOn#unplugFrom.

      Overrides:
      unplugFrom in class ALcyTool
      Parameters:
      aLucyEnv - The environment to unplug from, must be identical to the environment given to plugInto.
    • findFormat

      public static <T extends ALcyLspFormat> T findFormat(ALcyLspFormat aFormat, Class<T> aFormatClass)

      Utility method to find an ALcyLspFormat (or ALcyLspFormatWrapper) of the given class. This can be useful to, in a chain of wrapped formats, retrieve a format of the given class.

      To do so, it assumes every format wrapper extends from ALcyLspFormatWrapper.

      Consider for example this chain of formats:

      
       ALcyLspFormat format =
       new TLcyLspSafeGuardFormatWrapper( new MyFormat() )
       
      A call to
      
       findFormat(format, TLcyLspSafeGuardFormatWrapper.class)
       
      will return the TLcyLspSafeGuardFormatWrapper instance. A call to
      
       findFormat(format, SomeOtherFormatWrapper.class)
       
      will return null.

      Parameters:
      aFormat - The format to start looking from.
      aFormatClass - The class to find.
      Returns:
      null if no such format was found, or an instance of (a subclass of) the given aFormatClass.
    • findBaseFormat

      public static ALcyLspFormat findBaseFormat(ALcyLspFormat aFormat)

      Utility method to, in a chain of wrapped formats, find the deepest format.

      To do so, it assumes every format wrapper extends from ALcyLspFormatWrapper.

      Consider for example this chain of formats:

      
       ALcyLspFormat format =
       new TLcyLspSafeGuardFormatWrapper( new MyFormat() )
       
      A call to
      
       findBaseFormat(format)
       
      will return the MyFormat instance.

      Parameters:
      aFormat - The format to find the base format of.
      Returns:
      The base format of the given aFormat.