Search in sources :

Example 36 with Vector2D

use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.

the class SLinkElbowLeftRight method buildVerticalBottomPath.

public void buildVerticalBottomPath(int direction) {
    Vector2D start_ = link.getStartWithOffset();
    Vector2D end_ = link.getEndWithOffset();
    Vector2D start = link.start;
    Vector2D end = link.end;
    double farest_y = Math.max(start_.y, end_.y) + 40;
    if (direction == LEFT_RIGHT) {
        if (start_.x > end.x - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength) {
            // Extend start out offset only if the end box is on the RIGHT
            double end_box_bottom_edge = end.y + GElementRect.DEFAULT_WIDTH * 0.5;
            if (start_.y <= end_box_bottom_edge + 5)
                start_.x = end.x - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength;
        }
        if (end_.x < start.x + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength) {
            // Extend end out offset only if the start box is on the RIGHT
            double start_box_bottom_edge = start.y + GElementRect.DEFAULT_WIDTH * 0.5;
            if (end_.y <= start_box_bottom_edge + 5)
                end_.x = start.x + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength;
        }
    } else {
        if (start_.x < end.x + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength) {
            // Extend start out offset only if the end box is on the RIGHT
            double end_box_bottom_edge = end.y + GElementRect.DEFAULT_WIDTH * 0.5;
            if (start_.y <= end_box_bottom_edge + 5)
                start_.x = end.x + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength;
        }
        if (end_.x > start.x - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength) {
            // Extend end out offset only if the start box is on the RIGHT
            double start_box_bottom_edge = start.y + GElementRect.DEFAULT_WIDTH * 0.5;
            if (end_.y <= start_box_bottom_edge + 5)
                end_.x = start.x - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength;
        }
    }
    // Extend the link to the RIGHT
    Vector2D p1 = start_.add(new Vector2D(0, farest_y - start.y));
    Vector2D p2 = end_.add(new Vector2D(0, farest_y - end.y));
    path.clear();
    path.add(start);
    path.add(start_);
    path.add(p1);
    path.add(p2);
    path.add(end_);
    path.add(end);
    Vector2D labelv = start_.sub(p2);
    labelv.stretch(0.5);
    link.label.setPosition(p2.add(labelv).shift(0, LABEL_OFFSET));
}
Also used : Vector2D(org.antlr.xjlib.appkit.gview.base.Vector2D)

Example 37 with Vector2D

use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.

the class SLinkElbowLeftTop method buildHorizontalLeftPath.

public void buildHorizontalLeftPath(boolean left) {
    Vector2D start_ = link.getStartWithOffset();
    Vector2D end_ = link.getEndWithOffset();
    double farest_x;
    double farest_y = Math.min(end_.y, start_.y - GElementRect.DEFAULT_HEIGHT * 0.5 - 10);
    if (left)
        farest_x = Math.min(end_.x - GElementRect.DEFAULT_WIDTH * 0.5 - 10, start_.x);
    else
        farest_x = Math.max(end_.x + GElementRect.DEFAULT_WIDTH * 0.5 + 10, start_.x);
    Vector2D p1 = new Vector2D(end_.x, farest_y);
    Vector2D p2 = new Vector2D(farest_x, p1.y);
    Vector2D p3 = new Vector2D(p2.x, start_.y);
    path.add(link.start);
    path.add(p3);
    path.add(p2);
    path.add(p1);
    path.add(end_);
    path.add(link.end);
    link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
}
Also used : Vector2D(org.antlr.xjlib.appkit.gview.base.Vector2D)

Example 38 with Vector2D

use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.

the class SLinkElbowLeftTop method buildHorizontalPath.

public void buildHorizontalPath() {
    Vector2D start_ = link.getStartWithOffset();
    Vector2D end_ = link.getEndWithOffset();
    Vector2D ab = link.start.sub(end_);
    Vector2D p1 = new Vector2D(end_.x + ab.x * 0.5, end_.y);
    Vector2D p2 = new Vector2D(p1.x, start_.y);
    path.add(link.start);
    path.add(start_);
    path.add(p2);
    path.add(p1);
    path.add(end_);
    path.add(link.end);
    link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
}
Also used : Vector2D(org.antlr.xjlib.appkit.gview.base.Vector2D)

Example 39 with Vector2D

use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.

the class SLinkElbowTopBottom method buildVerticalPath.

public void buildVerticalPath() {
    Vector2D start_ = link.getStartWithOffset();
    Vector2D end_ = link.getEndWithOffset();
    Vector2D ab = end_.sub(start_);
    Vector2D p1 = start_.add(new Vector2D(0, ab.getY() * 0.5));
    Vector2D p2 = p1.add(new Vector2D(ab.getX(), 0));
    Vector2D p3 = p2.add(new Vector2D(0, ab.getY() * 0.5));
    path.add(link.start);
    path.add(start_);
    path.add(p1);
    path.add(p2);
    path.add(p3);
    path.add(end_);
    path.add(link.end);
    link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
}
Also used : Vector2D(org.antlr.xjlib.appkit.gview.base.Vector2D)

Example 40 with Vector2D

use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.

the class SLinkElbowTopBottom method buildHorizontalPath.

public void buildHorizontalPath() {
    Vector2D start_ = link.getStartWithOffset();
    Vector2D end_ = link.getEndWithOffset();
    Vector2D ab = end_.sub(start_);
    Vector2D p1 = start_.add(new Vector2D(ab.getX() * 0.5, 0));
    Vector2D p2 = p1.add(new Vector2D(0, ab.getY()));
    Vector2D p3 = p2.add(new Vector2D(ab.getX() * 0.5, 0));
    path.add(link.start);
    path.add(start_);
    path.add(p1);
    path.add(p2);
    path.add(p3);
    path.add(end_);
    path.add(link.end);
    link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
}
Also used : Vector2D(org.antlr.xjlib.appkit.gview.base.Vector2D)

Aggregations

Vector2D (org.antlr.xjlib.appkit.gview.base.Vector2D)40 GElement (org.antlr.xjlib.appkit.gview.object.GElement)2 GLink (org.antlr.xjlib.appkit.gview.object.GLink)2 QuadCurve2D (java.awt.geom.QuadCurve2D)1 ArrayList (java.util.ArrayList)1