The basic constructor for MilitarySymbologyPainter. This constructor allows you to define a few functions to retrieve specific properties (such as modifiers and styling) for a given feature. An example of how this works is given in the class documentation. Each function defined in the "options" parameter of this constructor will receive the feature as a parameter, and will expect to get some object literal as output (in the return value). This allows you to either use the feature itself for feature-specific properties, or to refer to a global variable to retrieve certain properties.
The example in the class documentation uses a global style object literal for all feature, but uses feature-specific modifiers.
A symbology object or a ReadOnlyFeaturePropertyAccessor which can be used to retrieve the symbology object based on the painted feature.
A set of optional parameters and functions to help you customize the visualization of military icons and symbols.
Set or get the density painting settings on this painter. Use null to disable density painting.
The setting affects all features in the layer associated with this painter.
The density settings object has one property: colorMap, the color map
used to map density values to color.
The density at a particular location is the sum of the value of alpha channel for all overlapping objects. So for a single opaque object you would get a density value of 1.0, for 2 opaque objects 2.0, etc.
Example:
var painter = new FeaturePainter();
painter.paintBody = ... // customize painter as usual
painter.density = {
colorMap: ColorMap.createGradientColorMap([
{level: 0, color: "rgba( 0, 0, 0, 0.0)"}, // no objects -> Transparent
{level: 1, color: "rgba( 0, 255, 0, 0.5)"}, // 1 opaque object -> Transparent green
{level: 10, color: "rgba(255, 255, 255, 1.0)"} //10 opaque objects -> White
])
};
Notes when using density painting:
A method that generates an image for the given feature with the given size. The feature needs a symbology and code property const properties = { code: symbologyNode.code, symbology: symbology, } The feature also needs a valid (template) shape. (Use SymbologyNode.createTemplates)
You will get an image as HTMLImageElement.
This can be used to generate a UI preview image for your symbols as is done in our Symbology sample in the CreationPanel to clarify the creation instructions.
feature containing a shape and symbol properties
width and height of the preview
A utility method to get the actual symbol bounds, that can then be used for fitting on that symbol.
The feature needs a symbology and code property
const properties = { code: symbologyNode.code, symbology: symbology, }
The feature also needs a valid (template) shape. (Use SymbologyNode.createTemplates)
The visualization of a military symbol might differ significantly of the polyline that contains the symbol's anchor points. In the most extreme case, two anchor points are used to draw a full circle. The bounds of the shape inside the feature will be the bounds of the two points, this method will return the bounds of the circle. Please note that only the actual shapes are taken into account to calculate the bounds, specific styling, labels and icons are not taken into account. Therefor it is probably a good idea to fit with a MapNavigatorFitOptions.fitMargin
the feature representing a military symbol
Returns an array of map scales that define when to switch between levels of detail.
This method allows the painter to support multiple visual representations (levels-of-detail, or LOD)
for the same feature depending on the map's current scale. The map determines the active level
and passes it to the painter via the paintState.level property during rendering.
If the level changes due to map navigation (such as zooming, panning, or fitting), the map will call the paintBody and paintLabel methods with the corresponding level.
By default, this method returns null, indicating that level-of-detail is not used.
Override this method to enable scale-based LOD behavior.
Optionallayer: FeatureLayerThe feature layer for which level-of-detail scales are requested.
Optionalmap: RIAMapThe map instance for which the scales apply.
An array of scales at which to switch to the next detail level, or null if LOD is not used.
// The example below illustrates how switching scales map to paint levels.
// It uses 3 switching points, resulting in 4 distinct paint levels:
//
// Scale: 1 : 100 000 1 : 10 000 1 : 1000
// (zoomed out) --- | ------------- | ------------- | --- (zoomed in)
// level 0 | level 1 | level 2 | level 3
painter.getDetailLevelScales = (): number[] => {
return [ 1 / 100_000, 1 / 10_000, 1 / 1_000 ];
}
This method returns the IconStyle of the military icon representing the feature provided.
If the feature is not represented by an icon or if the icon is not yet resolved, null is returned.
Note that icon generation is an asynchronous process. If the actual icon does not yet exist on the map,
you will get null. As soon as the actual icon appears on the map,
it automatically invalidates the painter to trigger a repaint. At that point, when you re-try to get
the IconStyle, the correct style will be returned.
Using the offsets defined in the IconStyle allows you to customize icon decorations in a wrapper painter. Common icon decorations are:
the IconStyle of the military icon representing the feature provided or
null if the feature does not represent an icon or if the icon is not yet resolved.
Invalidates this painter for a specific feature. Call this method when any state that affects the rendering of the given feature has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for the specified feature during the next map render.
Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.
the model feature whose representation has changed
Invalidates this painter for all features. Call this method when any state that affects the rendering of features has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for all features in the layer during the next map render.
Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.
Note that this is called automatically whenever RIAMap.displayScale changes.
Invalidates this painter for a specific feature identified by its id. Call this method when any state that affects the rendering of the given feature has changed. This method refreshes the associated layer and ensures that FeaturePainter.paintBody and FeaturePainter.paintLabel will be called for the specified feature during the next map render.
Note: If the layer is currently invisible, the invalidation is deferred and will be applied when the layer becomes visible again.
The id of the feature. It corresponds to Feature.id.
A method that paints military icons and tactical graphics on a map.
Override this method to add custom decorations on top of the military icons and tactical graphics. (Example: Painting flags next to icons, based on the country)
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
A method that paints labels for military icons.
Override this method to customize labeling, or to add additional labels to existing military symbols (Example: Put the name of the country as a text label near the military icon)
You can modify the style of the labels by changing the CSS style of the label. This class is called
.luciad .lcdSymbologyLabel
See samples/symbology/common/ui/milsym-common-styles.css for an example usage of this selector.
.luciad .lcdSymbologyLabel {
font-family: Arial, monospace;
font-weight: normal;
color: white;
font-size: 10px;
text-shadow: 0 0 5px #000000;
}
You can also modify the style of the "glow" applied to the label when a bloomStyle is applied to the symbol.
The class to do so is called lcdSymbologyLabelGlow
text-shadow: 0 0 2px #000, 0 0 4px #fff,
0 0 5px #efefef, 0 0 6px #efefef,
0 0 7px #bbbbbb, 0 0 8px #bbbbbb, 0 0 9px #bbbbbb;
the render target
the feature that is being rendered
the shape to render
the layer containing the given feature
the map containing the layer
an object describing the current paint state
Registers a callback function for the "InvalidateAll" event, that notifies a listener that the all features are invalidated.
Always set to "InvalidateAll" for this event type.
The callback function to be executed when the event is emitted
Optionalcontext: anyThe context in which the function should be invoked.
"InvalidateAll"
FeaturePainter.on "InvalidateAll"
FeaturePainter.on "InvalidateById"
Registers a callback function for the "SymbologyServiceOnline" event, that notifies a listener that the symbology service is online.
Always set to "SymbologyServiceOnline" for this event type.
The callback function to be executed when the event is emitted
Optionalcontext: anyThe context in which the function should be invoked.
"SymbologyServiceOnline"
Registers a callback function for the "SymbologyServiceOffline" event, that notifies a listener that the symbology service is offline.
Always set to "SymbologyServiceOffline" for this event type.
The callback function to be executed when the event is emitted
Optionalcontext: anyThe context in which the function should be invoked.
"SymbologyServiceOffline"
A painter for military icons and tactical graphics. This painter extends the FeaturePainter with functionality to visualize icons and symbols found in the MIL-STD 2525b, MIL-STD 2525c, , MIL-STD 2525d, APP-6A, APP-6B, APP-6C and APP-6D military standards.
Everything for this painter is configured at construction time, using functions that retrieve object literals for a given feature. This allows for flexibility for both feature-based properties, as well as global properties (that apply to all features).
Here's an overview of the keys for a few of the properties.
The following affiliation values can be colored with the affiliationColors map. Note that these values are not camel-case. This is because they are typically used as display values as well.
Movement direction arrows
This painter also paints movement direction arrows for moving symbols. Ground units will have an arrow starting from a vertical stem, except in 3D.
The following modifiers affect the arrows:
The length of the arrow is determined by the existing style property "iconSize" in combination with the "speedLabel" modifier if available. The line-width of the arrow is determined by the existing style properties "lineWidth".
Example how to create a military feature and a painter