@Override public Icon scale(float scaleFactor) { if (scaleFactor == 1f) { return this; } if (scaledIcons == null) { scaledIcons = new HashMap<Float, Icon>(1); } Icon result = scaledIcons.get(scaleFactor); if (result != null) { return result; } final Image image = ImageLoader.loadFromUrl(myUrl, UIUtil.isUnderDarcula(), scaleFactor >= 1.5f, filter); if (image != null) { int width = (int) (getIconWidth() * scaleFactor); int height = (int) (getIconHeight() * scaleFactor); final BufferedImage resizedImage = Scalr.resize( ImageUtil.toBufferedImage(image), Scalr.Method.ULTRA_QUALITY, width, height); result = getIcon(resizedImage); scaledIcons.put(scaleFactor, result); return result; } return this; }
@Nullable public Icon getProgressTailIcon() { if (myProgressTailIcon == null && myProgressTailIconName != null) { try { final URL url = getClass().getResource(myProgressTailIconName); @SuppressWarnings({"deprecation", "UnnecessaryFullyQualifiedName"}) final Image image = com.intellij.util.ImageLoader.loadFromUrl(url, false); if (image != null) { myProgressTailIcon = new ImageIcon(image); } } catch (Exception ignore) { } } return myProgressTailIcon; }
@NotNull private synchronized Icon getRealIcon() { if (isLoaderDisabled() && (myRealIcon == null || dark != USE_DARK_ICONS || scale != SCALE || filter != IMAGE_FILTER)) return EMPTY_ICON; if (dark != USE_DARK_ICONS || scale != SCALE || filter != IMAGE_FILTER) { myRealIcon = null; dark = USE_DARK_ICONS; scale = SCALE; filter = IMAGE_FILTER; } Object realIcon = myRealIcon; if (realIcon instanceof Icon) return (Icon) realIcon; Icon icon; if (realIcon instanceof Reference) { icon = ((Reference<Icon>) realIcon).get(); if (icon != null) return icon; } Image image = ImageLoader.loadFromUrl(myUrl, true, filter); icon = checkIcon(image, myUrl); if (icon != null) { if (icon.getIconWidth() < 50 && icon.getIconHeight() < 50) { realIcon = icon; } else { realIcon = new SoftReference<Icon>(icon); } myRealIcon = realIcon; } return icon == null ? EMPTY_ICON : icon; }