1 17 18 19 20 package org.apache.fop.image; 21 22 import org.apache.fop.apps.FOUserAgent; 23 24 27 class ImageLoader { 28 29 private String url; 30 private ImageCache cache; 31 private boolean valid = true; 32 private FOUserAgent userAgent; 33 private FopImage image = null; 34 35 41 public ImageLoader(String url, ImageCache cache, FOUserAgent ua) { 42 this.url = url; 43 this.cache = cache; 44 this.userAgent = ua; 45 } 46 47 51 public synchronized FopImage loadImage() { 52 if (!valid || image != null) { 53 return image; 54 } 55 ImageFactory imageFactory = userAgent.getFactory().getImageFactory(); 56 image = imageFactory.loadImage(url, userAgent); 57 if (image == null) { 58 cache.invalidateImage(url, userAgent); 59 valid = false; 60 } 61 return image; 62 } 63 64 } 65 | Popular Tags |