in src/main/java/com/intellij/util/ui/UIUtilities.java [1638:1683]
private static Section liesIn(Rectangle rect, Point p, boolean horizontal,
boolean ltr, boolean three) {
/* beginning of the rectangle on the axis */
int p0;
/* point on the axis we're interested in */
int pComp;
/* length of the rectangle on the axis */
int length;
/* value of ltr if horizontal, else true */
boolean forward;
if (horizontal) {
p0 = rect.x;
pComp = p.x;
length = rect.width;
forward = ltr;
} else {
p0 = rect.y;
pComp = p.y;
length = rect.height;
forward = true;
}
if (three) {
int boundary = (length >= 30) ? 10 : length / 3;
if (pComp < p0 + boundary) {
return forward ? Section.LEADING : Section.TRAILING;
} else if (pComp >= p0 + length - boundary) {
return forward ? Section.TRAILING : Section.LEADING;
}
return Section.MIDDLE;
} else {
int middle = p0 + length / 2;
if (forward) {
return pComp >= middle ? Section.TRAILING : Section.LEADING;
} else {
return pComp < middle ? Section.TRAILING : Section.LEADING;
}
}
}