*/
protected void showLayoutTargetFeedback(Request request) {
if (getHost().getChildren().size() == 0)
return;
Polyline fb = getLineFeedback();
Transposer transposer = new Transposer();
transposer.setEnabled(!isLayoutHorizontal(request));
boolean before = true;
int epIndex = getFeedbackIndexFor(request);
Rectangle r = null;
if (epIndex == -1) {
before = false;
epIndex = getHost().getChildren().size() - 1;
EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
} else {
EditPart editPart = (EditPart) getHost().getChildren().get(epIndex);
r = transposer.t(getAbsoluteBounds((GraphicalEditPart) editPart));
Point p = transposer.t(getLocationFromRequest(request));
if (p.x <= r.x + (r.width / 2))
before = true;
else {
/*
* We are not to the left of this Figure, so the emphasis line
* needs to be to the right of the previous Figure, which must
* be on the previous row.
*/
before = false;
epIndex--;
editPart = (EditPart) getHost().getChildren().get(epIndex);
r = transposer
.t(getAbsoluteBounds((GraphicalEditPart) editPart));
}
}
int x = Integer.MIN_VALUE;
if (before) {
/*
* Want the line to be halfway between the end of the previous and
* the beginning of this one. If at the beginning of a line, then
* start halfway between the left edge of the parent and the
* beginning of the box, but no more than 5 pixels (it would be too
* far and be confusing otherwise).
*/
if (epIndex > 0) {
// Need to determine if a line break.
Rectangle boxPrev = transposer
.t(getAbsoluteBounds((GraphicalEditPart) getHost()
.getChildren().get(epIndex - 1)));
int prevRight = boxPrev.right();
if (prevRight < r.x) {
// Not a line break
x = prevRight + (r.x - prevRight) / 2;
} else if (prevRight == r.x) {
x = prevRight + 1;
}
}
if (x == Integer.MIN_VALUE) {
// It is a line break.
Rectangle parentBox = transposer
.t(getAbsoluteBounds((GraphicalEditPart) getHost()));
x = r.x - 5;
if (x < parentBox.x)
x = parentBox.x + (r.x - parentBox.x) / 2;
}
} else {
/*
* We only have before==false if we are at the end of a line, so go
* halfway between the right edge and the right edge of the parent,
* but no more than 5 pixels.
*/
Rectangle parentBox = transposer
.t(getAbsoluteBounds((GraphicalEditPart) getHost()));
int rRight = r.x + r.width;
int pRight = parentBox.x + parentBox.width;
x = rRight + 5;
if (x > pRight)
x = rRight + (pRight - rRight) / 2;
}
Point p1 = new Point(x, r.y);
p1 = transposer.t(p1);
fb.translateToRelative(p1);
Point p2 = new Point(x, r.y + r.height);
p2 = transposer.t(p2);
fb.translateToRelative(p2);
fb.setPoint(p1, 0);
fb.setPoint(p2, 1);
}