Class TLspFusionVectorLayerBuilder
Builder class for creating ILspLayer
instances for the visualization
of LuciadFusion vector data in a Lightspeed view.
A layer, ready to be added to the view, can be created as follows:
ILcdModel model = ...;
ILspLayer layer = TLspFusionVectorLayerBuilder().newBuilder().model( model ).build();
The above snippet creates a layer with default visualization setting. If you want to customize this visualization, it is important to understand how the default visualization works, and what hooks are provided to customize this. This is explained in the next sections.
Default visualization
The layer created by this builder is by default configured with stylers for the body and the labels. These default stylers will ensure that:
-
The SLD styling is respected when it is available on the coverage (see
ALfnCoverageMetadata.getFeatureTypeStyles()
). - GeoSym styling is used for VPF data, if the Defense Standards component is available (i.e., if it is defined in the license and if the corresponding Java library is found in the classpath). If not available, it will fall back to default styling instead.
-
Default colors and styles are used in other cases.
You can adjust those by replacing the fallback body styler using
fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
andfallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
. -
When
filters
are defined on the coverage, they will be respected by this layer. This means domain objects will only remain visible until the scale is reached for which the filter which accepts that domain object is defined. The domain object will then remain visible when zooming in further.
Customize the visualization
It is perfectly possible to customize the visualization of the data on the client side by using the available API on this builder.
However, if the custom visualization can be defined in SLD, it is highly recommended to fuse your vector data using an SLD file containing all the styling information.
This SLD information will be picked up by the created layer automatically.
Consult the javadoc of TLfnVectorCoverageMetadata
for more information.
To customize the visualization, you can set your own ILspStyler
for bodies and / or labels using the
bodyStyler
,
bodyStyles
,
labelStyler
or
labelStyles
methods.
Consult the Writing your own ILspStyler
section for more information on how to write your own styler for Fusion vector data.
Using any of the above mentioned methods will completely replace the default styling for bodies and/or labels.
This means SLD styling is no longer picked up automatically and GeoSym styling is no longer automatically applied for VPF data.
If you want to retain that functionality and only want to alter the default styling for other coverages, you can use the
fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
and/or fallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
methods.
Working with Fusion vector domain objects
Fusion vector domain objects implement ILcdDataObject
and ILcdShapeList
.
While you can safely access all the ILcdDataObject
methods, you should take care when using the ILcdShapeList
API.
Fusion vector features often have multiple geospatial representations:
a same feature may for example be represented by a point at world-scale and a polygon at a more detailed zoom level.
The ILcdShapeList
interface of these features only provide access to the geometry of the feature at the most detailed level.
This most detailed level geometry is typically not loaded yet, and must be retrieved on-demand when you access the ILcdShapeList
API.
If you need access to the geometry of a LuciadFusion domain object (for example when writing an ILspLabelingAlgorithm
)
you must make sure you use the geometry associated with the tiles loaded for the level and bounds associated with the view.
This geometry is obtained by calling the TLspFusionGeometryProvider.getGeometry(Object, com.luciad.view.lightspeed.TLspContext)
method.
Failing to do this will load the original untiled geometry, which will have to be retrieved at that moment and may be very costly.
Consult the javadoc of the TLspFusionGeometryProvider.getGeometry(Object, com.luciad.view.lightspeed.TLspContext)
method for more information about the kind of geometries that will be returned.
This also has an effect on the ILspStyler
instances which you set on this builder.
See the next section for more information.
Writing your own ILspStyler
When writing your own ILspStyler
for Fusion vector domain objects, you should avoid loading the most detailed geometries as this is a costly operation.
To facilitate this, this builder will decorate all ILspStyler
instances with an ALspStyleTargetProvider
which uses the tile-specific geometry.
As a result, you can simply use a regular styler as you would normally use in LuciadLightspeed:
@Override
void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext){
List<Object> majorRoads = new List<Object>();
List<Object> minorRoads = new List<Object>();
for (Object domainObject : aObjects) {
boolean isMajorRoad = "motorway".equals( ((ILcdDataObject)domainObject).getValue("roadType") );
if (isMajorRoad) {
majorRoads.add(domainObject);
} else {
minorRoads.add(domainObject);
}
}
if (!majorRoads.isEmpty()){
aStyleCollector.objects(majorRoads).style(fMajorRoadsStyle).submit();
}
if (!minorRoads.isEmpty() ){
aStyleCollector.objects(minorRoads).style(fMajorRoadsStyle).submit();
}
}
The decorator will ensure that the correct geometry (=the tile-specific geometry) is placed on the style collector.
Note that when you place your own ALspStyleTargetProvider
on the ALspStyleCollector
, your own
style target provider will never receive the domain objects.
It will only receive the tile-specific geometries.
The javadoc of TLspFusionGeometryProvider#getGeometry
lists what those tile-specific geometries are.
It is important to note that in your styler you should NEVER call
@Override
void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext) {
for (Object domainObject : aObjects) {
//NEVER DO THIS
if (domainObject instanceof ILcdShapeList){
ILcdShapeList shapeList = (ILcdShapeList) domainObject;
...
//working with the ILcdShapeList API will trigger the loading of the most detailed tiles
//this will kill the performance
}
}
}
- Since:
- 2012.1
-
Method Summary
Modifier and TypeMethodDescriptionbodyPainter
(ILspPainter aPainter) Deprecated.Customizing the body painter should be done by using thebodyStyler(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...)
method.bodyScaleRange
(ILcdInterval aBodyScaleRange) Deprecated.Sets the scale range for the body of the layer.bodyStyler
(TLspPaintState aPaintState, ILspStyler aBodyStyler) Deprecated.Sets the given body styler for the given paint state.bodyStyles
(TLspPaintState aPaintState, ALspStyle... aBodyStyles) Deprecated.Sets the given body styles for the given paint state.build()
Deprecated.Creates a new layer instance.fallbackBodyStyler
(TLspPaintState aPaintState, ILspStyler aFallbackBodyStyler) Deprecated.Sets the body styler which is used as fallback when the coverage does not contain SLD information nor VPF data.fallbackLabelStyler
(TLspPaintState aPaintState, ILspStyler aFallbackLabelStyler) Deprecated.Sets the label styler which is used as fallback when the coverage does not contains SLD information nor VPF data.filter
(ILcdDynamicFilter aFilter) Deprecated.Sets a filter that will be used to filter objects to prevent them from being painted by the layer.Deprecated.Sets the icon of the layer.Deprecated.Sets the label of the layer.labelPainter
(ILspPainter aPainter) Deprecated.Customizing the label painter should be done by using thelabelStyler(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...)
method.labelScaleRange
(ILcdInterval aLabelScaleRange) Deprecated.Sets the scale range for the labels of the layerlabelStyler
(TLspPaintState aPaintState, ILspStyler aLabelStyler) Deprecated.Sets the given label styler for the given paint state.labelStyles
(TLspPaintState aPaintState, ALspStyle... aLabelStyles) Deprecated.Sets the given label styles for the given paint state.layerType
(ILspLayer.LayerType aLayerType) Deprecated.Sets the layer type of the layer.minimumObjectSizeForPainting
(double aMinimumObjectSizeForPainting) Deprecated.Sets the minimum size of an object in the view for it to be painted and handled otherwise.Deprecated.Sets the model of the layer.static TLspFusionVectorLayerBuilder
Deprecated.Returns a new layer builder with the default settings.objectViewMargin
(double aObjectViewMargin) Deprecated.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) Deprecated.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) Deprecated.Sets the painting hints to be used by created layers.selectable
(boolean aSelectable) Deprecated.Sets whether the layer should be selectable.Methods inherited from class com.luciad.view.lightspeed.layer.ALspLayerBuilder
getIcon, getLabel, getLayerStyle, getLayerType, getModel, layerStyle
-
Method Details
-
newBuilder
Deprecated.Returns a new layer builder with the default settings.- Returns:
- a new layer builder with the default settings.
-
build
Deprecated.Description copied from class:ALspLayerBuilder
Creates a new layer instance.
- Specified by:
build
in classALspLayerBuilder
- Returns:
- the new layer instance
-
selectable
Deprecated.Sets whether the layer should be selectable.- Parameters:
aSelectable
- whether the layer should be selectable- Returns:
this
-
bodyStyler
Deprecated.Sets the given body styler for the given paint state.
The following styles are supported:
TLspFillStyle
: can be applied to areasTLspLineStyle
: can be applied to lines and areasTLspComplexStrokedLineStyle
: can be applied to lines and areasTLspWorldSizedLineStyle
: can be applied to lines and areasTLspIconStyle
: can be applied to points, lines and areasTLsp3DIconStyle
: can be applied to points, lines and areasTLspVerticalLineStyle
: can be applied to points, lines and areas
aBodyStyler
will be decorated to ensure that it receives the geometry associated with the tiles loaded for level and bounds associated with the view. Consult the class javadoc for more information.Warning: calling this method will replace the default body styling. The default label styling will remain intact. If you only want to alter the default styling for non-SLD / non-VPF coverages, you should use the
fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
method instead.Consult the class javadoc for more information about customizing the style of the resulting layer.
Note: use either
bodyStyler()
orbodyStyles()
for the sameTLspPaintState
, not both.- Parameters:
aPaintState
- the paint state for which to set the body styleraBodyStyler
- the new body styler for the layer- Returns:
this
-
bodyStyles
public TLspFusionVectorLayerBuilder bodyStyles(TLspPaintState aPaintState, ALspStyle... aBodyStyles) Deprecated.Sets the given body styles for the given paint state.
The following styles are supported:
TLspFillStyle
: can be applied to areasTLspLineStyle
: can be applied to lines and areasTLspComplexStrokedLineStyle
: can be applied to lines and areasTLspWorldSizedLineStyle
: can be applied to lines and areasTLspIconStyle
: can be applied to points, lines and areasTLsp3DIconStyle
: can be applied to points, lines and areasTLspVerticalLineStyle
: can be applied to points, lines and areas
The
aBodyStyles
will be applied on the geometry associated associated with the tiles loaded for level and bounds associated with the view. Consult the class javadoc for more information.Warning: calling this method will replace the default body styling. The default label styling will remain intact. If you only want to alter the default styling for non-SLD / non-VPF coverages, you should use the
fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
method instead.Consult the class javadoc for more information about customizing the style of the resulting layer.
Note: use either
bodyStyler()
orbodyStyles()
for the sameTLspPaintState
, not both.- Parameters:
aPaintState
- the paint state for which to set the body styleraBodyStyles
- the new body styles for the layer- Returns:
this
-
fallbackBodyStyler
public TLspFusionVectorLayerBuilder fallbackBodyStyler(TLspPaintState aPaintState, ILspStyler aFallbackBodyStyler) Deprecated.Sets the body styler which is used as fallback when the coverage does not contain SLD information nor VPF data.
The difference between this method and the
bodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
andbodyStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
method is that those methods replace the default styling completely. When you call any of those methods, that specific styler is used in all cases. The styler set in this method is only used when no SLD information is available on the coverage, and the coverage does not contain VPF data.Consult the class javadoc for more information about customizing the style of the resulting layer.
- Parameters:
aPaintState
- the paint state for which to useaFallbackBodyStyler
aFallbackBodyStyler
- the new fallback body styler- Returns:
this
-
labelStyler
public TLspFusionVectorLayerBuilder labelStyler(TLspPaintState aPaintState, ILspStyler aLabelStyler) Deprecated.Sets the given label styler for the given paint state.
If you need control over other labeling aspects such as positioning or priorities, you can use a
ALspLabelStyler
.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 istoString()
). See alsoTLspDataObjectLabelTextProviderStyle
. -
TLspLabelBoxStyle
to specify fill color or frames -
TLspLabelOpacityStyle
to specify the opacity and modulation color. -
TLspPinLineStyle
to draw pins for the labels.
aLabelStyler
will be decorated to ensure that it receives the geometry associated with the tiles loaded for level and bounds associated with the view. Consult the class javadoc for more information.Warning: calling this method will replace the default label styling. The default body styling will remain intact. If you only want to alter the default styling for non-SLD / non-VPF coverages, you should use the
fallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
method instead.Consult the class javadoc for more information about customizing the style of the resulting layer.
Note: Use either
labelStyler()
orlabelStyles()
for the sameTLspPaintState
, not both.- Parameters:
aPaintState
- the paint state for which to set the label styleraLabelStyler
- the new label styler for the layer- Returns:
this
-
-
labelStyles
public TLspFusionVectorLayerBuilder labelStyles(TLspPaintState aPaintState, ALspStyle... aLabelStyles) Deprecated.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 istoString()
). See alsoTLspDataObjectLabelTextProviderStyle
. -
TLspLabelBoxStyle
to specify fill color or frames -
TLspLabelOpacityStyle
to specify the opacity and modulation color. -
TLspPinLineStyle
to draw pins for the labels.
The
aLabelStyles
will be applied on the geometry associated associated with the tiles loaded for level and bounds associated with the view. Consult the class javadoc for more information.Warning: calling this method will replace the default label styling. The default body styling will remain intact. If you only want to alter the default styling for non-SLD / non-VPF coverages, you should use the
fallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
method instead.Consult the class javadoc for more information about customizing the style of the resulting layer.
Note: Use either
labelStyler()
orlabelStyles()
for the sameTLspPaintState
, not both.- Parameters:
aPaintState
- the paint state for which to set the label stylesaLabelStyles
- the new label styles for the layer- Returns:
this
-
-
fallbackLabelStyler
public TLspFusionVectorLayerBuilder fallbackLabelStyler(TLspPaintState aPaintState, ILspStyler aFallbackLabelStyler) Deprecated.Sets the label styler which is used as fallback when the coverage does not contains SLD information nor VPF data.
The difference between this method and the
labelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
andlabelStyles(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.ALspStyle...)
method is that those methods replace the default styling completely. When you call any of those methods, that specific styler is used in all cases. The styler set in this method is only used when no SLD information is available on the coverage, and the coverage does not contain VPF data.Consult the class javadoc for more information about customizing the style of the resulting layer.
- Parameters:
aPaintState
- the paint state for which to useaFallbackLabelStyler
aFallbackLabelStyler
- the new fallback label styler- Returns:
this
-
bodyPainter
Deprecated.Customizing the body painter should be done by using thebodyStyler(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...)
method.Allows setting a custom body painter on the layer.
Warning: in almost any case, it is better to configure the default painter using the
bodyStyler()
orbodyStyles()
methods instead.Calling this method will also replace the default styling.
- Parameters:
aPainter
- the body painter for the layer- Returns:
this
-
labelPainter
Deprecated.Customizing the label painter should be done by using thelabelStyler(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...)
method.Allows setting a custom label painter on the layer.
Warning: In almost any case, it is better to configure the default label painter using the
labelStyler()
orlabelStyles()
methods instead.Calling this method will also replace the default styling.
- Parameters:
aPainter
- the label painter for the layer- Returns:
this
- See Also:
-
bodyScaleRange
Deprecated.Sets the scale range for the body of the layer. By default, no scale range is used.- Parameters:
aBodyScaleRange
- the scale range for the body of the layer- Returns:
this
-
labelScaleRange
Deprecated.Sets the scale range for the labels of the layer- Parameters:
aLabelScaleRange
- the scale range for the labels of the layer- Returns:
this
-
filter
Deprecated.Sets a filter that will be used to filter objects to prevent them from being painted by the layer.
When the vector coverage does not use SLD for the styling, the filter will be composited with a default filter which is based on the info in
TLfnVectorCoverageMetadata.getFilters()
. This will ensure that the visualization matches the filters which were used during the fusion of the data exactly.- Parameters:
aFilter
- the filter- Returns:
this
-
minimumObjectSizeForPainting
public TLspFusionVectorLayerBuilder minimumObjectSizeForPainting(double aMinimumObjectSizeForPainting) Deprecated.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.- Parameters:
aMinimumObjectSizeForPainting
- The minimal size, expressed in pixels.- Returns:
this
-
objectViewMargin
Deprecated.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. 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 is0
.- Parameters:
aObjectViewMargin
- the maximum difference (in pixels)- Returns:
this
-
objectWorldMargin
Deprecated.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. 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
-
paintingHints
Deprecated.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() is not called). The default value isTLspShapePaintingHints.newBuilder().build()
. The hints must not benull
.- Parameters:
aPaintingHints
- the painting hints to be used- Returns:
this
-
model
Deprecated.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
Deprecated.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
Deprecated.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
Deprecated.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:
-