void (@NotNull Rectangle inlayBounds) { Rectangle contentComponentBounds = myEditor.getScrollPane().getViewport().getViewRect(); int compMinX = contentComponentBounds.x; int compMaxX = compMinX + contentComponentBounds.width; int compMinY = contentComponentBounds.y; int compMaxY = compMinY + contentComponentBounds.height; int inlayMaxX = inlayBounds.x + inlayBounds.width; int inlayMaxY = inlayBounds.y + inlayBounds.height; JScrollBar hsb = myEditor.getScrollPane().getHorizontalScrollBar(); JScrollBar vsb = myEditor.getScrollPane().getVerticalScrollBar(); int hsbNewValue = hsb.getValue() + info.direction.xMultiplier * (inlayMaxX > compMaxX ? inlayMaxX - compMaxX : inlayMaxX < compMinX ? inlayMaxX - compMinX : 0); int vsbNewValue = vsb.getValue() + info.direction.yMultiplier * (inlayMaxY > compMaxY ? inlayMaxY - compMaxY : inlayMaxY < compMinY ? inlayMaxY - compMinY : 0); hsb.setValue(Math.max(0, hsbNewValue)); vsb.setValue(Math.max(0, vsbNewValue)); }