private static @NotNull Pair<Image, Point> createDragImage(@NotNull Tree tree,
                                                             @NotNull Component c,
                                                             @Nullable Point dragOrigin,
                                                             boolean adjustToPathUnderDragOrigin) {
    if (c instanceof JComponent) {
      ((JComponent)c).setOpaque(true);
    }

    c.setForeground(RenderingUtil.getForeground(tree));
    c.setBackground(RenderingUtil.getBackground(tree));
    c.setFont(tree.getFont());
    c.setSize(c.getPreferredSize());
    final BufferedImage image = UIUtil.createImage(c, c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D)image.getGraphics();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
    c.paint(g2);
    g2.dispose();

    Point point = new Point(image.getWidth(null) / 2, image.getHeight(null) / 2);

    if (adjustToPathUnderDragOrigin) {
      TreePath path = tree.getPathForLocation(dragOrigin.x, dragOrigin.y);
      if (path != null) {
        Rectangle bounds = tree.getPathBounds(path);
        point = new Point(dragOrigin.x - bounds.x, dragOrigin.y - bounds.y);
      }
    }

    return new Pair<>(image, point);
  }
private static @NotNull Pair<Image, Point> createDragImage(@NotNull Tree tree,
                                                             @NotNull Component c,
                                                             @Nullable Point dragOrigin,
                                                             boolean adjustToPathUnderDragOrigin)