The default TLspMS2525bSymbolStyler
used by the TLspMS2525bLayerBuilder
class works with ILcdMS2525bCoded
objects.
When your domain objects cannot implement this interface, you can still use this layer builder class to visualize your data
using military symbology.
However, you become responsible for creating the mapping from your domain object to a TLspMS2525bSymbolStyle
instance:
-
Creating a
TLcdDefaultMS2525bStyle
object specifying how the domain object must be styled (colors, line widths, label positions, …​) -
Creating a
TLcdEditableMS2525bObject
for your domain object, specifying what the SIDC (symbol code) is. This for example determines what icon to use. -
Convert this into an
TLspMS2525bSymbolStyle
instance by using the available builder class -
This style object can be used as
ILspStyler
or in anILspStyler
implementation -
Configure the styler on the
TLspMS2525bLayerBuilder
// Configure the styling we want to use
TLcdDefaultMS2525bStyle style = TLcdDefaultMS2525bStyle.getNewInstance();
// Adjust some settings
style.setColor(Color.BLACK);
style.setLabelColor(Color.WHITE);
style.setAffiliationColorEnabled(true);
//Create an TLspMS2525bSymbolStyle
//First create and configure a TLcdEditableMS2525bObject object,
//and convert it to a TLspMS2525bSymbolStyle using the builder
TLcdEditableMS2525bObject coded = new TLcdEditableMS2525bObject("10030100001101000000", ELcdMS2525Standard.MIL_STD_2525d);
coded.putTextModifier(ILcdMS2525bCoded.sMovementDirection, Double.toString(120));
TLspMS2525bSymbolStyle symbolStyle = TLspMS2525bSymbolStyle.newBuilder()
.ms2525bCoded(coded)
.ms2525bStyle(style)
.build();
//Create a layer with a single point domain object
//which will be visualized using the created style
//In this example, all points will be styled the same because we use a fixed style
//Implement an ILspStyler if you need to map each domain object onto a separate TLspMS2525bSymbolStyle
TLcdLonLatPoint point = new TLcdLonLatPoint(0, 0);
TLcdVectorModel model =
new TLcdVectorModel(new TLcdGeodeticReference(),
new TLcdModelDescriptor(null, "Tutorial", "Tutorial"));
model.addElement(point, ILcdModel.NO_EVENT);
ILspLayer layer = TLspMS2525bLayerBuilder.newBuilder()
.model(model)
.bodyStyler(TLspPaintState.REGULAR, symbolStyle)
.build();
In this example, we only replaced the body styler. If you want to have labels for your domain object, you will have to do the same for the label styler. |