NASA Worldwind:如何更改战术符号的速度领导者的颜色?

sti*_*tix 10 java worldwind

在NASA WorldWind中,可以为Milstd-2525符号指定"行进方向"速度引导者.然而,这个速度领先者是黑色的,因此很难看到深蓝色的海洋背景.我已经尝试在TacticalSymbolAttributes中更改内部颜色材质,但这似乎没有效果(对任何东西).遗憾的是,文档没有提供有关如何更改线条颜色的任何线索.

是否有可能在Worldwind中改变Milstd-2525 Tactical Symbol的速度领导线的颜色,如果是这样,怎么样?

had*_*uri 5

在github上的WorldWindJava源代码的基础,类MilStd2525TacticalSymbol重写方法命名layoutDynamicModifiers.在此方法中,您可以看到DIRECTION_OF_MOVEMENT最终addLine(...)只调用(此方法在超类AbstractTacticalSymbol中实现,只在命名列表中添加一行currentLines)并且只能SPEED_LEADER_SCALE设置,并且无法在外部更改移动方向的其他属性.

@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);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在超类中AbstractTacticalSymbol,字段currentLines(包含移动方向的行)用于名为的方法中,该方法drawLines(...)将添加的行绘制到所提到的列表中(类的第2366行).在第2364行中,您可以看到颜色设置为黑色.

gl.glColor4f(0f, 0f, 0f, opacity.floatValue()); 
Run Code Online (Sandbox Code Playgroud)

现在我建议你扩展MilStd2525TacticalSymbol并做以下事情:

  1. 扩展类AbstractTacticalSymbol.Line并定义一些字段来存储颜色.
  2. 覆盖方法layoutDynamicModifiers并获取您自己的密钥(例如DIRECTION_OF_MOVEMENT_COLOR)以从修饰符获取颜色并使用此给定颜色创建您自己的行并将其添加到currentLines列表(您可以addLine为此目的覆盖方法).
  3. 最后覆盖drawLines以在您自己的Line类中使用商店颜色并更改gl绘制线之前的颜色(您可以在绘制运动方向后将颜色更改为黑色).