}
private static Image getImage(ResizableIcon icon, int size) {
icon.setDimension(new Dimension(size, size));
if (icon instanceof AsynchronousLoading) {
AsynchronousLoading async = (AsynchronousLoading) icon;
if (async.isLoading()) {
final CountDownLatch latch = new CountDownLatch(1);
final boolean[] status = new boolean[1];
AsynchronousLoadListener all = new AsynchronousLoadListener() {
public void completed(boolean success) {
status[0] = success;
latch.countDown();
}
};
async.addAsynchronousLoadListener(all);
try {
latch.await();
} catch (InterruptedException ie) {
}
async.removeAsynchronousLoadListener(all);
if (!status[0]) {
return null;
}
if (async.isLoading()) {
return null;
}
}
}
Image result = FlamingoUtilities.getBlankImage(size, size);