2017-04-17 67 views
10

在美国国家航空航天局WorldWind中,可以为Milstd-2525符号分配一个“旅行方向”速度领先者。但是,这个速度领先者是黑色的,因此很难看到深蓝色的海洋背景。我曾尝试更改TacticalSymbolAttributes中的内部颜色材质,但这似乎没有任何效果(在任何情况下)。不幸的是,文档没有提供关于如何改变线条颜色的线索。美国国家航空航天局Worldwind:如何改变战术符号的速度领导者的颜色?

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

+0

您使用的是哪个版本的WorldWind?即1.X,2.0,2.0-986,2.1 – Igor

+0

2.1.0。我基本上已经跟上了主git分支。 – stix

回答

5

基地source codes of WorldWindJava on github,类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); 
     } 
    } 
} 

在超类AbstractTacticalSymbol,字段currentLines(其包含用于移动的方向线)在其中提请加入行提到列表(类的线2366)的方法命名drawLines(...)被使用。在第2364行中,您可以看到该颜色设置为黑色。

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

现在我建议你延长MilStd2525TacticalSymbol和做以下:

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

我正在跑掉之前的Worldwind,但试试看看AbstractTacticalSymbol.java - > drawLines()方法。

在绘制线条之前,它默认glColor为黑色。

相关问题