Methods Summary |
---|
public void | addRasterImageConsumer(java.lang.String absoluteURI, RasterImageConsumer imageNode)In cases where the ImageLoader may update the images associated to a URI,
RasterImageConsumer interested in updates need to register their interest
throught this method.
|
public boolean | allowsRelativeURI()Determines whether this ImageLoader can handle relative uri's
return false;
|
public void | documentLoaded(DocumentNode doc)Some ImageLoader implementations may wish to wait until the end of the
Document load to start retrieving resources. This method notifies
the implementation that the DocumentNode completed loading successfully.
// Do nothing. The DefaultImageLoader implementation loads image
// as soon as they are notified in needsURI calls.
|
public com.sun.perseus.j2d.RasterImage | getBrokenImage()Returns the image that should be used to represent an
image which could not be loaded.
return loaderUtil.getBrokenImage();
|
public com.sun.perseus.j2d.RasterImage | getImageAndWait(java.lang.String uri)Requests the given image. This call blocks until an image is
returned.
// If we are dealing with a data URI, decode the image
// now. Data URIs do not go in the cache.
if (loaderUtil.isDataURI(uri)) {
return loaderUtil.getEmbededImage(uri);
}
// We are dealing with a regular URI which requires IO.
// The image might already be in the loading queue if
// a call to needsURI was made.
synchronized (cache) {
RasterImage img = (RasterImage) cache.get(uri);
if (img != null) {
return img;
}
}
// The URI has not been retrieved at all or the
// ImageLoadRunnable has not completed yet. We
// simply preempt a new ImageLoadRunnable. When that
// one complete, we will be sure the image is in
// the cache.
ImageLoadRunnable loader =
new ImageLoadRunnable(uri);
try {
loadingQueue.preemptAndWait(loader, null);
} catch (InterruptedException ie) {
// We were interrupted while waiting for the image.
// Return brokenImage
return loaderUtil.getBrokenImage();
}
synchronized (cache) {
return (RasterImage) cache.get(uri);
}
|
public void | getImageLater(java.lang.String uri, RasterImageConsumer imageNode)Requests the given image. This call returns immediately and
the image is set on the input ImageNode when the
image becomes available.
// Only load later images which have not been loaded yet
// and which are not data URIs.
if (loaderUtil.isDataURI(uri)) {
imageNode.setImage(loaderUtil.getEmbededImage(uri), uri);
return;
}
RasterImage img = null;
synchronized (cache) {
img = (RasterImage) cache.get(uri);
}
if (img != null) {
imageNode.setImage(img, uri);
return;
}
ImageLoadRunnable loader = new ImageLoadRunnable(uri, imageNode);
loadingQueue.invokeLater(loader, null);
|
public com.sun.perseus.j2d.RasterImage | getLoadingImage()Returns the image that should be used to represent
an image which is loading.
return loaderUtil.getLoadingImage();
|
public void | needsURI(java.lang.String absoluteURI)Notifies the URILoader that the given uri will be needed.
// Do not load base64 images as we do not want to
// store the base64 string in the cache, because it
// might be huge.
//
// Correct content should not have the same base64
// string duplicated. Rather, the same image element
// can be referenced by a use element.
if (!loaderUtil.isDataURI(absoluteURI)) {
// Check if the image is currently loaded
synchronized (cache) {
if (cache.get(absoluteURI) == null) {
// Start loading the image now so that it is ready when
// we need it for rendering.
loadingQueue.invokeLater
(new ImageLoadRunnable(absoluteURI), null);
}
}
}
|
public void | removeRasterImageConsumer(java.lang.String absoluteURI, RasterImageConsumer imageNode)In cases where the ImageLoader may update the images associated to a URI,
RasterImageConsumer interested in updates need to de-register their
interest throught this method.
|
public java.lang.String | resolveURI(java.lang.String uri, java.lang.String baseURI)Resolves the input relative and base URI into an absolute URI
which can be used in subsequent calls to needsURI, getImageAndWait
or getImageLater calls.
if (uri == null) {
return null;
}
// Do not load base64 images as we do not want to
// store the base64 string in the cache, because it
// might be huge.
if (loaderUtil.isDataURI(uri)) {
return uri;
}
try {
return URLResolver.resolve(baseURI, uri);
} catch (IllegalArgumentException iae) {
return null;
}
|
public void | waitForAll()Utility method. Used to wait until all pending load operations are
complete.
loadingQueue.invokeAndWait(new Runnable() { public void run() { } },
null);
|