Dimension (@NotNull Editor editor, @NotNull Point p, boolean alignToRight, boolean expanded, @NotNull JComponent tooltipComponent, @NotNull JLayeredPane layeredPane, int widthLimit, int heightLimit, int currentWidth) { Dimension preferredSize = tooltipComponent.getPreferredSize(); int width = expanded ? 3 * currentWidth / 2 : preferredSize.width; int height = expanded ? Math.max(preferredSize.height, 150) : preferredSize.height; Dimension dimension = new Dimension(width, height); if (alignToRight) { p.x = Math.max(0, p.x - width); } // try to make cursor outside tooltip. SCR 15038 p.x += 3; p.y += 3; if (p.x >= widthLimit - width) { p.x = widthLimit - width; width = Math.min(width, widthLimit); height += 20; dimension = new Dimension(width, height); } if (p.x < 3) { p.x = 3; } if (p.y > heightLimit - height) { p.y = heightLimit - height; height = Math.min(heightLimit, height); dimension = new Dimension(width, height); } if (p.y < 3) { p.y = 3; } locateOutsideMouseCursor(editor, layeredPane, p, width, height, heightLimit); return dimension; }