RelativePoint (@NotNull Balloon object) { if (myTarget != null && !popupFactory.isBestPopupLocationVisible(myEditor)) { return myTarget; } if (myCaretRangeMarker != null && myCaretRangeMarker.isValid()) { myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, myEditor.offsetToVisualPosition(myCaretRangeMarker.getStartOffset())); } RelativePoint target = popupFactory.guessBestPopupLocation(myEditor); Point screenPoint = target.getScreenPoint(); int y = screenPoint.y; if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) { y -= myEditor.getLineHeight(); } myTarget = new RelativePoint(new Point(screenPoint.x, y)); return myTarget; }