在 NASA WorldWind 中,可以为 Milstd-2525 符号指定一个“行进方向”速度领导者。然而,这个领航者是黑色的,在深蓝色的海洋背景下很难看清。我曾尝试更改 TacticalSymbolAttributes 中的内部颜色 Material ,但这似乎没有任何效果(对任何东西)。不幸的是,该文档没有提供有关如何更改线条颜色的任何线索。
是否可以在 Worldwind 中更改 Milstd-2525 战术符号的速度引导线的颜色,如果可以,如何更改?
最佳答案
source codes of WorldWindJava on github的基数| , 类 MilStd2525TacticalSymbol
覆盖名为 layoutDynamicModifiers
的方法。在这个方法中你可以看到对于 DIRECTION_OF_MOVEMENT
最终只有 addLine(...)
被调用(这个方法是在父类(super class) 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);
}
}
}
在父类(super class)中 AbstractTacticalSymbol
,字段 currentLines
(包含移动方向的线)在名为 drawLines(...)
的方法中使用,该方法将添加的线绘制到提到的列表(线2366 类)。在第 2364 行中,您可以看到颜色设置为黑色。
gl.glColor4f(0f, 0f, 0f, opacity.floatValue());
现在我建议您扩展 MilStd2525TacticalSymbol
并执行以下操作:
- 扩展类
AbstractTacticalSymbol.Line
并定义一些字段来存储颜色。 - 覆盖方法
layoutDynamicModifiers
并获取您自己的键(例如DIRECTION_OF_MOVEMENT_COLOR
)以从修饰符获取颜色并使用此给定颜色创建您自己的线并将其添加到currentLines
列表(您可以为此覆盖方法addLine
)。 - 最后覆盖
drawLines
以在您自己的Line
类中使用存储颜色并在绘制线之前更改gl
的颜色(您可以改回绘制运动方向后颜色变为黑色)。
关于java - NASA Worldwind : How can I change the color of the speed leader for tactical symbols?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43454496/