public final class TLspScaleBasedStyler extends ALspStyler
TLspScaleBasedStylerBuilder
can be used to create a new instance of this class. The following example sets up
a scale based styler that switches between styles at a map scale of 1:10.000:
TLspScaleBasedStyler scaleBasedStyler =
TLspScaleBasedStylerBuilder.newBuilder()
.styles(TLcdMapScale.MAX_ZOOMED_OUT, new TLcdMapScale(1d / 10_000), zoomedOutStyle)
.styles(new TLcdMapScale(1d / 10_000), TLcdMapScale.MAX_ZOOMED_IN, zoomedInStyle)
.build();
TLspScaleBasedStylerBuilder
can also be used in combination with
getStylersByScaleRange()
to create a variation of an existing styler. The following
example derives a new styler by copying the stylers from a given TLspScaleBasedStyler
that apply at map scale
of 1:1000:
TLspScaleBasedStylerBuilder builder = TLspScaleBasedStylerBuilder.newBuilder();
existingStyler.getStylersByScaleRange().entrySet().stream()
.filter(entry -> entry.getKey().contains(new TLcdMapScale(1d / 1_000)))
.forEach(entry -> {
for (ALspStyler styler : entry.getValue()) {
builder.styler(entry.getKey(), styler);
}
});
TLspScaleBasedStyler newStyler = builder.build();
TLspScaleBasedStylerBuilder
Modifier and Type | Method and Description |
---|---|
Map<TLcdDimensionInterval<TLcdMapScale>,List<ALspStyler>> |
getStylersByScaleRange()
Returns the map scale intervals and associated stylers of this styler.
|
static TLspScaleBasedStylerBuilder |
newBuilder()
Creates a new builder without configured stylers.
|
void |
style(Collection<?> aObjects,
ALspStyleCollector aStyleCollector,
TLspContext aContext)
Implementation of
ILspStyler.style that applies the configured stylers, based on the
map scale of the current view. |
addStyleChangeListener, fireStyleChangeEvent, fireStyleChangeEvent, removeStyleChangeListener
public static TLspScaleBasedStylerBuilder newBuilder()
public Map<TLcdDimensionInterval<TLcdMapScale>,List<ALspStyler>> getStylersByScaleRange()
public void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext)
Implementation of ILspStyler.style
that applies the configured stylers, based on the
map scale of the current view.
aObjects
- The objects to be styled.aStyleCollector
- A style collector to which all styling information
should be passed, this collector is only valid within this method
call, and can no longer be used afterwards.aContext
- Provides context information that may affect styling, such as view specific properties.