0

我看不懂 org.eclipse.draw2d.Triangle 的 api。有一些用于操作的字段:

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)

谢谢。

4

1 回答 1

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否则设置为。

我认为您不能使用此类来绘制任意三角形。

于 2010-10-24T08:06:46.627 回答