public final class TLspFusionVectorLayerBuilder extends ALspLayerBuilder
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.
The layer created by this builder is by default configured with stylers for the body and the labels. These default stylers will ensure that:
ALfnCoverageMetadata.getFeatureTypeStyles()
).
fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
and
fallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler)
.
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.
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.
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.
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
}
}
}
Modifier and Type | Method and Description |
---|---|
TLspFusionVectorLayerBuilder |
bodyPainter(ILspPainter aPainter)
Deprecated.
Customizing the body painter should be done by using the
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...) method. |
TLspFusionVectorLayerBuilder |
bodyScaleRange(ILcdInterval aBodyScaleRange)
Deprecated.
Sets the scale range for the body of the layer.
|
TLspFusionVectorLayerBuilder |
bodyStyler(TLspPaintState aPaintState,
ILspStyler aBodyStyler)
Deprecated.
Sets the given body styler for the given paint state.
|
TLspFusionVectorLayerBuilder |
bodyStyles(TLspPaintState aPaintState,
ALspStyle... aBodyStyles)
Deprecated.
Sets the given body styles for the given paint state.
|
ILspInteractivePaintableLayer |
build()
Deprecated.
Creates a new layer instance.
|
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.
|
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.
|
TLspFusionVectorLayerBuilder |
filter(ILcdDynamicFilter aFilter)
Deprecated.
Sets a filter that will be used to filter objects to prevent them from being painted by the layer.
|
TLspFusionVectorLayerBuilder |
icon(ILcdIcon aIcon)
Deprecated.
Sets the icon of the layer.
|
TLspFusionVectorLayerBuilder |
label(String aLabel)
Deprecated.
Sets the label of the layer.
|
TLspFusionVectorLayerBuilder |
labelPainter(ILspPainter aPainter)
Deprecated.
Customizing the label painter should be done by using the
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...) method. |
TLspFusionVectorLayerBuilder |
labelScaleRange(ILcdInterval aLabelScaleRange)
Deprecated.
Sets the scale range for the labels of the layer
|
TLspFusionVectorLayerBuilder |
labelStyler(TLspPaintState aPaintState,
ILspStyler aLabelStyler)
Deprecated.
Sets the given label styler for the given paint state.
|
TLspFusionVectorLayerBuilder |
labelStyles(TLspPaintState aPaintState,
ALspStyle... aLabelStyles)
Deprecated.
Sets the given label styles for the given paint state.
|
TLspFusionVectorLayerBuilder |
layerType(ILspLayer.LayerType aLayerType)
Deprecated.
Sets the layer type of the layer.
|
TLspFusionVectorLayerBuilder |
minimumObjectSizeForPainting(double aMinimumObjectSizeForPainting)
Deprecated.
Sets the minimum size of an object in the view for it to be painted and handled otherwise.
|
TLspFusionVectorLayerBuilder |
model(ILcdModel aModel)
Deprecated.
Sets the model of the layer.
|
static TLspFusionVectorLayerBuilder |
newBuilder()
Deprecated.
Returns a new layer builder with the default settings.
|
TLspFusionVectorLayerBuilder |
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.
|
TLspFusionVectorLayerBuilder |
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.
|
TLspFusionVectorLayerBuilder |
paintingHints(TLspShapePaintingHints aPaintingHints)
Deprecated.
Sets the painting hints to be used by created layers.
|
TLspFusionVectorLayerBuilder |
selectable(boolean aSelectable)
Deprecated.
Sets whether the layer should be selectable.
|
getIcon, getLabel, getLayerStyle, getLayerType, getModel, layerStyle
public static TLspFusionVectorLayerBuilder newBuilder()
public ILspInteractivePaintableLayer build()
ALspLayerBuilder
Creates a new layer instance.
build
in class ALspLayerBuilder
public TLspFusionVectorLayerBuilder selectable(boolean aSelectable)
aSelectable
- whether the layer should be selectablethis
public TLspFusionVectorLayerBuilder 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 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()
or bodyStyles()
for the same TLspPaintState
, not both.
aPaintState
- the paint state for which to set the body styleraBodyStyler
- the new body styler for the layerthis
public TLspFusionVectorLayerBuilder bodyStyles(TLspPaintState aPaintState, ALspStyle... aBodyStyles)
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()
or bodyStyles()
for the same TLspPaintState
, not both.
aPaintState
- the paint state for which to set the body styleraBodyStyles
- the new body styles for the layerthis
public TLspFusionVectorLayerBuilder fallbackBodyStyler(TLspPaintState aPaintState, ILspStyler aFallbackBodyStyler)
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)
and bodyStyles(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.
aPaintState
- the paint state for which to use aFallbackBodyStyler
aFallbackBodyStyler
- the new fallback body stylerthis
public TLspFusionVectorLayerBuilder labelStyler(TLspPaintState aPaintState, ILspStyler aLabelStyler)
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 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.
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()
or labelStyles()
for the same TLspPaintState
, not both.
aPaintState
- the paint state for which to set the label styleraLabelStyler
- the new label styler for the layerthis
public TLspFusionVectorLayerBuilder labelStyles(TLspPaintState aPaintState, ALspStyle... aLabelStyles)
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.
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()
or labelStyles()
for the same TLspPaintState
, not both.
aPaintState
- the paint state for which to set the label stylesaLabelStyles
- the new label styles for the layerthis
public TLspFusionVectorLayerBuilder fallbackLabelStyler(TLspPaintState aPaintState, ILspStyler aFallbackLabelStyler)
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)
and labelStyles(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.
aPaintState
- the paint state for which to use aFallbackLabelStyler
aFallbackLabelStyler
- the new fallback label stylerthis
public TLspFusionVectorLayerBuilder bodyPainter(ILspPainter aPainter)
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...)
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()
or
bodyStyles()
methods instead.
Calling this method will also replace the default styling.
aPainter
- the body painter for the layerthis
public TLspFusionVectorLayerBuilder labelPainter(ILspPainter aPainter)
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...)
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()
or
labelStyles()
methods instead.
Calling this method will also replace the default styling.
aPainter
- the label painter for the layerthis
TLspLabelPainter
public TLspFusionVectorLayerBuilder bodyScaleRange(ILcdInterval aBodyScaleRange)
aBodyScaleRange
- the scale range for the body of the layerthis
public TLspFusionVectorLayerBuilder labelScaleRange(ILcdInterval aLabelScaleRange)
aLabelScaleRange
- the scale range for the labels of the layerthis
public TLspFusionVectorLayerBuilder filter(ILcdDynamicFilter aFilter)
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.
aFilter
- the filterthis
public TLspFusionVectorLayerBuilder 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.aMinimumObjectSizeForPainting
- The minimal size, expressed in pixels.this
public TLspFusionVectorLayerBuilder objectViewMargin(double aObjectViewMargin)
maximum distance in meters
.
The default value is 0
.aObjectViewMargin
- the maximum difference (in pixels)this
public TLspFusionVectorLayerBuilder objectWorldMargin(double aObjectWorldMargin)
maximum distance in pixels
.
The default value is 0
.aObjectWorldMargin
- the maximum difference in metersthis
public TLspFusionVectorLayerBuilder paintingHints(TLspShapePaintingHints aPaintingHints)
TLspShapePaintingHints.newBuilder().build()
. The hints must not be null
.aPaintingHints
- the painting hints to be usedthis
public TLspFusionVectorLayerBuilder model(ILcdModel aModel)
ALspLayerBuilder
null
.model
in class ALspLayerBuilder
aModel
- a modelILcdLayer.getModel()
public TLspFusionVectorLayerBuilder label(String aLabel)
ALspLayerBuilder
null
.label
in class ALspLayerBuilder
aLabel
- the labelILcdLayer.getLabel()
public TLspFusionVectorLayerBuilder layerType(ILspLayer.LayerType aLayerType)
ALspLayerBuilder
ILspLayer.LayerType.EDITABLE
.layerType
in class ALspLayerBuilder
aLayerType
- the layer typeILspLayer.getLayerType()
public TLspFusionVectorLayerBuilder icon(ILcdIcon aIcon)
ALspLayerBuilder
null
.icon
in class ALspLayerBuilder
aIcon
- the iconILcdLayer.getIcon()