link.label.setPosition(p2.copy().shift(-LABEL_OFFSET, -LABEL_OFFSET));
}
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));
}