Class WaitingImageObserver
- java.lang.Object
-
- org.pentaho.reporting.libraries.base.util.WaitingImageObserver
-
- All Implemented Interfaces:
ImageObserver
public class WaitingImageObserver extends Object implements ImageObserver
This image observer blocks until the image is completely loaded. AWT defers the loading of images until they are painted on a graphic. While printing reports it is not very nice, not to know whether a image was completely loaded, so this observer forces the loading of the image until a final state (either ALLBITS, ABORT or ERROR) is reached.- Author:
- Thomas Morgner
-
-
Field Summary
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description WaitingImageObserver(Image image)Creates a newImageObserverfor the givenImage.WaitingImageObserver(Image image, long maxLoadTime)Creates a newImageObserverfor the givenImage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanimageUpdate(Image img, int infoflags, int x, int y, int width, int height)Callback function used by AWT to inform that more data is available.booleanisError()Returns true if there is an error condition, and false otherwise.booleanisLoadingComplete()Checks whether the loading is complete.voidwaitImageLoaded()The workerthread.
-
-
-
Constructor Detail
-
WaitingImageObserver
public WaitingImageObserver(Image image)
Creates a newImageObserverfor the givenImage. The observer has to be started by an external thread.- Parameters:
image- the image to observe (nullnot permitted).
-
WaitingImageObserver
public WaitingImageObserver(Image image, long maxLoadTime)
Creates a newImageObserverfor the givenImage. The observer has to be started by an external thread.- Parameters:
image- the image to observe (nullnot permitted).
-
-
Method Detail
-
imageUpdate
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
Callback function used by AWT to inform that more data is available. The observer waits until either all data is loaded or AWT signals that the image cannot be loaded.- Specified by:
imageUpdatein interfaceImageObserver- Parameters:
img- the image being observed.infoflags- the bitwise inclusive OR of the following flags:WIDTH,HEIGHT,PROPERTIES,SOMEBITS,FRAMEBITS,ALLBITS,ERROR,ABORT.x- the x coordinate.y- the y coordinate.width- the width.height- the height.- Returns:
falseif the infoflags indicate that the image is completely loaded;trueotherwise.
-
waitImageLoaded
public void waitImageLoaded()
The workerthread. Simply draws the image to a BufferedImage's Graphics-Object and waits for the AWT to load the image.
-
isLoadingComplete
public boolean isLoadingComplete()
Checks whether the loading is complete.- Returns:
- true, if the loading is complete, false otherwise.
-
isError
public boolean isError()
Returns true if there is an error condition, and false otherwise.- Returns:
- A boolean.
-
-