Class TLcyLspStyleRepositoryAddOn

java.lang.Object
com.luciad.lucy.addons.ALcyAddOn
com.luciad.lucy.addons.ALcyPreferencesAddOn
com.luciad.lucy.addons.stylerepository.lightspeed.TLcyLspStyleRepositoryAddOn

public class TLcyLspStyleRepositoryAddOn extends ALcyPreferencesAddOn

Add-on which is responsible for the creation of a ALcyLspStyleRepository instance, and registers it as a service to the Lucy back-end. The style repository manages the selection colors and the color mapping for elevation data on Lightspeed views.

The default ALcyLspStyleRepository implementation, plugged in by this add-on, allows to customize both the selection colors and elevation data color mapping through the API. Adjusting those will affect all existing layers and future layers.

This add-on also provides a UI for the Lucy end-user to change those colors.

Typically, Lightspeed format add-ons use the registered ALcyLspStyleRepository instance. Therefore it is recommended to plug in this add-on before the other Lightspeed add-ons.

Changing the colors through the API

The selection colors can be changed through the properties of this add-on:

    //Retrieve the add-on
    TLcyLspStyleRepositoryAddOn addOn = aLucyEnv.retrieveAddOnByClass(TLcyLspStyleRepositoryAddOn.class);

    //Change the selection color for icons by changing the corresponding property
    //The available properties can be found in the configuration file of the add-on
    //
    //This will update the selection color on all existing and future layers
    String property = addOn.getShortPrefix() + "selection.iconColor";
    addOn.getPreferences().putColor(property, Color.PINK);

The elevation data color mapping can be changed using the setter for the color map:

    //Retrieve the style repository
    ALcyLspStyleRepository styleRepository = aLucyEnv.getService(ALcyLspStyleRepository.class);

    //Update the color map
    //
    //This will update the color mapping used by all existing and future elevation layers
    styleRepository.setElevationColorMap(newElevationColorMap);

Applying the colors to your own layers

If you have a selectable layer, you can use the same selection colors by using the selection styler created by the style repository:

    //Retrieve the style repository
    ALcyLspStyleRepository styleRepository = aLucyEnv.getService(ALcyLspStyleRepository.class);

    //Ask the repository to create a selection styler based on the styler for the regular body
    ILspStyler selectionStyler = styleRepository.createSelectionStyler(regularBodyStyler);

    //Install the styler on the layer
    TLspLayer layer = TLspShapeLayerBuilder.newBuilder()
                                           .model(aModel)
                                           .bodyStyler(TLspPaintState.REGULAR, regularBodyStyler)
                                           .bodyStyler(TLspPaintState.SELECTED, selectionStyler)
                                           .build();

If you have a layer with elevation data, you can use the same color mapping by using the elevation styler created by the style repository:

    //Retrieve teh style repository
    ALcyLspStyleRepository styleRepository = aLucyEnv.getService(ALcyLspStyleRepository.class);

    //Ask the repository to create an elevation styler for your model
    ILspStyler elevationStyler = styleRepository.createElevationStyler(aModel);

    //Install the styler on the layer
    ILspEditableStyledLayer layer = TLspRasterLayerBuilder.newBuilder()
                                                          .model(aModel)
                                                          .styler(TLspPaintRepresentationState.REGULAR_BODY, elevationStyler)
                                                          .build();

Plugging in your own ALcyLspStyleRepository instance

To insert your own ALcyLspStyleRepository, this add-on should be removed and a custom style repository add-on should be plugged in: one which registers your custom style repository in stead of the default one.

Since:
2012.0