views:

28

answers:

1

Hi!

I can't understand org.eclipse.draw2d.Triangle's api. There are some fields for manipulation:

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. 

There are "The points of the triangle" also. But there is no api for direct manipulation with them. So I need probably some examples for understanding.. (Creating triangle by points or smt like this)

Thanks.

+1  A: 

I don't know the API very well, but from looking at the source, this class looks like it is useful for producing "arrowhead" type triangles that point either up, down, left or right depending on whether you specify north, south, west or east respectively for the direction.

The orientation is dependent on direction, and vice-versa. To illustrate what I mean, here is the code for setDirection():

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

So orientation is set to VERTICAL if you specify a NORTH or SOUTH direction, and HORIZONTAL otherwise.

I don't think you can use this class to draw arbitrary triangles.

spong
@spong : Thanks. As I couldn't draw arbitrary triangles I should implement It by myself(
Stas