2010-10-24 39 views
0

我无法理解org.eclipse.draw2d.Triangle的api。有一些操作区域:draw2d库中的三角形

protected int direction 
    The direction this triangle will face. Possible values are PositionConstants.NORTH, PositionConstants.SOUTH, PositionConstants.EAST and PositionConstants.WEST. 

protected int orientation 
    The orientation of this triangle. Possible values are Orientable.VERTICAL and Orientable.HORIZONTAL. 

还有“三角形的点”。但是没有与他们直接操纵的API。 所以我需要大概一些理解的例子..(通过点或smt像这样创建三角形)

谢谢。

回答

1

我不太了解这个API,但从查看源代码看,这个类看起来对于生成指向上,下,左或右的“箭头”型三角形非常有用,具体取决于您是否指定北,南,西或东分别为方向。

方向取决于方向,反之亦然。为了说明我的意思,这里是setDirection()代码:

public void setDirection(int value) { 
      if ((value & (NORTH | SOUTH)) != 0) 
        orientation = VERTICAL; 
      else 
        orientation = HORIZONTAL; 
      direction = value; 
      revalidate(); 
      repaint(); 
    } 

所以方向设置为VERTICAL如果指定了NORTHSOUTH方向,HORIZONTAL否则。

我不认为你可以使用这个类来绘制任意三角形。

+0

谢谢。由于我无法绘制任意三角形,因此我应该自行实施( – 2010-10-24 08:26:18