use of com.intellij.util.ui.AsyncProcessIcon in project intellij-community by JetBrains.
the class ProgressStripeIcon method generateIcon.
@NotNull
public static AsyncProcessIcon generateIcon(@NotNull JComponent component) {
List<Icon> result = ContainerUtil.newArrayList();
if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) {
result.add(new GradientIcon(component, i));
}
} else {
for (int i = 0; i < JBUI.scale(StripeIcon.WIDTH); i += JBUI.scale(TRANSLATE)) {
result.add(new StripeIcon(component, i));
}
result = ContainerUtil.reverse(result);
}
Icon passive = result.get(0);
AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {
@Override
public Dimension getPreferredSize() {
return new Dimension(component.getWidth(), passive.getIconHeight());
}
};
component.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
super.componentResized(e);
icon.revalidate();
}
});
return icon;
}
Aggregations