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.
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);
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();
ALcyLspStyleRepository
instanceTo 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.
Constructor and Description |
---|
TLcyLspStyleRepositoryAddOn()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
protected TLcyPreferencesTool |
createPreferencesTool()
Creates the
TLcyPreferencesTool to be used by this add-on. |
void |
plugInto(ILcyLucyEnv aLucyEnv)
Creates and plugs in the add-on's preferences tool.
|
void |
unplugFrom(ILcyLucyEnv aLucyEnv)
Unplugs the add-on's preferences tool.
|
getLongPrefix, getLucyEnv, getPreferences, getPreferencesTool, getShortPrefix
getConfigSourceName, getDisplayName, setConfigSourceName, setDisplayName
public TLcyLspStyleRepositoryAddOn()
public void plugInto(ILcyLucyEnv aLucyEnv)
ALcyPreferencesAddOn
plugInto
in class ALcyPreferencesAddOn
aLucyEnv
- the Lucy environment to plug intoALcyAddOn.unplugFrom(com.luciad.lucy.ILcyLucyEnv)
public void unplugFrom(ILcyLucyEnv aLucyEnv)
ALcyPreferencesAddOn
unplugFrom
in class ALcyPreferencesAddOn
aLucyEnv
- the Lucy environmentALcyAddOn.plugInto(com.luciad.lucy.ILcyLucyEnv)
protected TLcyPreferencesTool createPreferencesTool()
ALcyPreferencesAddOn
Creates the TLcyPreferencesTool
to be used by this add-on. Overwriting this method
for example allows to register additional ILcyPropertyConverter
s for (complex)
custom properties, to make sure they are correctly decoded from the add-on's configuration file
and/or saved to the workspace. Note that this isn't required for simple properties such as
String
, int
, double
, etc.
The default implementation creates a new tool based on the ALcyAddOn.getConfigSourceName()
and
the add-on's prefixes.
createPreferencesTool
in class ALcyPreferencesAddOn
TLcyPreferencesTool
.