When labels appear or disappear in a Lightspeed view, they fade in or out. While this effect is visually pleasing, it may not always be what you want.
How to do it?
To disable this effect, you need to do 2 things:
-
Create a label painter without the fading behavior. You can do so by setting the fading duration to 0 for the new label painter.
TLspLabelPainter labelPainter = new TLspLabelPainter(); labelPainter.setDefaultOpacityFadeDuration(0);
You can also use the
setDefaultOpacityFadeDuration
method to make the label fading duration longer or shorter. -
Make sure your new label painter is used by the layer.
If you use theTLspShapeLayerBuilder
class to build your layer, you can use the following code:ILspLayer layer = TLspShapeLayerBuilder.newBuilder() .model(aModel) .labelPainter(labelPainter) // Use the label painter without fading effect ... // Configure the rest of the layer (styling etc...) .build();
If you directly create a
TLspLayer
, without using theTLspShapeLayerBuilder
class, you can use the following code:TLspLayer layer = new TLspLayer(model, ...); layer.setPainter(TLspPaintRepresentation.LABEL, labelPainter); // Use the label painter without fading effect // ... // Configure the rest of the layer (styling etc...)