NASA Worldwind: How can I change the color of the speed leader for tactical symbols?
Asked Answered
C

2

10

In NASA WorldWind, one can assign a "direction of travel" speed leader to the Milstd-2525 symbols. However, this speed leader is black, making it very difficult to see against the dark blue ocean background. I have tried changing the internal color material in the TacticalSymbolAttributes, but this doesn't seem to have an effect (on anything). The documentation unfortunately doesn't provide any clues on how to change the line's color.

Is it possible to change the color of the Milstd-2525 Tactical Symbol's speed leader line in Worldwind, and if so, how?

Chervil answered 17/4, 2017 at 15:31 Comment(2)
Which version of WorldWind are you using? i.e. 1.X, 2.0, 2.0-986, 2.1Metallography
2.1.0. I've basically been keeping up with the master git branch.Chervil
E
5

Base of source codes of WorldWindJava on github, class MilStd2525TacticalSymbol overrides method named layoutDynamicModifiers. In this method you can see that for DIRECTION_OF_MOVEMENT only eventually addLine(...) is called (This method is implemented in the superclass AbstractTacticalSymbol which only adds a line to a list named currentLines) and only SPEED_LEADER_SCALE could be set and other properties for the direction of movement could not be changed externally.

@Override
protected void layoutDynamicModifiers(DrawContext dc, AVList modifiers, OrderedSymbol osym)
{
    this.currentLines.clear();

    if (!this.isShowGraphicModifiers())
        return;

    // Direction of Movement indicator. Placed either at the center of the icon or at the bottom of the symbol
    // layout.
    Object o = this.getModifier(SymbologyConstants.DIRECTION_OF_MOVEMENT);
    if (o != null && o instanceof Angle)
    {
        // The length of the direction of movement line is equal to the height of the symbol frame. See
        // MIL-STD-2525C section 5.3.4.1.c, page 33.
        double length = this.iconRect.getHeight();
        Object d = this.getModifier(SymbologyConstants.SPEED_LEADER_SCALE);
        if (d != null && d instanceof Number)
            length *= ((Number) d).doubleValue();

        if (this.useGroundHeadingIndicator)
        {
            List<? extends Point2D> points = MilStd2525Util.computeGroundHeadingIndicatorPoints(dc, osym.placePoint,
                (Angle) o, length, this.iconRect.getHeight());
            this.addLine(dc, Offset.BOTTOM_CENTER, points, LAYOUT_RELATIVE, points.size() - 1, osym);
        }
        else
        {
            List<? extends Point2D> points = MilStd2525Util.computeCenterHeadingIndicatorPoints(dc,
                osym.placePoint, (Angle) o, length);
            this.addLine(dc, Offset.CENTER, points, null, 0, osym);
        }
    }
}

In the superclass AbstractTacticalSymbol, field currentLines (which contains the line for the direction of movement) is used in a method named drawLines(...) which draws added lines to the mentioned list (line 2366 of class). In line 2364 you can see that color is set to black.

gl.glColor4f(0f, 0f, 0f, opacity.floatValue()); 

Now I suggest you extend MilStd2525TacticalSymbol and do following:

  1. extend class AbstractTacticalSymbol.Line and define some fields to store color.
  2. override method layoutDynamicModifiers and get your own key (for example DIRECTION_OF_MOVEMENT_COLOR) to get color from modifiers and use this given color to create your own line and add this to currentLines list (you can override method addLine for this purpose).
  3. finally override drawLines to use store color in your own Line class and change the color of gl before draw line (you can change back color to black after the direction of movement is drawn).
Excommunicative answered 16/6, 2017 at 21:46 Comment(0)
T
1

I'm running off an earlier Worldwind but try Taking a look at AbstractTacticalSymbol.java -> drawLines() method.

It's defaulting the glColor to black before drawing the lines.

Toxin answered 13/6, 2017 at 19:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.