Class TLspShapeLayerBuilder
ILspLayer
instances that visualize geometric shapes. This builder is the
recommended way of creating new layers with a model that contains
ILcdShape
and/or ILcd3DMesh
elements.
This layer builder uses the following default settings to allow for easy
layer setup, they can all be overridden using the methods available on this
builder:
- Default styles for points, curves, surfaces and geo-referenced meshes are used if none are
specified. The actual styling parameters are taken from
TLspIconStyle
,TLspLineStyle
,TLspFillStyle
andTLsp3DMeshStyle
. - Selection is enabled, selection styling is derived from the regular style.
- Editing is disabled.
- Labeling is disabled.
- The model descriptor display name is used as layer label.
- Culling is enabled.
- Snapping is enabled
bodyEditable(boolean)
to true
and optionally provide a custom editor through bodyEditor(com.luciad.view.lightspeed.editor.ILspEditor)
.
To enable labels, set a styler for labels using labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
. You can use the default TLspLabelStyler
, or create your own. However, the styler must apply at least one style to the domain objects for any labels to be displayed.
Alternatively, you can can also just add a TLspTextStyle
using labelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
.- Since:
- 2012.0
-
Method Summary
Modifier and TypeMethodDescriptionbodyEditable
(boolean aEditable) Sets whether the body of the layer should be editable.bodyEditor
(ILspEditor aEditor) Sets the body editor for the layer, alternatively you can usebodyEditable(boolean)
to enable a default editor.bodyMapScaleRange
(TLcdDimensionInterval<TLcdMapScale> aBodyScaleRange) Sets the scale range for the body of the layer in unitless map scale ratios.bodyPainter
(ILspPainter aPainter) Allows setting a custom body painter on the layer.bodyScaleRange
(ILcdInterval aBodyScaleRange) Sets the scale range for the body of the layer in toolkit pixels/meter.bodyStyler
(TLspPaintState aPaintState, ILspStyler aBodyStyler) Sets the given body styler for the given paint state.bodyStyles
(TLspPaintState aPaintState, ALspStyle... aBodyStyles) Sets the given body styles for the given paint state.build()
Creates a new layer instance.culling
(boolean aUseCulling) Sets whether the layer should use culling or not, enabled by default.editableSupported
(boolean aEditableSupported) Sets whether the layer should support editing.filter
(ILcdDynamicFilter aFilter) Sets a filter that will be used to filter objects to prevent them from being painted by the layer.Sets the icon of the layer.Sets the label of the layer.labelEditable
(boolean aEditable) Sets whether the labels of the layer should be editable.labelEditor
(ILspEditor aEditor) Sets a custom label editor for the layer, alternatively you can uselabelEditable(boolean)
to enable a default label editor.labelMapScaleRange
(TLcdDimensionInterval<TLcdMapScale> aLabelScaleRange) Sets the scale range for the labels of the layer in unitless map scale ratios.labelPainter
(ILspPainter aPainter) Allows setting a custom label painter on the layer.labelScaleRange
(ILcdInterval aLabelScaleRange) Sets the scale range for the labels of the layer in toolkit pixels/meter.labelStyler
(TLspPaintState aPaintState, ILspStyler aLabelStyler) Sets the given label styler for the given paint state.labelStyles
(TLspPaintState aPaintState, ALspStyle... aLabelStyles) Sets the given label styles for the given paint state.layerStyle
(TLspLayerStyle aLayerStyle) Set a layer style to be used during the rendering of the layer.layerType
(ILspLayer.LayerType aLayerType) Sets the layer type of the layer.minimumObjectSizeForPainting
(double aMinimumObjectSizeForPainting) Sets the minimum size of an object in the view for it to be painted and handled otherwise.Sets the model of the layer.modelQueryConfiguration
(TLcdModelQueryConfiguration aModelQueryConfiguration) Sets the model query configuration which defines the filters that the layer will use when querying the model during the paint operation.static TLspShapeLayerBuilder
static TLspShapeLayerBuilder
newBuilder
(ILspLayer.LayerType aLayerType) Creates a TLspShapeLayerBuilder.newBuilder with the given layer type.objectViewMargin
(double aObjectViewMargin) Sets the largest possible difference (in pixels) between an object's model bounds and its painted representation's bounds that should be taken into account.objectWorldMargin
(double aObjectWorldMargin) Sets the largest possible difference (in meters) between an object's model bounds and its painted representation's bounds that should be taken into account.paintingHints
(TLspShapePaintingHints aPaintingHints) Sets the painting hints to be used by created layers.selectable
(boolean aSelectable) Sets whether the layer should be selectable, by default, non-background layers are selectable.selectableSupported
(boolean aSelectableSupported) Sets whether the layer should support selection.sldStyle
(TLcdSLDFeatureTypeStyle aFeatureTypeStyle) Use the styling defined inaFeatureTypeStyle
to style the layer under creation.snapTarget
(boolean aIsSnapTarget) Sets whether the created layer should be regarded as a source for snapping points.synchronizePainters
(boolean aSynchronizePainters) Sets whether the painters should be synchronized or not.synchronous
(boolean aIsSynchronous) Specifies whether created layers should paint synchronously.Methods inherited from class com.luciad.view.lightspeed.layer.ALspLayerBuilder
getIcon, getLabel, getLayerStyle, getLayerType, getModel
-
Method Details
-
newBuilder
- Returns:
- a new layer builder with the default settings.
-
newBuilder
Creates a TLspShapeLayerBuilder.newBuilder with the given layer type. When creating a layer for use with dynamic data, it is highly recommended to use theILspLayer.LayerType.REALTIME
layer type, since it provides various performance enhancements for dynamic data. Failing to do so may result in a non-negligible performance cost.- Parameters:
aLayerType
- the layer type for the layer built by this builder- Returns:
- a new layer builder with the given layer type
-
build
Description copied from class:ALspLayerBuilder
Creates a new layer instance.
- Specified by:
build
in classALspLayerBuilder
- Returns:
- the new layer instance
-
selectable
Sets whether the layer should be selectable, by default, non-background layers are selectable.- Parameters:
aSelectable
- whether the layer should be selectable- Returns:
this
-
selectableSupported
Sets whether the layer should support selection. By default, layers support selection.- Parameters:
aSelectableSupported
- whether the layer should support selection- Returns:
this
-
editableSupported
Sets whether the layer should support editing. By default, layers support editing if any editors are set.- Parameters:
aEditableSupported
- whether the layer should support selection- Returns:
this
-
bodyEditable
Sets whether the body of the layer should be editable. A default body editor will be used if no body editor is provided.- Parameters:
aEditable
- whether the body of the layer should be editable- Returns:
this
- See Also:
-
labelEditable
Sets whether the labels of the layer should be editable. A default label editor will be used if no label editor is provided.- Parameters:
aEditable
- whether the labels of the layer should be editable- Returns:
this
- See Also:
-
bodyStyler
Sets the given body styler for the given paint state. The following styles are supported:TLspFillStyle
: can be applied to closed shapes such as circles or polygonsTLspLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspComplexStrokedLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspWorldSizedLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspIconStyle
: can be applied to point shapes and point listsTLsp3DIconStyle
: can be applied to point shapes and point listsTLspVerticalLineStyle
: can be applied to point shapes and point lists
Use either
bodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
orbodyStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.- Parameters:
aPaintState
- the paint state for which to set the body styleraBodyStyler
- the new body styler for the layer- Returns:
this
-
bodyStyles
Sets the given body styles for the given paint state. The following styles are supported:TLspFillStyle
: can be applied to closed shapes such as circles or polygonsTLspLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspComplexStrokedLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspWorldSizedLineStyle
: can be applied to closed and non-closed shapes such as arcs and polylinesTLspIconStyle
: can be applied to point shapes and point listsTLsp3DIconStyle
: can be applied to point shapes and point listsTLspVerticalLineStyle
: can be applied to point shapes and point lists
Use either
bodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
orbodyStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.- Parameters:
aPaintState
- the paint state for which to set the body styleraBodyStyles
- the new body styles for the layer- Returns:
this
-
labelStyler
Sets the given label styler for the given paint state.If you need control over other labeling aspects such as positioning or priorities, use an
The following styles are supported:ALspLabelStyler
.- TLspTextStyle to get text with a specific font, font color, size, halo etc.
- TLspIconStyle to get custom images.
- ALspLabelTextProviderStyle
to specify which text to use (default is
toString()
). See also TLspDataObjectLabelTextProviderStyle. - TLspLabelBoxStyle to specify fill color or frames
- TLspLabelOpacityStyle to specify the opacity and modulation color.
- TLspPinLineStyle to draw pins for the labels (see TLspLabelPainter)
Use either
labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
orlabelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.- Parameters:
aPaintState
- the paint state for which to set the label styleraLabelStyler
- the new label styler for the layer- Returns:
this
-
labelStyles
Sets the given label styles for the given paint state. The following styles are supported:- TLspTextStyle to get text with a specific font, font color, size, halo etc.
- TLspIconStyle to get custom images.
- ALspLabelTextProviderStyle
to specify which text to use (default is
toString()
). See also TLspDataObjectLabelTextProviderStyle. - TLspLabelBoxStyle to specify fill color or frames
- TLspLabelOpacityStyle to specify the opacity and modulation color.
- TLspPinLineStyle to draw pins for the labels (see TLspLabelPainter)
Use either
labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
orlabelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.- Parameters:
aPaintState
- the paint state for which to set the label stylesaLabelStyles
- the new label styles for the layer- Returns:
this
-
bodyPainter
Allows setting a custom body painter on the layer. In almost any case, it is better to configure the default painter using thebodyStyler(TLspPaintState, ILspStyler)
orbodyStyles(TLspPaintState, ALspStyle...)
methods instead. One example of using a custom painter is theTLspDensityPainter
to create a density plot layer.- Parameters:
aPainter
- the body painter for the layer- Returns:
this
-
labelPainter
Allows setting a custom label painter on the layer. In almost any case, it is better to configure the default label painter using thelabelStyler(TLspPaintState, ILspStyler)
orlabelStyles(TLspPaintState, ALspStyle...)
methods instead.- Parameters:
aPainter
- the label painter for the layer- Returns:
this
- See Also:
-
bodyEditor
Sets the body editor for the layer, alternatively you can usebodyEditable(boolean)
to enable a default editor.- Parameters:
aEditor
- the body editor for the layer- Returns:
this
- See Also:
-
labelEditor
Sets a custom label editor for the layer, alternatively you can uselabelEditable(boolean)
to enable a default label editor.- Parameters:
aEditor
- the label editor for the layer- Returns:
this
- See Also:
-
bodyScaleRange
Sets the scale range for the body of the layer in toolkit pixels/meter. This property defines a range of scales in which the bodies of the layer are visible. By default, no scale range is used, meaning that all bodies are visible.- Parameters:
aBodyScaleRange
- the scale range for the body of the layer, in toolkit pixels/meter- Returns:
this
-
bodyMapScaleRange
Sets the scale range for the body of the layer in unitless map scale ratios. This property defines a range of scales in which the bodies of the layer are visible. By default, no scale range is used, meaning that all bodies are visible.- Parameters:
aBodyScaleRange
- the scale range for the body of the layer- Returns:
this
- Since:
- 2021.0
-
labelScaleRange
Sets the scale range for the labels of the layer in toolkit pixels/meter. This property defines a range of scales in which the labels of the layer are visible. By default, no scale range is used, meaning that all labels are visible.- Parameters:
aLabelScaleRange
- the scale range for the labels of the layer, in toolkit pixels/meter- Returns:
this
-
labelMapScaleRange
public TLspShapeLayerBuilder labelMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aLabelScaleRange) Sets the scale range for the labels of the layer in unitless map scale ratios. This property defines a range of scales in which the labels of the layer are visible. By default, no scale range is used, meaning that all labels are visible.- Parameters:
aLabelScaleRange
- the scale range for the labels of the layer- Returns:
this
- Since:
- 2021.0
-
culling
Sets whether the layer should use culling or not, enabled by default. Enabling culling restricts the objects that are painted to those that (approximately) overlap with the view. This typically reduces the memory usage and increases the frame rate. However because culling also introduces an additional overhead, you may get better performance by disabling it for either very dynamic layers or layers with only a small amount of objects. The cost of culling is typically higher if the model does not implementILcd2DBoundsIndexedModel
. The culling of objects is based on their model bounds. These bounds may be (slightly) different from the painted representation's bounds. This can occur due to styling (for example painting a point as a circle or as a view-sized icon). To ensure that objects all objects are correctly painted in these cases you can configure a margin in bothpixels
andmeters
.- Parameters:
aUseCulling
- whether the layer should use culling or not- Returns:
this
-
filter
Sets a filter that will be used to filter objects to prevent them from being painted by the layer. No filter is set by default.
Consult the class javadoc of
TLspLayer
for more information about data filtering.- Parameters:
aFilter
- the filter- Returns:
this
-
modelQueryConfiguration
public TLspShapeLayerBuilder modelQueryConfiguration(TLcdModelQueryConfiguration aModelQueryConfiguration) Sets the model query configuration which defines the filters that the layer will use when querying the model during the paint operation.
Consult the class javadoc of
TLspLayer
for more information about data filtering.- Parameters:
aModelQueryConfiguration
- The model query configuration- Returns:
this
- Since:
- 2017.0
-
sldStyle
Use the styling defined in
aFeatureTypeStyle
to style the layer under creation. All relevant settings on the layer will be adjusted to match the info contained in the SLD style.Calling this method is the equivalent of calling (in pseudo-code):
//Create a model query configuration based on the SLD TLcdModelQueryConfiguration config = calculateFromSLD(aFeatureTypeStyle); //Create an SLD styler TLspSLDStyler styler = new TLspSLDStyler(aFeatureTypeStyle); //Configure those instances on the builder builder.modelQueryConfiguration(config) .bodyStyler(TLspPaintState.REGULAR, styler) .labelStyler(TLspPaintState.REGULAR, styler);
If you need to override certain settings, while wanting to retain the rest, you can call this method and override some settings afterwards. For example, if you want to use a specific SLD context for the styler, you can use:
//Create a SLD styler which uses a custom context TLcdSLDContext context = createCustomSLDContext(); TLspSLDStyler customSLDStyler = new TLspSLDStyler(aFeatureTypeStyle, context); //Override the styler, while retaining the SLD-based model query configuration builder.sldStyle(aFeatureTypeStyle) .bodyStyler(TLspPaintState.REGULAR, customSLDStyler) .labelStyler(TLspPaintState.REGULAR, customSLDStyler);
Note that in future versions of the product it is possible that this method will overwrite more settings.
- Parameters:
aFeatureTypeStyle
- The feature type style- Returns:
- this builder
- Since:
- 2017.0
-
minimumObjectSizeForPainting
Sets the minimum size of an object in the view for it to be painted and handled otherwise. So objects that are smaller as this minimum size are ignored during painting and duringapplyOnInteract
(which is for example used during selection). A value of 0 will always paint all objects, no matter how small they appear. Larger values can discard more objects. This typically improves the painting speed, although it might leave undesirable gaps in models containing many small objects. The default value is 1 pixel. SeeTLspLayer.setMinimumObjectSizeForPainting(double)
for more information.- Parameters:
aMinimumObjectSizeForPainting
- The minimal size, expressed in pixels.- Returns:
this
-
objectViewMargin
Sets the largest possible difference (in pixels) between an object's model bounds and its painted representation's bounds that should be taken into account. This value is used when determining what objects are visible (ifculling
is enabled). It ensures, for example, that a model element is still painted if its visual representation falls inside the view, but its model bounds do not. If for example view-sized icons are used to represent points on the map, the icon could be 16 by 16 pixels, whereas the object itself is a point, having a zero size. Depending on where the point is located in the icon, the required margin for this example can be up to 16 pixels. The drawback of setting a too large value is a performance loss. The drawback of setting a too small value is that objects (e.g. icons) disappear when they are located partly outside the view. You can also configure amaximum distance in meters
. The default value is32
.- Parameters:
aObjectViewMargin
- the maximum difference (in pixels)- Returns:
this
-
objectWorldMargin
Sets the largest possible difference (in meters) between an object's model bounds and its painted representation's bounds that should be taken into account. This value is used when determining what objects are visible (ifculling
is enabled). It ensures, for example, that a model element is still painted if its visual representation falls inside the view, but its model bounds do not. If for example circles are used to represent points on the map, the circle could have a radius of 1km, whereas the object itself is a point, having a zero size. The required margin for this example is 1000 meters. The drawback of setting a too large value is a performance loss. The drawback of setting a too small value is that objects (e.g. icons) disappear when they are located partly outside the view. You can also configure amaximum distance in pixels
. The default value is0
.- Parameters:
aObjectWorldMargin
- the maximum difference in meters- Returns:
this
-
synchronizePainters
Sets whether the painters should be synchronized or not. If the synchronization is enabled then all painters will be updated at the same time. For example the body and label of the objects in the view will be consistent. However enabling synchronization typically also increases the memory usage and latency of the layer. The default value istrue
.- Parameters:
aSynchronizePainters
-true
if the painters should be synchronized- Returns:
this
-
paintingHints
Sets the painting hints to be used by created layers. The hints are only respected when no custom painter is set (i.e. when bodyPainter(ILspPainter) is not called). The default value isTLspShapePaintingHints.newBuilder().build()
. The hints must not benull
.- Parameters:
aPaintingHints
- the painting hints to be used- Returns:
this
-
synchronous
Specifies whether created layers should paint synchronously. The default is false and allows layers to perform shape discretization and other expensive processing using the view's ILspTaskExecutor. When synchronous mode is on, all such tasks are performed on the EDT. It is strongly recommended to leave this setting off, to ensure that the application remains responsive. Applications that need to change the view's world reference on a regular basis, however, may want to consider synchronous mode to avoid flickering.- Parameters:
aIsSynchronous
- true if the layer should paint synchronously- Returns:
this
-
snapTarget
Sets whether the created layer should be regarded as a source for snapping points.- Parameters:
aIsSnapTarget
- if true, the created layer should be regarded as a source for snapping points, i.e. it should be possible to snap to objects in the layer; if false, the layer should not produce snapping candidates.- Since:
- 2018.0
-
model
Description copied from class:ALspLayerBuilder
Sets the model of the layer. The default value isnull
.- Overrides:
model
in classALspLayerBuilder
- Parameters:
aModel
- a model- Returns:
- this builder
- See Also:
-
label
Description copied from class:ALspLayerBuilder
Sets the label of the layer. This is a short textual representation for it, often used to represent the layer to end-users. The default value isnull
.- Overrides:
label
in classALspLayerBuilder
- Parameters:
aLabel
- the label- Returns:
- this builder
- See Also:
-
layerType
Description copied from class:ALspLayerBuilder
Sets the layer type of the layer. The default value isILspLayer.LayerType.EDITABLE
.- Overrides:
layerType
in classALspLayerBuilder
- Parameters:
aLayerType
- the layer type- Returns:
- this builder
- See Also:
-
icon
Description copied from class:ALspLayerBuilder
Sets the icon of the layer. The default value isnull
.- Overrides:
icon
in classALspLayerBuilder
- Parameters:
aIcon
- the icon- Returns:
- this builder
- See Also:
-
layerStyle
Description copied from class:ALspLayerBuilder
Set a layer style to be used during the rendering of the layer.TLspLayerStyle
is used to style the layer as a whole. Layer style can for example modify the transparency of a layer. Also, layer style can be modified after building the layer by callingILspLayer.setLayerStyle(TLspLayerStyle)
.- Overrides:
layerStyle
in classALspLayerBuilder
- Parameters:
aLayerStyle
- the layer style. Must not benull
. If you want to set the default layer style, setTLspLayerStyle.newBuilder().build()
- Returns:
- this
- See Also:
-