// if set for synchronous mode, block for image to load.
! if ( !m_asynch ) {
waitForImage(image);
addImage(imageLocation, image);
} else {
--- 120,126 ----
image = Toolkit.getDefaultToolkit().createImage(imageURL);
// if set for synchronous mode, block for image to load.
! if ( m_asynch ) {
waitForImage(image);
addImage(imageLocation, image);
} else {
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The ImageFactory loads images asynchronously (loads them in the background), so it will return null until the image has been loaded. This is the intended behavior. However, I will add new methods for toggling the synchronous/asynchronous state so that one can cause the image factory to block rather than load in the background. Just call setAsynchronous(false) first, then try the example above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following code highlights the bug (make sure someimage.jpeg exist in current directory):
import prefuse.render.ImageFactory;
import java.awt.Image;
class TestImageFactory {
public static void main(String args[]) {
ImageFactory images = new ImageFactory();
Image image = images.getImage("someimage.jpeg");
assert image != null; // This test fails (with assertion enabled, of course).
}
}
The following patch should fix it.
*** prefuse/render/ImageFactory.java.orig 2007-03-01 01:03:00.000000000 +0800
--- prefuse/render/ImageFactory.java 2007-03-01 01:02:59.000000000 +0800
***************
*** 120,126 ****
image = Toolkit.getDefaultToolkit().createImage(imageURL);
// if set for synchronous mode, block for image to load.
! if ( !m_asynch ) {
waitForImage(image);
addImage(imageLocation, image);
} else {
--- 120,126 ----
image = Toolkit.getDefaultToolkit().createImage(imageURL);
// if set for synchronous mode, block for image to load.
! if ( m_asynch ) {
waitForImage(image);
addImage(imageLocation, image);
} else {
The ImageFactory loads images asynchronously (loads them in the background), so it will return null until the image has been loaded. This is the intended behavior. However, I will add new methods for toggling the synchronous/asynchronous state so that one can cause the image factory to block rather than load in the background. Just call setAsynchronous(false) first, then try the example above.