public static String layoutCompoundLabel(JComponent c,
    FontMetrics fm,
    String[] text,
    Icon icon,
    int verticalAlignment,
    int horizontalAlignment,
    int verticalTextPosition,
    int horizontalTextPosition,
    Rectangle viewR,
    Rectangle iconR,
    Rectangle textR,
    int textIconGap) {
    boolean orientationIsLeftToRight = true;


    if (c != null) {
      if (!(c.getComponentOrientation().isLeftToRight())) {
        orientationIsLeftToRight = false;
      }
    }


    // Translate LEADING/TRAILING values in horizontalAlignment
    // to LEFT/RIGHT values depending on the components orientation
    int hAlign = switch (horizontalAlignment) {
      case LEADING -> (orientationIsLeftToRight) ? LEFT : RIGHT;
      case TRAILING -> (orientationIsLeftToRight) ? RIGHT : LEFT;
      default -> horizontalAlignment;
    };

    // Translate LEADING/TRAILING values in horizontalTextPosition
    // to LEFT/RIGHT values depending on the components orientation
    int hTextPos = switch (horizontalTextPosition) {
      case LEADING -> (orientationIsLeftToRight) ? LEFT : RIGHT;
      case TRAILING -> (orientationIsLeftToRight) ? RIGHT : LEFT;
      default -> horizontalTextPosition;
    };

    return layoutCompoundLabel(fm,
      text,
      icon,
      verticalAlignment,
      hAlign,
      verticalTextPosition,
      hTextPos,
      viewR,
      iconR,
      textR,
      textIconGap);
  }
public static String layoutCompoundLabel(JComponent c,
    FontMetrics fm,
    String[] text,
    Icon icon,
    int verticalAlignment,
    int horizontalAlignment,
    int verticalTextPosition,
    int horizontalTextPosition,
    Rectangle viewR,
    Rectangle iconR,
    Rectangle textR,
    int textIconGap)