Class TLcyLspStyleRepositoryAddOn
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected TLcyPreferencesTool
Creates theTLcyPreferencesTool
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.Methods inherited from class com.luciad.lucy.addons.ALcyPreferencesAddOn
getLongPrefix, getLucyEnv, getPreferences, getPreferencesTool, getShortPrefix
Methods inherited from class com.luciad.lucy.addons.ALcyAddOn
getConfigSourceName, getDisplayName, setConfigSourceName, setDisplayName
-
Constructor Details
-
TLcyLspStyleRepositoryAddOn
public TLcyLspStyleRepositoryAddOn()Default constructor
-
-
Method Details
-
plugInto
Description copied from class:ALcyPreferencesAddOn
Creates and plugs in the add-on's preferences tool.- Overrides:
plugInto
in classALcyPreferencesAddOn
- Parameters:
aLucyEnv
- the Lucy environment to plug into- See Also:
-
unplugFrom
Description copied from class:ALcyPreferencesAddOn
Unplugs the add-on's preferences tool.- Overrides:
unplugFrom
in classALcyPreferencesAddOn
- Parameters:
aLucyEnv
- the Lucy environment- See Also:
-
createPreferencesTool
Description copied from class:ALcyPreferencesAddOn
Creates the
TLcyPreferencesTool
to be used by this add-on. Overwriting this method for example allows to register additionalILcyPropertyConverter
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 asString
,int
,double
, etc.The default implementation creates a new tool based on the
ALcyAddOn.getConfigSourceName()
and the add-on's prefixes.- Overrides:
createPreferencesTool
in classALcyPreferencesAddOn
- Returns:
- the created
TLcyPreferencesTool
.
-