private void showIndicatorPopup(final int xPos, final int yPos, final boolean showLeft, final String html) {
        indicatorPopup.setHTML(html);
        indicatorPopup.setPopupPositionAndShow((offsetWidth, offsetHeight) -> {
            int x = xPos;
            final int minX = 0;
            final int maxX = Window.getClientWidth() - offsetWidth;
            int y = yPos;
            final int minY = 0;
            final int maxY = Window.getClientHeight() - offsetHeight;

            if (showLeft) {
                x -= offsetWidth;
            }

            if (x < minX) {
                x = minX;
            } else if (x > maxX) {
                x = maxX;
            }

            if (y < minY) {
                y = minY;
            } else if (y > maxY) {
                y = maxY;
            }

            indicatorPopup.setPopupPosition(x, y);
        });
    }
Shows text associated with an indicator in a popup.
stroom-core-client-widget/src/main/java/stroom/editor/client/view/RightBar.java