Search in sources :

Example 1 with Vector

use of org.eclipse.draw2d.geometry.Vector in project tdi-studio-se by Talend.

the class LookupConnectionRouter method getDirection.

protected Vector getDirection(Rectangle r, Point p) {
    int i, distance = Math.abs(r.x - p.x);
    Vector direction;
    direction = LEFT;
    i = Math.abs(r.y - p.y);
    if (i <= distance) {
        distance = i;
        direction = UP;
    }
    i = Math.abs(r.bottom() - p.y);
    if (i <= distance) {
        distance = i;
        direction = DOWN;
    }
    i = Math.abs(r.right() - p.x);
    if (i < distance) {
        distance = i;
        direction = RIGHT;
    }
    return direction;
}
Also used : Vector(org.eclipse.draw2d.geometry.Vector) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with Vector

use of org.eclipse.draw2d.geometry.Vector in project Palladio-Editors-Sirius by PalladioSimulator.

the class AbstractRotatableImageEditPart method getFirstSegmentAngle.

/**
 * Angle in degrees [0..360]
 *
 * @param polylineConnection
 * @return the angle in degrees.
 */
public static double getFirstSegmentAngle(PolylineConnection polylineConnection) {
    PointList points = polylineConnection.getPoints();
    PrecisionPoint firstPoint = new PrecisionPoint(points.getFirstPoint());
    PrecisionPoint secondPoint = new PrecisionPoint(points.getPoint(1));
    Vector edgeVector = new Vector(firstPoint, secondPoint);
    double atan2 = Math.atan2(edgeVector.y, edgeVector.x);
    double degrees = Math.toDegrees(atan2);
    if (degrees < 0) {
        degrees = -degrees;
    } else {
        degrees = 180 + (180 - degrees);
    }
    return degrees;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Vector(org.eclipse.draw2d.geometry.Vector) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Aggregations

Vector (org.eclipse.draw2d.geometry.Vector)2 Point (org.eclipse.draw2d.geometry.Point)1 PointList (org.eclipse.draw2d.geometry.PointList)1 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)1