Class TLcdKML22IconProvider

java.lang.Object
com.luciad.format.kml22.util.TLcdKML22IconProvider

public class TLcdKML22IconProvider extends Object

Provides icons for icon styles.

Icons can be retrieved synchronously or asynchronously. The provider keeps a cache of icons to optimize performance. Icons can also be queried for their status. This status describes whether they are cached or not.

A template for the usage of retrieving icon is as follows:

 
    //variables used in this template
    TLcdKML22IconProvider iconProvider;
    TLcdKML22IconStyle iconStyle;
    ILcdKML22ResourceListener callbackFunction;

    //the template

    //obtain the status of the icon to decide what to do
    ELcdKML22ResourceStatus iconStatus = iconProvider.getIconStatus( iconStyle );
    ILcdIcon icon = null;
    switch ( iconStatus ) {
      case CACHED:
        //the resource is cached, so you can retrieve it synchronously without blocking the calling
        //thread
        icon = iconProvider.retrieveIcon( iconStyle );
        break;
      case LOADING:
        //the resource is being loaded. Use a temporary value instead.
        icon = getLoadingIcon();
        break;
      case FAULTY:
        //the resource is unavailable because it is faulty. A fallback mechanism should be used here
        //because the resource itself can't be retried.
        icon = getFaultyIcon();
        break;
      case NOT_CACHED:
        //the resource is not cached. Start an asynchronous retrieve and used a temporary value instead.
        iconProvider.retrieveIcon( iconStyle,callbackFunction );
        icon = getLoadingIcon();
        break;
    }
 
 
Since:
10.0
  • Method Details

    • retrieveIcon

      public ILcdIcon retrieveIcon(TLcdKML22IconStyle aIconStyle)

      Retrieves an icon for a given icon style.

      This method will block the calling thread while it is retrieving an icon, unless the icon was already available in the cache. To check whether an icon is available, use the getIconStatus(com.luciad.format.kml22.model.style.TLcdKML22IconStyle) method.

      Parameters:
      aIconStyle - The icon style for which to retrieve an icon. Can not be null.
      Returns:
      Either an ILcdIcon or null if the icon could not be loaded.
    • retrieveIcon

      public void retrieveIcon(TLcdKML22IconStyle aIconStyle, ILcdKML22ResourceListener aCallbackFunction)

      Asynchronously retrieves an icon for a given icon style without calling the calling thread.

      This method returns immediately.

      Parameters:
      aIconStyle - The icon style for which to retrieve the icon.
      aCallbackFunction - the function that will be notified when the icon has been loaded.
    • getIconStatus

      public ELcdKML22ResourceStatus getIconStatus(TLcdKML22IconStyle aIconStyle)
      Gets the status of the icon for a given icon style
      Parameters:
      aIconStyle - an icon style for which to check the status
      Returns:
      An ELcdKML22ResourceStatus