Point (@NotNull LightweightHint hint, @NotNull Editor editor, @NotNull VisualPosition pos1, @NotNull VisualPosition pos2, @PositionFlags short constraint, boolean showByBalloon) { Dimension hintSize = hint.getComponent().getPreferredSize(); Point location; JComponent externalComponent = getExternalComponent(editor); JComponent internalComponent = editor.getContentComponent(); if (constraint == RIGHT_UNDER) { Point p = editor.visualPositionToXY(pos2); if (!showByBalloon) { p.y += editor.getLineHeight(); } location = SwingUtilities.convertPoint(internalComponent, p, externalComponent); } else { Point p = editor.visualPositionToXY(pos1); if (constraint == UNDER) { p.y += editor.getLineHeight(); } location = SwingUtilities.convertPoint(internalComponent, p, externalComponent); } if (constraint == ABOVE && !showByBalloon) { location.y -= hintSize.height; int diff = location.x + hintSize.width - externalComponent.getWidth(); if (diff > 0) { location.x = Math.max(location.x - diff, 0); } } if ((constraint == LEFT || constraint == RIGHT) && !showByBalloon) { location.y -= hintSize.height / 2; if (constraint == LEFT) { location.x -= hintSize.width; } } return location; }