public final class TLspShapeLayerBuilder extends ALspLayerBuilder
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:
TLspIconStyle
, TLspLineStyle
,
TLspFillStyle
and TLsp3DMeshStyle
.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...)
.Modifier and Type | Method and Description |
---|---|
TLspShapeLayerBuilder |
bodyEditable(boolean aEditable)
Sets whether the body of the layer should be editable.
|
TLspShapeLayerBuilder |
bodyEditor(ILspEditor aEditor)
Sets the body editor for the layer, alternatively you can use
bodyEditable(boolean) to enable a default editor. |
TLspShapeLayerBuilder |
bodyMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aBodyScaleRange)
Sets the scale range for the body of the layer in unitless map scale ratios.
|
TLspShapeLayerBuilder |
bodyPainter(ILspPainter aPainter)
Allows setting a custom body painter on the layer.
|
TLspShapeLayerBuilder |
bodyScaleRange(ILcdInterval aBodyScaleRange)
Sets the scale range for the body of the layer in toolkit pixels/meter.
|
TLspShapeLayerBuilder |
bodyStyler(TLspPaintState aPaintState,
ILspStyler aBodyStyler)
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 polygons
TLspLineStyle : can be applied to closed and non-closed shapes such as arcs and polylines
TLspComplexStrokedLineStyle : can be applied to closed and non-closed shapes such as arcs and polylines
TLspWorldSizedLineStyle : can be applied to closed and non-closed shapes such as arcs and polylines
TLspIconStyle : can be applied to point shapes and point lists
TLsp3DIconStyle : can be applied to point shapes and point lists
TLspVerticalLineStyle : can be applied to point shapes and point lists
|
TLspShapeLayerBuilder |
bodyStyles(TLspPaintState aPaintState,
ALspStyle... aBodyStyles)
Sets the given body styles for the given paint state.
|
TLspLayer |
build()
Creates a new layer instance.
|
TLspShapeLayerBuilder |
culling(boolean aUseCulling)
Sets whether the layer should use culling or not, enabled by default.
|
TLspShapeLayerBuilder |
editableSupported(boolean aEditableSupported)
Sets whether the layer should support editing.
|
TLspShapeLayerBuilder |
filter(ILcdDynamicFilter aFilter)
Sets a filter that will be used to filter objects to prevent them from
being painted by the layer.
|
TLspShapeLayerBuilder |
icon(ILcdIcon aIcon)
Sets the icon of the layer.
|
TLspShapeLayerBuilder |
label(String aLabel)
Sets the label of the layer.
|
TLspShapeLayerBuilder |
labelEditable(boolean aEditable)
Sets whether the labels of the layer should be editable.
|
TLspShapeLayerBuilder |
labelEditor(ILspEditor aEditor)
Sets a custom label editor for the layer, alternatively you can use
labelEditable(boolean) to enable a default label editor. |
TLspShapeLayerBuilder |
labelMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aLabelScaleRange)
Sets the scale range for the labels of the layer in unitless map scale ratios.
|
TLspShapeLayerBuilder |
labelPainter(ILspPainter aPainter)
Allows setting a custom label painter on the layer.
|
TLspShapeLayerBuilder |
labelScaleRange(ILcdInterval aLabelScaleRange)
Sets the scale range for the labels of the layer in toolkit pixels/meter.
|
TLspShapeLayerBuilder |
labelStyler(TLspPaintState aPaintState,
ILspStyler aLabelStyler)
Sets the given label styler for the given paint state.
|
TLspShapeLayerBuilder |
labelStyles(TLspPaintState aPaintState,
ALspStyle... aLabelStyles)
Sets the given label styles for the given paint state.
|
TLspShapeLayerBuilder |
layerStyle(TLspLayerStyle aLayerStyle)
Set a layer style to be used during the rendering of the layer.
|
TLspShapeLayerBuilder |
layerType(ILspLayer.LayerType aLayerType)
Sets the layer type of the layer.
|
TLspShapeLayerBuilder |
minimumObjectSizeForPainting(double aMinimumObjectSizeForPainting)
Sets the minimum size of an object in the view for it to be painted and handled otherwise.
|
TLspShapeLayerBuilder |
model(ILcdModel aModel)
Sets the model of the layer.
|
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.
|
static TLspShapeLayerBuilder |
newBuilder() |
static TLspShapeLayerBuilder |
newBuilder(ILspLayer.LayerType aLayerType)
Creates a TLspShapeLayerBuilder.newBuilder with the given layer type.
|
TLspShapeLayerBuilder |
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.
|
TLspShapeLayerBuilder |
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.
|
TLspShapeLayerBuilder |
paintingHints(TLspShapePaintingHints aPaintingHints)
Sets the painting hints to be used by created layers.
|
TLspShapeLayerBuilder |
selectable(boolean aSelectable)
Sets whether the layer should be selectable, by default, non-background layers
are selectable.
|
TLspShapeLayerBuilder |
selectableSupported(boolean aSelectableSupported)
Sets whether the layer should support selection.
|
TLspShapeLayerBuilder |
sldStyle(TLcdSLDFeatureTypeStyle aFeatureTypeStyle)
Use the styling defined in
aFeatureTypeStyle to style the layer under creation. |
TLspShapeLayerBuilder |
snapTarget(boolean aIsSnapTarget)
Sets whether the created layer should be regarded as a source for snapping points.
|
TLspShapeLayerBuilder |
synchronizePainters(boolean aSynchronizePainters)
Sets whether the painters should be synchronized or not.
|
TLspShapeLayerBuilder |
synchronous(boolean aIsSynchronous)
Specifies whether created layers should paint synchronously.
|
getIcon, getLabel, getLayerStyle, getLayerType, getModel
public static TLspShapeLayerBuilder newBuilder()
public static TLspShapeLayerBuilder newBuilder(ILspLayer.LayerType aLayerType)
ILspLayer.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.aLayerType
- the layer type for the layer built by this builderpublic TLspLayer build()
ALspLayerBuilder
Creates a new layer instance.
build
in class ALspLayerBuilder
public TLspShapeLayerBuilder selectable(boolean aSelectable)
aSelectable
- whether the layer should be selectablethis
public TLspShapeLayerBuilder selectableSupported(boolean aSelectableSupported)
aSelectableSupported
- whether the layer should support selectionthis
public TLspShapeLayerBuilder editableSupported(boolean aEditableSupported)
aEditableSupported
- whether the layer should support selectionthis
public TLspShapeLayerBuilder bodyEditable(boolean aEditable)
aEditable
- whether the body of the layer should be editablethis
bodyEditor(ILspEditor)
public TLspShapeLayerBuilder labelEditable(boolean aEditable)
aEditable
- whether the labels of the layer should be editablethis
labelEditor(ILspEditor)
public TLspShapeLayerBuilder bodyStyler(TLspPaintState aPaintState, ILspStyler aBodyStyler)
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 listsUse either bodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
or bodyStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.
aPaintState
- the paint state for which to set the body styleraBodyStyler
- the new body styler for the layerthis
public TLspShapeLayerBuilder bodyStyles(TLspPaintState aPaintState, ALspStyle... aBodyStyles)
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 listsUse either bodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
or bodyStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.
aPaintState
- the paint state for which to set the body styleraBodyStyles
- the new body styles for the layerthis
public TLspShapeLayerBuilder labelStyler(TLspPaintState aPaintState, ILspStyler aLabelStyler)
If you need control over other labeling aspects such as positioning or priorities, use an ALspLabelStyler
.
toString()
). See also TLspDataObjectLabelTextProviderStyle.Use either labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
or labelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.
aPaintState
- the paint state for which to set the label styleraLabelStyler
- the new label styler for the layerthis
public TLspShapeLayerBuilder labelStyles(TLspPaintState aPaintState, ALspStyle... aLabelStyles)
toString()
). See also TLspDataObjectLabelTextProviderStyle.Use either labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
or labelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
, not both.
aPaintState
- the paint state for which to set the label stylesaLabelStyles
- the new label styles for the layerthis
public TLspShapeLayerBuilder bodyPainter(ILspPainter aPainter)
bodyStyler(TLspPaintState, ILspStyler)
or
bodyStyles(TLspPaintState, ALspStyle...)
methods instead.
One example of using a custom painter is the TLspDensityPainter
to
create a density plot layer.aPainter
- the body painter for the layerthis
public TLspShapeLayerBuilder labelPainter(ILspPainter aPainter)
labelStyler(TLspPaintState, ILspStyler)
or
labelStyles(TLspPaintState, ALspStyle...)
methods instead.aPainter
- the label painter for the layerthis
TLspLabelPainter
public TLspShapeLayerBuilder bodyEditor(ILspEditor aEditor)
bodyEditable(boolean)
to enable a default editor.aEditor
- the body editor for the layerthis
TLspShapeEditor
public TLspShapeLayerBuilder labelEditor(ILspEditor aEditor)
labelEditable(boolean)
to enable a default label editor.aEditor
- the label editor for the layerthis
TLspLabelEditor
public TLspShapeLayerBuilder bodyScaleRange(ILcdInterval aBodyScaleRange)
aBodyScaleRange
- the scale range for the body of the layer, in toolkit pixels/meterthis
public TLspShapeLayerBuilder bodyMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aBodyScaleRange)
aBodyScaleRange
- the scale range for the body of the layerthis
public TLspShapeLayerBuilder labelScaleRange(ILcdInterval aLabelScaleRange)
aLabelScaleRange
- the scale range for the labels of the layer, in toolkit pixels/meterthis
public TLspShapeLayerBuilder labelMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aLabelScaleRange)
aLabelScaleRange
- the scale range for the labels of the layerthis
public TLspShapeLayerBuilder culling(boolean aUseCulling)
ILcd2DBoundsIndexedModel
.
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 both pixels
and meters
.aUseCulling
- whether the layer should use culling or notthis
public TLspShapeLayerBuilder filter(ILcdDynamicFilter aFilter)
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.
aFilter
- the filterthis
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.
aModelQueryConfiguration
- The model query configurationthis
public TLspShapeLayerBuilder sldStyle(TLcdSLDFeatureTypeStyle aFeatureTypeStyle)
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.
aFeatureTypeStyle
- The feature type stylepublic TLspShapeLayerBuilder minimumObjectSizeForPainting(double aMinimumObjectSizeForPainting)
applyOnInteract
(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.
See TLspLayer.setMinimumObjectSizeForPainting(double)
for more information.aMinimumObjectSizeForPainting
- The minimal size, expressed in pixels.this
public TLspShapeLayerBuilder objectViewMargin(double aObjectViewMargin)
culling
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 a maximum distance in meters
.
The default value is 32
.aObjectViewMargin
- the maximum difference (in pixels)this
public TLspShapeLayerBuilder objectWorldMargin(double aObjectWorldMargin)
culling
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 a maximum distance in pixels
.
The default value is 0
.aObjectWorldMargin
- the maximum difference in metersthis
public TLspShapeLayerBuilder synchronizePainters(boolean aSynchronizePainters)
true
.aSynchronizePainters
- true
if the painters should be synchronizedthis
public TLspShapeLayerBuilder paintingHints(TLspShapePaintingHints aPaintingHints)
TLspShapePaintingHints.newBuilder().build()
.
The hints must not be null
.aPaintingHints
- the painting hints to be usedthis
public TLspShapeLayerBuilder synchronous(boolean aIsSynchronous)
aIsSynchronous
- true if the layer should paint synchronouslythis
public TLspShapeLayerBuilder snapTarget(boolean aIsSnapTarget)
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.public TLspShapeLayerBuilder model(ILcdModel aModel)
ALspLayerBuilder
null
.model
in class ALspLayerBuilder
aModel
- a modelILcdLayer.getModel()
public TLspShapeLayerBuilder label(String aLabel)
ALspLayerBuilder
null
.label
in class ALspLayerBuilder
aLabel
- the labelILcdLayer.getLabel()
public TLspShapeLayerBuilder layerType(ILspLayer.LayerType aLayerType)
ALspLayerBuilder
ILspLayer.LayerType.EDITABLE
.layerType
in class ALspLayerBuilder
aLayerType
- the layer typeILspLayer.getLayerType()
public TLspShapeLayerBuilder icon(ILcdIcon aIcon)
ALspLayerBuilder
null
.icon
in class ALspLayerBuilder
aIcon
- the iconILcdLayer.getIcon()
public TLspShapeLayerBuilder layerStyle(TLspLayerStyle aLayerStyle)
ALspLayerBuilder
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 calling
ILspLayer.setLayerStyle(TLspLayerStyle)
.layerStyle
in class ALspLayerBuilder
aLayerStyle
- the layer style. Must not be null
. If you want to set the default layer style, set TLspLayerStyle.newBuilder().build()
ILspLayer.getLayerStyle()
,
ILspLayer.setLayerStyle(TLspLayerStyle)