private static boolean shouldAddGapAfterCell(final DimensionInfo info, final int cellIndex) {
    if (cellIndex < 0 || cellIndex >= info.getCellCount()) {
      throw new IllegalArgumentException("wrong cellIndex: " + cellIndex + "; cellCount=" + info.getCellCount());
    }

    boolean endsInThis = false;
    boolean startsInNext = false;

    int indexOfNextNotEmpty = -1;
    for (int i = cellIndex + 1; i < info.getCellCount(); i++) {
      if (!isCellEmpty(info, i)) {
        indexOfNextNotEmpty = i;
        break;
      }
    }

    for (int i = 0; i < info.getComponentCount(); i++) {
      final Component component = info.getComponent(i);
      if (component instanceof Spacer) {
        continue;
      }

      if (info.componentBelongsCell(i, cellIndex) &&
          DimensionInfo.findAlignedChild(component, info.getConstraints(i)) != null) {
        return true;
      }

      if (info.getCell(i) == indexOfNextNotEmpty) {
        startsInNext = true;
      }

      if (info.getCell(i) + info.getSpan(i) - 1 == cellIndex) {
        endsInThis = true;
      }
    }

    return startsInNext && endsInThis;
  }
private static boolean shouldAddGapAfterCell(final DimensionInfo info, final int cellIndex)