// bottom offset correct is double
scrollY -= XDOM.getBodyScrollTop() * 2;
}
}
Size sz = getElement().getSize();
Region r = XElement.as(target).getRegion();
// Anchor range is not factored in on overall size, which overall size has to be used to flip to another side
// Note, things are inverted from display to programattical code like RIGHT means screen display LEFT
offsets = getAddAnchorToRange(offsets);
// When tip is screen top hits the ceiling out of range/site, this is the offset that fixes it.
if (toolTipConfig.isTrackMouse() && toolTipConfig.getAnchor() == Side.BOTTOM) {
offsets[1] = XDOM.getBodyScrollTop() * 2;
}
// When tip is screen bottom during a scroll needs an offset correction so not to flip to early
if (toolTipConfig.isTrackMouse() && toolTipConfig.getAnchor() == Side.TOP) {
offsets[1] -= XDOM.getBodyScrollTop() * 2;
}
if (GXTLogConfiguration.loggingIsEnabled()) {
String s = "dw=" + dw + ",dh=" + dh + " ";
s += "scroll=" + scrollX + ",=" + scrollY + " ";
s += "offsets=" + offsets[0] + "," + offsets[1] + " ";
s += "axy=" + axy[0] + "," + axy[1] + " ";
s += "sz=" + sz + " ";
s += "r=" + r + " ";
s += "isTrackMouse=" + toolTipConfig.isTrackMouse() + " ";
s += "targetXY=" + targetXY + " ";
logger.finest(s);
if (toolTipConfig.getAnchor() == Side.TOP) {
String s1 = "TOP CALC: " + "sz.getHeight()=" + sz.getHeight() + " " + "+ offsets[1]=" + offsets[1] + " "
+ "+ scrollY " + scrollY + " " + "< dh=" + dh + " " + "- r.getBottom()=" + r.getBottom();
String s2 = "TOP CALC: " + (sz.getHeight() + offsets[1] + scrollY) + " < " + (dh - r.getBottom()) + " ";
String s3 = "TOP CALC: " + (sz.getHeight() + offsets[1] + scrollY < dh - r.getBottom());
logger.finest(s1);
logger.finest(s2);
logger.finest(s3);
}
if (toolTipConfig.getAnchor() == Side.BOTTOM) {
String s1 = "BOTTOM CALC: sz.getHeight()=" + sz.getHeight() + " + offsets[1]=" + offsets[1] + " - scrollY="
+ scrollY + " < r.getTop()=" + r.getTop();
String s2 = "BOTTOM CALC: " + (sz.getHeight() + offsets[1] - scrollY) + " < " + r.getTop();
String s3 = "BOTTOM CALC: " + (sz.getHeight() + offsets[1] - scrollY < r.getTop());
logger.finest(s1);
logger.finest(s2);
logger.finest(s3);
}
if (toolTipConfig.getAnchor() == Side.LEFT) {
String s1 = "LEFT CALC: sz.getWidth()=" + sz.getWidth() + " + offsets[0]=" + offsets[0] + " + scrollX="
+ scrollX + " < dw=" + dw + " - r.getRight()=" + r.getRight();
String s2 = "LEFT CALC: " + (sz.getWidth() + offsets[0] + scrollX) + " < " + (dw - r.getRight());
String s3 = "LEFT CALC: " + (sz.getWidth() + offsets[0] + scrollX < dw - r.getRight());
logger.finest(s1);
logger.finest(s2);
logger.finest(s3);
}
if (toolTipConfig.getAnchor() == Side.RIGHT) {
String s1 = "RIGHT CALC: sz.getWidth()=" + sz.getWidth() + " + offsets[0]=" + offsets[0] + " + scrollX="
+ scrollX + " < r.getLeft()=" + r.getLeft();
String s2 = "RIGHT CALC: " + (sz.getWidth() + offsets[0] + scrollX) + " < " + r.getLeft();
String s3 = "RIGHT CALC: " + (sz.getWidth() + offsets[0] + scrollX < r.getLeft());
logger.finest(s1);
logger.finest(s2);
logger.finest(s3);
}
}
// if we are not inside valid ranges we try to switch the anchor
if (!((toolTipConfig.getAnchor() == Side.TOP && (sz.getHeight() + offsets[1] + scrollY < dh - r.getBottom()))
|| (toolTipConfig.getAnchor() == Side.RIGHT && (sz.getWidth() + offsets[0] + scrollX < r.getLeft()))
|| (toolTipConfig.getAnchor() == Side.BOTTOM && (sz.getHeight() + offsets[1] - scrollY < r.getTop()))
|| (toolTipConfig.getAnchor() == Side.LEFT && (sz.getWidth() + offsets[0] - scrollX < dw - r.getRight())))
&& targetCounter < 4) {
targetCounter++;
if (sz.getWidth() + offsets[0] + scrollX < r.getLeft()) {
toolTipConfig.setAnchor(Side.RIGHT);
return getTargetXY(targetCounter);
}
if (sz.getWidth() + offsets[0] + scrollX < r.getLeft()) {
toolTipConfig.setAnchor(Side.LEFT);
return getTargetXY(targetCounter);
}
if (sz.getHeight() + offsets[1] + scrollY < dh - r.getBottom()) {
toolTipConfig.setAnchor(Side.TOP);
return getTargetXY(targetCounter);
}
if (sz.getHeight() + offsets[1] + scrollY < r.getTop()) {
toolTipConfig.setAnchor(Side.BOTTOM);
return getTargetXY(targetCounter);
}
}