use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.
the class TalendBorderItemRectilinearRouter method makeUpConnection.
private void makeUpConnection(Connection conn) {
Point firstPoint = conn.getPoints().getFirstPoint();
Point lastPoint = conn.getPoints().getLastPoint();
PointList pointList = new PointList();
pointList.addPoint(firstPoint);
pointList.addPoint((lastPoint.x + firstPoint.x) / 2, firstPoint.y);
pointList.addPoint((lastPoint.x + firstPoint.x) / 2, (lastPoint.y + firstPoint.y) / 2);
pointList.addPoint((lastPoint.x + firstPoint.x) / 2, lastPoint.y);
pointList.addPoint(lastPoint);
conn.setPoints(pointList);
}
use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.
the class CurveConnectionRouter method route.
/**
* @see ConnectionRouter#route(Connection)
*/
public void route(Connection conn) {
if ((conn.getSourceAnchor() == null) || (conn.getTargetAnchor() == null)) {
return;
}
Point startPoint = getStartPoint(conn);
conn.translateToRelative(startPoint);
Point endPoint = getEndPoint(conn);
conn.translateToRelative(endPoint);
Ray start = new Ray(startPoint);
Ray end = new Ray(endPoint);
PointList points = new PointList();
points.addPoint(new Point(start.x, start.y));
Point p;
double w = Math.abs(start.x - end.x) * 4;
double h = Math.abs(start.y - end.y);
if (h <= 20) {
points.addPoint(new Point(end.x, end.y));
conn.setPoints(points);
return;
}
double EY = (int) (h / 2);
double EX = (int) (w / 4 / Math.PI);
int n = 400;
double h1 = 4.0 * Math.PI / n;
double x1 = -2 * Math.PI, y1 = Math.sin(x1), x2, y2;
boolean sight = false;
double dis = 0;
int beginJ = n / 8 * 3;
int endJ = n / 8 * 5;
double subTract = Math.abs(start.x - end.x) * 1.5;
if (start.y < end.y) {
subTract = Math.abs(start.x - end.x) * 0.5;
beginJ = n / 8 * 1;
endJ = n / 8 * 3;
}
for (int j = 0; j < n; j++) {
x2 = x1 + h1;
y2 = Math.sin(x2);
if (j > beginJ && j < endJ) {
double temx = (x1 * EX) + w / 2 + start.x - subTract;
double temy = (h / 2) - (EY * y1) + (h / 2);
if (!sight) {
dis = (temy - start.y);
}
p = new Point(temx, temy - dis);
points.addPoint(p);
sight = true;
} else if (j < beginJ) {
points.addPoint(new Point(start.x, start.y));
} else if (j > endJ) {
points.addPoint(new Point(end.x, end.y));
}
x1 = x2;
y1 = y2;
}
points.addPoint(new Point(end.x, end.y));
conn.setPoints(points);
}
use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.
the class LookupConnectionRouter method route.
public void route(Connection conn) {
PointList points = conn.getPoints();
points.removeAllPoints();
Point p;
Point startPoint = getStartPoint(conn);
Point endPoint = getEndPoint(conn);
conn.translateToRelative(p = startPoint);
points.addPoint(p);
if (conn instanceof PolylineConnection) {
PolylineConnection polylineConn = (PolylineConnection) conn;
// polylineConn.getta
}
// conn.getTargetDecoration()
conn.translateToRelative(p = getReferrencedPoint(startPoint));
points.addPoint(p);
conn.translateToRelative(p = getReferrencedPoint(endPoint));
points.addPoint(p);
conn.translateToRelative(p = endPoint);
points.addPoint(p);
conn.setPoints(points);
}
use of org.eclipse.draw2d.geometry.PointList in project dbeaver by serge-rider.
the class GraphAnimation method recordFinalState.
public static void recordFinalState(Connection conn) {
//$TODO
PointList points1 = (PointList) initialStates.get(conn);
PointList points2 = conn.getPoints().getCopy();
if (points1 != null && points1.size() != points2.size()) {
Point p = new Point(), q = new Point();
int size1 = points1.size() - 1;
int size2 = points2.size() - 1;
int i1 = size1;
int i2 = size2;
double current1 = 1.0;
double current2 = 1.0;
double prev1 = 1.0;
double prev2 = 1.0;
while (i1 > 0 || i2 > 0) {
if (Math.abs(current1 - current2) < 0.1 && i1 > 0 && i2 > 0) {
//Both points are the same, use them and go on;
prev1 = current1;
prev2 = current2;
i1--;
i2--;
current1 = (double) i1 / size1;
current2 = (double) i2 / size2;
} else if (current1 < current2) {
//2 needs to catch up
// current1 < current2 < prev1
points1.getPoint(p, i1);
points1.getPoint(q, i1 + 1);
p.x = (int) (((q.x * (current2 - current1) + p.x * (prev1 - current2)) / (prev1 - current1)));
p.y = (int) (((q.y * (current2 - current1) + p.y * (prev1 - current2)) / (prev1 - current1)));
points1.insertPoint(p, i1 + 1);
prev1 = prev2 = current2;
i2--;
current2 = (double) i2 / size2;
} else {
//1 needs to catch up
// current2< current1 < prev2
points2.getPoint(p, i2);
points2.getPoint(q, i2 + 1);
p.x = (int) (((q.x * (current1 - current2) + p.x * (prev2 - current1)) / (prev2 - current2)));
p.y = (int) (((q.y * (current1 - current2) + p.y * (prev2 - current1)) / (prev2 - current2)));
points2.insertPoint(p, i2 + 1);
prev2 = prev1 = current1;
i1--;
current1 = (double) i1 / size1;
}
}
}
finalStates.put(conn, points2);
}
use of org.eclipse.draw2d.geometry.PointList in project tdi-studio-se by Talend.
the class DecisionBusinessItemShapeFigure method drawFigure.
private void drawFigure(Rectangle r, Graphics graphics) {
PointList pointList = new PointList();
pointList.removeAllPoints();
pointList.addPoint(r.x + r.width / 2, r.y);
pointList.addPoint(r.x + r.width, r.y + r.height / 2);
pointList.addPoint(r.x + r.width / 2, r.y + r.height);
pointList.addPoint(r.x, r.y + r.height / 2);
graphics.fillPolygon(pointList);
graphics.drawPolygon(pointList);
}
Aggregations