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;
}
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;
}
Aggregations