use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.
the class SLinkElbowLeftRight 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.clear();
path.add(link.start);
if (ab.getX() != 0) {
path.add(start_);
path.add(p1);
path.add(p2);
path.add(p3);
path.add(end_);
}
path.add(link.end);
link.label.setPosition(p2.copy().shift(-LABEL_OFFSET, -LABEL_OFFSET));
}
use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.
the class SLinkElbowLeftTop method buildVerticalPath.
public void buildVerticalPath() {
Vector2D start_ = link.getStartWithOffset();
Vector2D end_ = link.getEndWithOffset();
if (link.start.x > link.end.x + link.outOffsetLength && link.startDirection == Anchor2D.DIRECTION_LEFT) {
path.add(link.start);
path.add(link.end.x, link.start.y);
path.add(link.end);
link.label.setPosition(link.end.x + (link.start.x - link.end.x) * 0.5, link.start.y - LABEL_OFFSET);
} else if (link.start.x < link.end.x - link.outOffsetLength && link.startDirection == Anchor2D.DIRECTION_RIGHT) {
path.add(link.start);
path.add(link.end.x, link.start.y);
path.add(link.end);
link.label.setPosition(link.end.x + (link.start.x - link.end.x) * 0.5, link.start.y - LABEL_OFFSET);
} else if (link.start.y + GElementRect.DEFAULT_HEIGHT * 0.5 > end_.y - 10) {
Vector2D p1 = new Vector2D(link.end.x, link.start.y - GElementRect.DEFAULT_HEIGHT * 0.5 - 10);
Vector2D p2 = new Vector2D(start_.x, p1.y);
path.add(link.start);
path.add(start_);
path.add(p2);
path.add(p1);
path.add(link.end);
link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
} else {
Vector2D ab = start_.sub(link.end);
Vector2D p1 = new Vector2D(link.end.x, link.end.y + ab.y * 0.5);
Vector2D p2 = new Vector2D(p1.x + ab.x, p1.y);
Vector2D p3 = new Vector2D(p2.x, start_.y);
path.add(link.start);
path.add(start_);
path.add(p3);
path.add(p2);
path.add(p1);
path.add(link.end);
link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, LABEL_OFFSET));
}
}
use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.
the class SLinkElbowTopBottom method buildHorizontalRightPath.
public void buildHorizontalRightPath(int direction) {
Vector2D start_ = link.getStartWithOffset();
Vector2D end_ = link.getEndWithOffset();
Vector2D start = link.start;
Vector2D end = link.end;
double farest_x = Math.max(start_.x, end_.x) + 40;
if (direction == BOTTOM_TOP) {
if (start_.y < end.y + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength) {
// Extend start out offset only if the end box is on the RIGHT
double end_box_right_edge = end.x + GElementRect.DEFAULT_WIDTH * 0.5;
if (start_.x <= end_box_right_edge + 5)
start_.y = end.y + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength;
}
if (end_.y > start.y - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength) {
// Extend end out offset only if the start box is on the RIGHT
double start_box_right_edge = start.x + GElementRect.DEFAULT_WIDTH * 0.5;
if (end_.x <= start_box_right_edge + 5)
end_.y = start.y - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength;
}
} else if (direction == TOP_BOTTOM) {
if (start_.y > end.y - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength) {
// Extend start out offset only if the end box is on the RIGHT
double end_box_right_edge = end.x + GElementRect.DEFAULT_WIDTH * 0.5;
if (start_.x <= end_box_right_edge + 5)
start_.y = end.y - GElementRect.DEFAULT_HEIGHT - link.outOffsetLength;
}
if (end_.y < start.y + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength) {
// Extend end out offset only if the start box is on the RIGHT
double start_box_right_edge = start.x + GElementRect.DEFAULT_WIDTH * 0.5;
if (end_.x <= start_box_right_edge + 5)
end_.y = start.y + GElementRect.DEFAULT_HEIGHT + link.outOffsetLength;
}
}
// Extend the link to the RIGHT
Vector2D p1 = start_.add(new Vector2D(farest_x - start.x, 0));
Vector2D p2 = end_.add(new Vector2D(farest_x - end.x, 0));
path.add(start);
path.add(start_);
path.add(p1);
path.add(p2);
path.add(end_);
path.add(end);
link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
}
use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.
the class SLinkElbowTopLeft method buildHorizontalLeftPath.
public void buildHorizontalLeftPath(boolean left) {
Vector2D start_ = link.getStartWithOffset();
Vector2D end_ = link.getEndWithOffset();
double farest_x;
double farest_y = Math.min(start_.y, end_.y - GElementRect.DEFAULT_HEIGHT * 0.5 - 10);
if (left)
farest_x = Math.min(start_.x - GElementRect.DEFAULT_WIDTH * 0.5 - 10, end_.x);
else
farest_x = Math.max(start_.x + GElementRect.DEFAULT_WIDTH * 0.5 + 10, end_.x);
Vector2D p1 = new Vector2D(start_.x, farest_y);
Vector2D p2 = new Vector2D(farest_x, p1.y);
Vector2D p3 = new Vector2D(p2.x, end_.y);
path.add(link.start);
path.add(start_);
path.add(p1);
path.add(p2);
path.add(p3);
path.add(link.end);
link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(0, -LABEL_OFFSET));
}
use of org.antlr.xjlib.appkit.gview.base.Vector2D in project antlrworks by antlr.
the class GEngineGraphics method drawArcConnector.
public void drawArcConnector(float x0, float y0, float x1, float y1, float start_offset, float end_offset, float ctrl_offset, float arc_offset, boolean arrow) {
if (x0 > x1) {
ctrl_offset *= -1;
arc_offset *= -1;
}
float cx = x1 - ctrl_offset;
float ax0 = cx - arc_offset;
Vector2D a = new Vector2D(cx, y0);
Vector2D b = new Vector2D(x1, y1);
Vector2D z = a.add(b.sub(a).setLength(Math.abs(arc_offset)));
drawLine(x0 + start_offset, y0, ax0, y0);
drawSpline((float) z.x, (float) z.y, x1, y1, 0, end_offset, 0, arrow);
QuadCurve2D.Float quad = new QuadCurve2D.Float();
quad.setCurve(ax0, y0, cx, y0, (float) z.x, (float) z.y);
getG2D().draw(quad);
}
Aggregations