private static ImageIcon getIconFromData(final ComponentDescriptor<?> componentDescriptor, final int width) {
final String cacheKey = "remote: " + componentDescriptor.getDisplayName() + ",width=" + width;
final Image image = _imageManager.getImageFromCache(cacheKey);
ImageIcon imageIcon;
if (image == null) {
final HasIcon descriptorWithIcon = (HasIcon) componentDescriptor;
if (descriptorWithIcon.getIconData() == null || descriptorWithIcon.getIconData().length == 0) {
final ClassLoader classLoader = componentDescriptor.getComponentClass().getClassLoader();
final String imagePath = getDescriptorImagePath(componentDescriptor, classLoader, true);
if (imagePath == null) {
return null;
}
imageIcon = _imageManager.getImageIcon(imagePath, width, classLoader);
} else {
imageIcon = new ImageIcon(descriptorWithIcon.getIconData());
}
final BufferedImage bufferedImage = new BufferedImage(width, width, BufferedImage.TYPE_INT_ARGB);
bufferedImage.getGraphics().drawImage(imageIcon.getImage(), 0, 0, width, width, null);
imageIcon = new ImageIcon(bufferedImage);
_imageManager.storeImageIntoCache(cacheKey, imageIcon.getImage());
} else {
imageIcon = new ImageIcon(image);
}
return imageIcon;
}