@@ -0,0 +1,2516 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0A%0Apackage com.intellij.ui;%0A%0Aimport com.intellij.util.IconUtil;%0Aimport com.intellij.util.ui.JBUI.CachingScalableJBIcon;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport javax.swing.Icon;%0Aimport java.awt.Component;%0Aimport java.awt.Graphics;%0Aimport java.util.Objects;%0A%0Aimport static com.intellij.util.ui.JBUI.ScaleType.OBJ_SCALE;%0Aimport static java.lang.Math.ceil;%0A%0Apublic final class OffsetIcon extends CachingScalableJBIcon%3COffsetIcon%3E %7B%0A  private int myWidth;%0A  private int myHeight;%0A%0A  private final int myOffset;%0A  private final Icon myIcon;%0A  private Icon myScaledIcon;%0A  private int myScaledOffset;%0A%0A  %7B%0A    getScaleContext().addUpdateListener(this::updateSize);%0A    setAutoUpdateScaleContext(false);%0A  %7D%0A%0A  public OffsetIcon(@NotNull Icon icon) %7B%0A    this(20, icon);%0A  %7D%0A%0A  public OffsetIcon(int offset, @NotNull Icon icon) %7B%0A    myOffset = offset;%0A    myIcon = icon;%0A    updateSize();%0A  %7D%0A%0A  private OffsetIcon(@NotNull OffsetIcon icon) %7B%0A    super(icon);%0A    myWidth = icon.myWidth;%0A    myHeight = icon.myHeight;%0A    myOffset = icon.myOffset;%0A    myIcon = icon.myIcon;%0A    myScaledIcon = null;%0A    myScaledOffset = icon.myScaledOffset;%0A  %7D%0A%0A  @NotNull%0A  @Override%0A  protected OffsetIcon copy() %7B%0A    return new OffsetIcon(this);%0A  %7D%0A%0A  @NotNull%0A  public Icon getIcon() %7B%0A    return myIcon;%0A  %7D%0A%0A  public int hashCode() %7B%0A    return myIcon.hashCode();%0A  %7D%0A%0A  public boolean equals(Object obj) %7B%0A    return obj instanceof OffsetIcon && Objects.equals(((OffsetIcon)obj).myIcon, myIcon);%0A  %7D%0A%0A  @Override%0A  public void paintIcon(Component c, Graphics g, int x, int y) %7B%0A    getScaleContext().update();%0A    if (myScaledIcon == null) %7B%0A      float scale = getScale();%0A      myScaledIcon = scale == 1f ? myIcon : IconUtil.scale(myIcon, null, scale);%0A    %7D%0A    myScaledIcon.paintIcon(c, g, myScaledOffset + x, y);%0A  %7D%0A%0A  @Override%0A  public int getIconWidth() %7B%0A    getScaleContext().update();%0A    return (int)ceil(scaleVal(myWidth, OBJ_SCALE)) + myScaledOffset;%0A  %7D%0A%0A  @Override%0A  public int getIconHeight() %7B%0A    getScaleContext().update();%0A    return (int)ceil(scaleVal(myHeight, OBJ_SCALE));%0A  %7D%0A%0A  private void updateSize() %7B%0A    myWidth = myIcon.getIconWidth();%0A    myHeight = myIcon.getIconHeight();%0A    myScaledOffset = (int)ceil(scaleVal(myOffset));%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return %22OffsetIcon: offset=%22 + myOffset + %22; icon=%22 + myIcon;%0A  %7D%0A%7D%0A

introduce OffsetIcon to make pseudo-trees in lists