private static Point _getHintPosition(@NotNull LightweightHint hint,
                                        @NotNull Editor editor,
                                        @NotNull Point point1,
                                        @NotNull Point point2,
                                        @PositionFlags short constraint,
                                        boolean showByBalloon) {
    Dimension hintSize = hint.getComponent().getPreferredSize();

    Point location;
    JComponent externalComponent = getExternalComponent(editor);
    JComponent internalComponent = editor.getContentComponent();
    Point p;
    if (constraint == RIGHT_UNDER) {
      p = new Point(point2);
      if (!showByBalloon) {
        p.y += editor.getLineHeight();
      }
    }
    else {
      p = new Point(point1);
      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;
  }
private static Point _getHintPosition(@NotNull LightweightHint hint,
                                        @NotNull Editor editor,
                                        @NotNull Point point1,
                                        @NotNull Point point2,
                                        @PositionFlags short constraint,
                                        boolean showByBalloon)