private static @Nullable Point getCollapsedTextEndLocation(JEditorPane text, BalloonLayoutData layoutData) {
    try {
      int end = text.viewToModel2D(new Point(10, layoutData.twoLineHeight + 5));
      if (end == -1) {
        end = text.getDocument().getLength();
      }
      for (int i = end - 1; i >= 0; i--) {
        Rectangle2D r = text.modelToView2D(i);
        if (r != null && r.getY() < layoutData.twoLineHeight) {
          return r.getBounds().getLocation();
        }
      }
    }
    catch (BadLocationException ignored) {
    }
    return null;
  }
private static @Nullable Point getCollapsedTextEndLocation(JEditorPane text, BalloonLayoutData layoutData)