2010-10-24 37 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