Customizing visualization

NVG domain object visualization can be classified in the following categories:

  • If the NVG domain object is a military symbol supported by LuciadLightspeed, the object is visualized as described by the appropriate standard. The Lightspeed NVG styler and the GXY NVG painter provider provide entry points to set up a ILcdMS2525bStyle or ILcdAPP6AStyle specifying the styling of military symbols. For more information on military symbology styling, refer to the LuciadLightspeed military symbology developer’s guide.

  • If the NVG domain object belongs to a custom symbology, you can add your own styling logic. As an example, Program: Plugging in styling logic for a custom symbology. shows how to plug in styling logic for a custom civilian symbology. More specifically, it configures a number of custom icons for the domain objects belonging to that symbology.

  • For objects extending TLcdNVG15Base or TLcdNVG20Content, the respective TLcdNVGStyle property determines the styling. Default values are used for undefined style properties. The GXY NVG painter provider and Lightspeed NVG styler provide entry points to set up the TLcdNVGStyle used to retrieve default values from.

  • For all other objects, a default styling is used. You can customize the styling similarly as shown in Program: Plugging in styling logic for a custom symbology.. Note that in the sample from which Program: Plugging in styling logic for a custom symbology. was taken some NVG domain objects are clustered. For an in-depth explanation of clustering see the article Clustering in the LuciadLightspeed developer’s guide. For more information on the application of clustering to military symbols, refer to the LuciadLightspeed military symbology developer’s guide.

Program: Plugging in styling logic for a custom symbology. (from samples/symbology/nvg/lightspeed/MainPanel)
      ILspStyler styler = new DomainSpecificNVGStyler(TLspPaintState.REGULAR);
      ILspStyler selectedStyler = new DomainSpecificNVGStyler(TLspPaintState.SELECTED);
      ILspStyler editedStyler = new DomainSpecificNVGStyler(TLspPaintState.EDITED);
      ILspLayer layer = TLspNVGLayerBuilder.newBuilder()
                                           .bodyStyler(TLspPaintState.REGULAR, styler)
                                           .bodyStyler(TLspPaintState.SELECTED, selectedStyler)
                                           .bodyStyler(TLspPaintState.EDITED, editedStyler)
                                           .model(model)
                                           .build();

private static class DomainSpecificNVGStyler extends TLspNVGStyler {

  private ILcdObjectIconProvider fDomainSpecificIconProvider = new CivilianIconProvider();

  public DomainSpecificNVGStyler(TLspPaintState aPaintState) {
    super(aPaintState);
  }

  @Override
  public void style(Collection<?> aObjects, ALspStyleCollector aCollector, TLspContext aContext) {
    List<Object> classicNVGObjects = new ArrayList<>();
    for (Object object : aObjects) {
      if (isDomainSpecificObject(object)) {
        aCollector.object(object).style(retrieveStyle(object)).submit();
      } else {
        classicNVGObjects.add(object);
      }
    }
    super.style(classicNVGObjects, aCollector, aContext);
  }

  private boolean isDomainSpecificObject(Object object) {
    boolean result = false;
    if (object instanceof TLcdNVG20SymbolizedContent) {
      TLcdNVG20SymbolizedContent symbolizedContent = (TLcdNVG20SymbolizedContent) object;
      TLcdNVGSymbol symbol = symbolizedContent.getSymbol();
      if (CUSTOM_CIVILIAN_DOMAIN_NAME.equals(symbol.getStandardName())) {
        result = true;
      }
    }
    return result;
  }

  private ALspStyle retrieveStyle(Object aObject) {
    return TLspIconStyle.newBuilder()
                        .icon(fDomainSpecificIconProvider.getIcon(aObject))
                        .build();
  }

}