Search in sources :

Example 6 with PointList

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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point)

Example 7 with 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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) Ray(org.eclipse.draw2d.geometry.Ray) Point(org.eclipse.draw2d.geometry.Point)

Example 8 with PointList

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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 9 with PointList

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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 10 with PointList

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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList)

Aggregations

PointList (org.eclipse.draw2d.geometry.PointList)16 Point (org.eclipse.draw2d.geometry.Point)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 CreateConnectionRequest (org.eclipse.gef.requests.CreateConnectionRequest)2 EConnectionCategory (org.talend.core.model.process.EConnectionCategory)2 EConnectionType (org.talend.core.model.process.EConnectionType)2 IConnection (org.talend.core.model.process.IConnection)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 PolygonDecoration (org.eclipse.draw2d.PolygonDecoration)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Ray (org.eclipse.draw2d.geometry.Ray)1 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)1 PolylineConnectionEx (org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx)1 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)1