Class TLspSLDStyler
- All Implemented Interfaces:
ILspStyler
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 vector layers styled with 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 raster layers styled with SLD 
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);
}
Performance considerations 
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.
Vendor options 
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:
- A vendor option
followLine
, which takes a boolean value and can be configured on atext symbolizer
to render curved labels that follow a feature's geometry. - The vendor options
startGap
andendGap
, which take a double value and can be configured on aline 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). - A vendor option
conflictResolution
, which takes a boolean value and can be configured on atext symbolizer
to disable label placement conflict resolution (label decluttering). - The vendor option
composite
with valuecopy
, which can be configured on apoint 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. - A vendor option
allowEditing
, which takes a boolean value and can be configured on apoint symbolizer
to disable editing for the symbolizer. - A vendor option
removeAlphaChannel
, which takes a boolean value and can be configured on araster symbolizer
to remove the alpha channel from an image. - The vendor options
colorReplace
andcolorReplaceTolerance
, which can be configured on araster symbolizer
to replace colors in an image. ThecolorReplace
option takes a string value consisting of a comma-separated list of values defined ashexSourceColor:hexDestinationColor
. For example,#000000:#00000000
replaces a black color with a transparent color. Depending on the band semantics of the source image (grayscale, palette, RGB or RGBA) and the specified destination color(s) (RGB or RGBA), acolor conversion operation
is optionally performed first to make sure that the color replacement can be done. More specifically, the visualized image will have RGBA band semantics if the destination color(s) and/or the source image include an alpha component; in all other cases, the visualized image will have RGB semantics. ThecolorReplaceTolerance
option takes an integer value that is used for matching the source color in the input image. The value is defined in the range (0 - 255) and defines the maximum distance between the red, green, blue and alpha components of the source color and the colors in the input image. - The vendor options
extrudedShapeMinimum
,extrudedShapeMaximum
,extrudedShapeReference
which respectively take a double, a double and aILspWorldElevationStyle.ElevationMode
, can be configured on apolygon symbolizer
to respectively define the minimum value in meters, the maximum value in meters and elevation mode of the rendered extruded shapes. - The vendor option
elevationMode
which takes aILspWorldElevationStyle.ElevationMode
, can be configured on aline symbolizer
andpolygon symbolizer
to define the elevation mode of the shapes.
- Since:
- 2012.1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTLspSLDStyler
(TLcdSLDFeatureTypeStyle aFeatureTypeStyle) Creates a new SLD styler for the givenTLcdSLDFeatureTypeStyle
.TLspSLDStyler
(TLcdSLDFeatureTypeStyle aFeatureTypeStyle, TLcdSLDContext aSLDContext) Creates a new SLD styler for the givenTLcdSLDFeatureTypeStyle
. -
Method Summary
Modifier and TypeMethodDescriptionfinal TLcdSLDFeatureTypeStyle
Returns the currently used SLD feature type style.Returns the elevation mode for icon symbolizers, or null if the default is used.Returns the elevation mode for line symbolizers, or null if the default is used.Returns the elevation mode for polygon symbolizers, or null if the default is used.int
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.final 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 anALspLabelStyleCollector
as argument instead of anALspStyleCollector
.void
style
(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext) Implementation ofILspStyler.style
that either casts theALspStyleCollector
toALspLabelStyleCollector
if possible, or adapts it otherwise.Methods inherited from class com.luciad.view.lightspeed.style.styler.ALspStyler
addStyleChangeListener, fireStyleChangeEvent, fireStyleChangeEvent, removeStyleChangeListener
-
Constructor Details
-
TLspSLDStyler
Creates a new SLD styler for the givenTLcdSLDFeatureTypeStyle
. A default, best effort, implementation is used to evaluate expressions that occur in the feature type style. UseTLspSLDStyler(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.
- Parameters:
aFeatureTypeStyle
- An SLD feature type style that defines the styles that this styler should generate. Never null.
-
TLspSLDStyler
Creates a new SLD styler for the givenTLcdSLDFeatureTypeStyle
. TheaSLDContext
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.
- Parameters:
aFeatureTypeStyle
- An SLD feature type style that defines the styles that this styler should generate. Never null.aSLDContext
- The SLD context that has to be used when applying aFeatureTypeStyle, should not be null.
-
-
Method Details
-
style
Description copied from class:ALspLabelStyler
Implementation of
ILspStyler.style
that either casts theALspStyleCollector
toALspLabelStyleCollector
if possible, or adapts it otherwise. In the latter case, the labeling-specific calls (label
,anchorLabel
,algorithm
, ...) are ignored. TheALspLabelStyleCollector
is then passed to thestyle(Collection,ALspLabelStyleCollector,TLspContext)
method.- Specified by:
style
in interfaceILspStyler
- Overrides:
style
in classALspLabelStyler
- Parameters:
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.
-
style
public void style(Collection<?> aObjects, ALspLabelStyleCollector aStyleCollector, TLspContext aContext) Description copied from class:ALspLabelStyler
Convenience method that takes an
ALspLabelStyleCollector
as argument instead of anALspStyleCollector
. This method is called fromALspLabelStyler.style(Collection, ALspStyleCollector, TLspContext)
.- Specified by:
style
in classALspLabelStyler
- Parameters:
aObjects
- The set of domain objects to provide information foraStyleCollector
- The label style collector to submit the information to.aContext
- The context- See Also:
-
setPolygonElevationMode
Sets the default elevation mode that is used by styles that correspond to polygon symbolizers. By default, the elevation mode is null, so the styler tries to use an elevation mode that gives the best visual result.- Parameters:
aElevationMode
- A valid elevation mode.
-
getPolygonElevationMode
Returns the elevation mode for polygon symbolizers, or null if the default is used.- Returns:
- The elevation mode for polygon symbolizers, null by default.
-
getLineElevationMode
Returns the elevation mode for line symbolizers, or null if the default is used.- Returns:
- The elevation mode for line symbolizers, null by default.
-
setLineElevationMode
Sets the default elevation mode that is used by styles that correspond to line symbolizers. By default, the elevation mode is null, so the styler tries to use an elevation mode that gives the best visual result.- Parameters:
aLineElevationMode
- A valid elevation mode.
-
getIconElevationMode
Returns the elevation mode for icon symbolizers, or null if the default is used.- Returns:
- The elevation mode for icon symbolizers, null by default.
-
setIconElevationMode
Sets the elevation mode that is used by styles that correspond to icon symbolizers. By default, the elevation mode is null, so the styler tries to use an elevation mode that gives the best visual result.- Parameters:
aIconElevationMode
- A valid elevation mode.
-
setZOrder
public 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.- Parameters:
aZOrder
- a Z-order value- See Also:
-
getZOrder
public int getZOrder()Returns the Z-order for point, line and polygon symbolizers, determining which shapes that are painted on top of one another.- Returns:
- the Z-order value
-
getFeatureTypeStyle
Returns the currently used SLD feature type style.Note: making changes to the returned instance is not supported. Instead, set a new instance using the
setSLDFeatureTypeStyle(TLcdSLDFeatureTypeStyle)
method.- Returns:
- the currently used SLD feature type style
- Since:
- 2017.0
-
setSLDFeatureTypeStyle
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.
- Parameters:
aSLDFeatureTypeStyle
- The new feature type style- Since:
- 2017.0
-