public class TLspRadarVideoLayerBuilder extends ALspLayerBuilder
TLspRadarVideoStyle
.
Additionally, the layers created by this builder support the same styling
constructs as TLspShapeLayerBuilder
.
This allows the user to add decorations (e.g. grid lines) and labels to the
radar feed.
The default styler shows the radar video data, a sweep line and a polar grid.
This styler is a ILspCustomizableStyler
, which means you can adjust the style of these elements after you
have created this layer.
The identifiers of this ILspCustomizableStyler
are:
TLspRadarVideoStyle
for the radar content.TLspLineStyle
of the sweep line.TLspLineStyle
of the range rings.TLspLineStyle
of the polar grid lines.You can use these identifiers if you want to change the style of one of these elements. For instance, changing the color of the sweep line:
private ILspLayer createRadarLayer(ILcdModel aModel) {
ILspEditableStyledLayer radarLayer = TLspRadarVideoLayerBuilder.newBuilder()
.model(aRadarModel)
.selectable(false)
.label(aSimulatedRadarProperties.getName())
.build();
ILspCustomizableStyler styler = (ILspCustomizableStyler) radarLayer.getStyler(TLspPaintRepresentationState.REGULAR_BODY);
for (TLspCustomizableStyle style : styler.getStyles()) {
if (style.getIdentifier().equals(TLspRadarVideoLayerBuilder.SWEEP_LINE_STYLE_IDENTIFIER) {
TLspLineStyle originalStyle = (TLspLineStyle) style.getStyle();
style.setStyle(originalStyle.asBuilder().color(Color.BLUE).build());
}
}
}
For deeper customization, you can replace the styler with your own implementation. For example if you want to change the number of range rings:
public class RadarStyler extends ALspStyler {
private static int RING_COUNT = 3;
private static final ALspStyleTargetProvider sRangeRingStyleTargetProvider = new ALspStyleTargetProvider() {
public void getStyleTargetsSFCT(Object aObject, TLspContext aContext, List<Object> aResultSFCT) {
double range = (Double) ((ILcdDataObject) aObject).getValue(TLcdRadarVideoDataTypes.RADAR_RANGE_PROPERTY);
//Range circles
for (int i = 1; i <= RING_COUNT; i++) {
TLcdXYCircle c = new TLcdXYCircle(0, 0, i * range / RING_COUNT);
aResultSFCT.add(c);
}
}
};
private ALspStyle fRadarStyle = TLspRadarVideoStyle.newBuilder().build();
private ALspStyle fRingStyle = TLspLineStyle.newBuilder().build();
public void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext) {
aStyleCollector
.objects(aObjects)
.styles(fRadarStyle)
.submit();
aStyleCollector
.objects(aObjects)
.geometry(sRangeRingStyleTargetProvider)
.styles(fRingStyle)
.submit();
}
}
ILspLayer radarLayer = TLspRadarVideoLayerBuilder
.newBuilder()
.model(radarModel)
.bodyStyler(TLspPaintState.REGULAR, new RadarStyler())
.build();
Finally, this layer builder only accepts models whose modelDescriptor is an ILcdDataModelDescriptor
whose
element types contain a TLcdDataType
that
extends from TLcdRadarVideoDataTypes.RADAR_VIDEO_DATA_TYPE
TLcdRadar
Modifier and Type | Field and Description |
---|---|
static String |
GRID_LINE_STYLE_IDENTIFIER
Identifier for the
TLspCustomizableStyle for the polar grid lines. |
static String |
RADAR_VIDEO_STYLE_IDENTIFIER
Identifier for the
TLspCustomizableStyle for the radar video. |
static String |
RANGE_RING_STYLE_IDENTIFIER
Identifier for the
TLspCustomizableStyle for the range rings. |
static String |
SWEEP_LINE_STYLE_IDENTIFIER
Identifier for the
TLspCustomizableStyle for the sweep line. |
Modifier and Type | Method and Description |
---|---|
TLspRadarVideoLayerBuilder |
bodyStyler(TLspPaintState aPaintState,
ILspStyler aBodyStyler)
Sets the body styler for the given paint state.
|
ILspEditableStyledLayer |
build()
Creates a new radar layer using the current settings of this builder.
|
TLspRadarVideoLayerBuilder |
icon(ILcdIcon aIcon)
Sets the icon of the layer.
|
TLspRadarVideoLayerBuilder |
label(String aLabel)
Sets the label of the layer.
|
TLspRadarVideoLayerBuilder |
labelStyler(TLspPaintState aPaintState,
ILspStyler aLabelStyler)
Sets the label styler for the given paint state.
|
TLspRadarVideoLayerBuilder |
layerStyle(TLspLayerStyle aLayerStyle)
Set a layer style to be used during the rendering of the layer.
|
TLspRadarVideoLayerBuilder |
layerType(ILspLayer.LayerType aLayerType)
This method throws an
UnsupportedOperationException . |
TLspRadarVideoLayerBuilder |
model(ILcdModel aModel)
Sets the model of the layer.
|
static TLspRadarVideoLayerBuilder |
newBuilder()
Creates a new radar layer builder.
|
TLspRadarVideoLayerBuilder |
selectable(boolean aSelectable)
Specifies whether layers should be made selectable.
|
TLspRadarVideoLayerBuilder |
selectableSupported(boolean aSelectableSupported)
Sets whether the layer should support selection.
|
TLspRadarVideoLayerBuilder |
synchronous(boolean aIsSynchronous)
Specifies whether created layers should paint synchronously.
|
getIcon, getLabel, getLayerStyle, getLayerType, getModel
public static final String RADAR_VIDEO_STYLE_IDENTIFIER
TLspCustomizableStyle
for the radar video. The style contained
in that TLspCustomizableStyle
is a TLspRadarVideoStyle
.public static final String GRID_LINE_STYLE_IDENTIFIER
TLspCustomizableStyle
for the polar grid lines. The style contained
in that TLspCustomizableStyle
is a TLspLineStyle
.public static final String RANGE_RING_STYLE_IDENTIFIER
TLspCustomizableStyle
for the range rings. The style contained
in that TLspCustomizableStyle
is a TLspLineStyle
.public static final String SWEEP_LINE_STYLE_IDENTIFIER
TLspCustomizableStyle
for the sweep line. The style contained
in that TLspCustomizableStyle
is a TLspLineStyle
.public static TLspRadarVideoLayerBuilder newBuilder()
public ILspEditableStyledLayer build()
build
in class ALspLayerBuilder
public TLspRadarVideoLayerBuilder bodyStyler(TLspPaintState aPaintState, ILspStyler aBodyStyler)
TLspRadarVideoStyle
s to customize
the appearance of the radar feed. Furthermore, the styler may output
additional geometries (using a
style target provider
).e
For these additional geometries, all styles supported by
TLspShapeLayerBuilder
are also supported. This allows the styler to add decorations such as grid
lines on top of the radar feed.aPaintState
- the paint state for which to set the body styleraBodyStyler
- the new body styler for the layerthis
public TLspRadarVideoLayerBuilder labelStyler(TLspPaintState aPaintState, ILspStyler aLabelStyler)
TLspShapeLayerBuilder
for information on the supported styles.aPaintState
- the paint state for which to set the label styleraLabelStyler
- the new label styler for the layerthis
public TLspRadarVideoLayerBuilder selectable(boolean aSelectable)
true
by default.aSelectable
- whether or not created layers should be selectablethis
public TLspRadarVideoLayerBuilder selectableSupported(boolean aSelectableSupported)
aSelectableSupported
- whether the layer should support selectionthis
public TLspRadarVideoLayerBuilder synchronous(boolean aIsSynchronous)
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.
aIsSynchronous
- true if the layer should paint synchronouslythis
public TLspRadarVideoLayerBuilder model(ILcdModel aModel)
ALspLayerBuilder
null
.model
in class ALspLayerBuilder
aModel
- a modelILcdLayer.getModel()
public TLspRadarVideoLayerBuilder label(String aLabel)
ALspLayerBuilder
null
.label
in class ALspLayerBuilder
aLabel
- the labelILcdLayer.getLabel()
public TLspRadarVideoLayerBuilder icon(ILcdIcon aIcon)
ALspLayerBuilder
null
.icon
in class ALspLayerBuilder
aIcon
- the iconILcdLayer.getIcon()
public TLspRadarVideoLayerBuilder 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)
public TLspRadarVideoLayerBuilder layerType(ILspLayer.LayerType aLayerType)
UnsupportedOperationException
. The layer
type of radar layers is always
ILspLayer.LayerType.REALTIME
.layerType
in class ALspLayerBuilder
aLayerType
- the layer typethis
ILspLayer.getLayerType()