|| | |||Browse by category|
How to configure transparency value of layers in Map Builder ?
In Map Builder, a property is either inherited or has its own value. It is not possible to have both. This is applicable for all properties. For example, if you specify that a property is inherited from its parent, when you modify the value at the parent layer level, the value will also be applied to the sublayer. On the other hand if you set for instance transparency to 50%, this value is no longer inherited and will not change whatever happens in the parent layer.
However, you may want to have a different behavior, namely to force transparency value of a parent layer to be applied to all sub layers, even if some of the layers have already a transparency value set.
In order to achieve this behavior, you need to listen to the changes in the parent layer style (with IlvMapStyle.addStyleListener) and to apply transparency value to all sub-layers.
You will find attached an implementation of such behavior. The attached classes, BaseDemo.java, LTMouseListener.java and MyStyleListener.java, are to be placed in the shared package of mapbuilder sample.
Explanations of the code :
In BaseDemo.createBeans() a mouse listener (LTMouseListener) is added to the layer tree panel in order to be notified when a layer is selected. When a layer is selected (in the mouse listener mouseClicked(...) method), a style listener is added to the parent style of the currently selected map layer. Finally, in the style listener, the transparency value of all children styles is set to the transparency value of the parent style.