@Nullable Offsets computeOffsets(Graphics gg, @NotNull JComponent component) {
    if (painters.isEmpty()) {
      return null;
    }

    Offsets offsets = new Offsets();
    offsets.offsets = new int[painters.size() * 2];
    // store current graphics transform
    Graphics2D g = (Graphics2D)gg;
    offsets.transform = new AffineTransform(g.getTransform());
    // calculate relative offsets for painters
    Rectangle r = null;
    Component prev = null;
    int i = 0;
    for (Painter painter : painters) {
      if (!painter.needsRepaint()) {
        continue;
      }

      Component cur = painterToComponent.get(painter);
      if (cur != prev || r == null) {
        Container curParent = cur.getParent();
        if (curParent == null) {
          continue;
        }
        r = SwingUtilities.convertRectangle(curParent, cur.getBounds(), component);
        prev = cur;
      }
      // component offsets don't include graphics scale, so compensate
      offsets.offsets[i++] = r.x;
      offsets.offsets[i++] = r.y;
    }
    return offsets;
  }
@Nullable Offsets computeOffsets(Graphics gg, @NotNull JComponent component)