link.label.setPosition(p1.add(p2.sub(p1).stretch(0.5)).shift(LABEL_OFFSET, 0));
}
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));
}