public class TLspSLDStyler extends ALspLabelStyler
Styles Lightspeed layers according to the OGC Styled Layer Descriptor / Symbology Encoding standards.
It styles all objects as described in a single TLcdSLDFeatureTypeStyle
, passed
during construction of the styler.
It supports both LABELS and BODIES paint representations.
A feature type style can be decoded from a file with
TLcdSLDFeatureTypeStyleDecoder.decodeFeatureTypeStyle(String)
or can
be created with TLcdSLDFeatureTypeStyle.newBuilder()
using the SLD
domain model.
Normally there is no need to create instances of this class yourself. See below on how to create vector and raster layers which are styled using SLD.
Creating the layer can be done using the TLspShapeLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
method:
TLcdSLDFeatureTypeStyle sld = new TLcdSLDFeatureTypeStyleDecoder().decodeFeatureTypeStyle("path/to/sld");
TLspLayer sldStyledLayer =
TLspShapeLayerBuilder.newBuilder()
.model(aModel)
.sldStyle(sld)
.build();
This will result in a layer which uses a TLspSLDStyler
allowing you to update certain settings of the styler:
TLspLayer sldStyledLayer = ...;
TLspSLDStyler bodyStyler = (TLspSLDStyler)sldStyledLayer.getStyler(TLspPaintRepresentationState.REGULAR_BODY);
bodyStyler.setIconElevationMode(ElevationMode#ON_TERRAIN);
If you want to update the SLD later on, you need to use the TLspLayer.configureForSLDStyling(TLcdSLDFeatureTypeStyle)
method:
TLspLayer sldStyledLayer = ...;
TLcdSLDFeatureTypeStyle sld = new TLcdSLDFeatureTypeStyleDecoder().decodeFeatureTypeStyle("path/to/another/sld");
sldStyledLayer.configureForSLDStyling(sld);
Note that the above snippets result in a layer that uses the specified SLD to render the data in the
regular paint state
. Please refer to TLspShapeLayerBuilder
to
adjust the styling for edited
or selected paint states
.
Creating the layer can be done using the TLspRasterLayerBuilder.sldStyle(TLcdSLDFeatureTypeStyle)
method:
TLcdSLDFeatureTypeStyle sld = new TLcdSLDFeatureTypeStyleDecoder().decodeFeatureTypeStyle("path/to/sld");
ILspEditableStyledLayer sldStyledLayer =
TLspRasterLayerBuilder.newBuilder()
.model(aModel)
.sldStyle(sld)
.build();
If you want to update the SLD later on, you need to use the TLspRasterLayer.configureForSLDStyling(TLcdSLDFeatureTypeStyle)
method:
ILspEditableStyledLayer sldStyledLayer = ...;
if(sldStyledLayer instanceof TLspRasterLayer){
TLcdSLDFeatureTypeStyle sld = new TLcdSLDFeatureTypeStyleDecoder().decodeFeatureTypeStyle("path/to/another/sld");
((TLspRasterLayer)sldStyledLayer).configureForSLDStyling(sld);
}
Dash patterns in line symbolizers can only be drawn efficiently if they can be converted
to a 16 bit pattern. Other patterns will be drawn with TLspComplexStrokedLineStyle
, which
may impact performance. So for instance '4 1 2 1' is an efficient pattern, while '4 1 2 2'
will degrade performance.
A symbolizer can optionally contain vendor options
,
which define additional behavior beyond the OGC Styled Layer Descriptor / Symbology Encoding standards.
A vendor option is defined by a name and a value. The following vendor options are supported:
followLine
, which takes a boolean value and can be configured on a text symbolizer
to render curved labels that follow a feature's geometry.startGap
and endGap
, which take a double value and can be configured on a line symbolizer
to respectively define a
gap in pixels at the first and the last point of the line. Note that this is currently only supported if the line width is also expressed in pixels (not world-sized).removeAlphaChannel
, which takes a boolean value and can be configured on a raster symbolizer
to remove the alpha channel from an image.conflictResolution
, which takes a boolean value and can be configured on a text symbolizer
to disable label placement conflict resolution (label decluttering).composite
with value copy
, which can be configured on a point symbolizer
to
indicate that the alpha channel of its icon needs to be copied to the line style provided by another symbolizer in the same styling rule.TLcdSLDFeatureTypeStyle
,
TLcdSLDFeatureTypeStyleDecoder
Constructor and Description |
---|
TLspSLDStyler(TLcdSLDFeatureTypeStyle aFeatureTypeStyle)
Creates a new SLD styler for the given
TLcdSLDFeatureTypeStyle . |
TLspSLDStyler(TLcdSLDFeatureTypeStyle aFeatureTypeStyle,
TLcdSLDContext aSLDContext)
Creates a new SLD styler for the given
TLcdSLDFeatureTypeStyle . |
Modifier and Type | Method and Description |
---|---|
TLcdSLDFeatureTypeStyle |
getFeatureTypeStyle()
Returns the currently used SLD feature type style.
|
ILspWorldElevationStyle.ElevationMode |
getIconElevationMode()
Returns the elevation mode for icon symbolizers, or null if the default is used.
|
ILspWorldElevationStyle.ElevationMode |
getLineElevationMode()
Returns the elevation mode for line symbolizers, or null if the default is used.
|
ILspWorldElevationStyle.ElevationMode |
getPolygonElevationMode()
Returns the elevation mode for polygon symbolizers, or null if the default is used.
|
int |
getZOrder()
Returns the Z-order for point, line and polygon symbolizers, determining which shapes that are
painted on top of one another.
|
void |
setIconElevationMode(ILspWorldElevationStyle.ElevationMode aIconElevationMode)
Sets the elevation mode that is used by styles that correspond to
icon symbolizers.
|
void |
setLineElevationMode(ILspWorldElevationStyle.ElevationMode aLineElevationMode)
Sets the default elevation mode that is used by styles that correspond to
line symbolizers.
|
void |
setPolygonElevationMode(ILspWorldElevationStyle.ElevationMode aElevationMode)
Sets the default elevation mode that is used by styles that correspond to
polygon symbolizers.
|
void |
setSLDFeatureTypeStyle(TLcdSLDFeatureTypeStyle aSLDFeatureTypeStyle)
Sets the SLD feature type style to use for styling.
|
void |
setZOrder(int aZOrder)
Sets the Z-order for point, line and polygon symbolizers, determining which shapes that are
painted on top of one another.
|
void |
style(Collection<?> aObjects,
ALspLabelStyleCollector aStyleCollector,
TLspContext aContext)
Convenience method that takes an
ALspLabelStyleCollector as argument instead of
an ALspStyleCollector . |
void |
style(Collection<?> aObjects,
ALspStyleCollector aStyleCollector,
TLspContext aContext)
Implementation of
ILspStyler.style that either casts the ALspStyleCollector
to ALspLabelStyleCollector if possible, or adapts it otherwise. |
addStyleChangeListener, fireStyleChangeEvent, fireStyleChangeEvent, removeStyleChangeListener
public TLspSLDStyler(TLcdSLDFeatureTypeStyle aFeatureTypeStyle)
TLcdSLDFeatureTypeStyle
. A
default, best effort, implementation is used to evaluate expressions that
occur in the feature type style. Use
TLspSLDStyler(TLcdSLDFeatureTypeStyle, TLcdSLDContext)
if you need
to change this to support custom domain objects or functions.
Note: normally there is no need to create instances of this class yourself. See the class javadoc on how to create layers which use SLD for styling.
aFeatureTypeStyle
- An SLD feature type style that defines the styles
that this styler should generate.public TLspSLDStyler(TLcdSLDFeatureTypeStyle aFeatureTypeStyle, TLcdSLDContext aSLDContext)
TLcdSLDFeatureTypeStyle
. The
aSLDContext
can be reused by multiple stylers, the different
objects that make up this context should be thread safe.
Note: normally there is no need to create instances of this class yourself. See the class javadoc on how to create layers which use SLD for styling.
aFeatureTypeStyle
- An SLD feature type style that defines the styles
that this styler should generate.aSLDContext
- The SLD context that has to be used when applying
aFeatureTypeStyle, should not be null.public void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext)
ALspLabelStyler
Implementation of ILspStyler.style
that either casts the ALspStyleCollector
to ALspLabelStyleCollector
if possible, or adapts it otherwise. In the latter case, the labeling-specific
calls (label
, anchorLabel
,
algorithm
, ...) are ignored. The ALspLabelStyleCollector
is then
passed to the style(Collection,ALspLabelStyleCollector,TLspContext)
method.
style
in interface ILspStyler
style
in class ALspLabelStyler
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.public void style(Collection<?> aObjects, ALspLabelStyleCollector aStyleCollector, TLspContext aContext)
ALspLabelStyler
Convenience method that takes an ALspLabelStyleCollector
as argument instead of
an ALspStyleCollector
. This method is called from
ALspLabelStyler.style(Collection, ALspStyleCollector, TLspContext)
.
style
in class ALspLabelStyler
aObjects
- The set of domain objects to provide information foraStyleCollector
- The label style collector to submit the information to.aContext
- The contextALspLabelStyleCollector
,
ILspStyler
public void setPolygonElevationMode(ILspWorldElevationStyle.ElevationMode aElevationMode)
aElevationMode
- A valid elevation mode.public ILspWorldElevationStyle.ElevationMode getPolygonElevationMode()
public ILspWorldElevationStyle.ElevationMode getLineElevationMode()
public void setLineElevationMode(ILspWorldElevationStyle.ElevationMode aLineElevationMode)
aLineElevationMode
- A valid elevation mode.public ILspWorldElevationStyle.ElevationMode getIconElevationMode()
public void setIconElevationMode(ILspWorldElevationStyle.ElevationMode aIconElevationMode)
aIconElevationMode
- A valid elevation mode.public void setZOrder(int aZOrder)
aZOrder
- a Z-order valueALspStyle.getZOrder()
public int getZOrder()
public final TLcdSLDFeatureTypeStyle getFeatureTypeStyle()
setSLDFeatureTypeStyle(TLcdSLDFeatureTypeStyle)
method.public final void setSLDFeatureTypeStyle(TLcdSLDFeatureTypeStyle aSLDFeatureTypeStyle)
Sets the SLD feature type style to use for styling.
Note: normally there is no need to call this method yourself. See the class javadoc on how to update the SLD feature type style used to style a layer.
aSLDFeatureTypeStyle
- The new feature type style