Package org.jfree.util
Class WaitingImageObserver
- java.lang.Object
-
- org.jfree.util.WaitingImageObserver
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.io.Serializable
,java.lang.Cloneable
public class WaitingImageObserver extends java.lang.Object implements java.awt.image.ImageObserver, java.io.Serializable, java.lang.Cloneable
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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WaitingImageObserver(java.awt.Image image)
Creates a newImageObserver
for the given
Image
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
Deprecated.cloning may lock down the observerboolean
imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
Callback function used by AWT to inform that more data is available.boolean
isError()
Returns true if there is an error condition, and false otherwise.boolean
isLoadingComplete()
Returnstrue
if loading is complete, andfalse
otherwise.void
waitImageLoaded()
The workerthread.
-
-
-
Constructor Detail
-
WaitingImageObserver
public WaitingImageObserver(java.awt.Image image)
Creates a newImageObserver
for the given
Image
. The observer has to be started by an external thread.
- Parameters:
image
- the image to observe (null
not permitted).
-
-
Method Detail
-
imageUpdate
public boolean imageUpdate(java.awt.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:
imageUpdate
in interfacejava.awt.image.ImageObserver
- 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:
false
if the infoflags indicate that the image is completely loaded;true
otherwise.
-
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.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Deprecated.cloning may lock down the observerClones this WaitingImageObserver.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone.
- Throws:
java.lang.CloneNotSupportedException
- this should never happen.
-
isLoadingComplete
public boolean isLoadingComplete()
Returnstrue
if loading is complete, andfalse
otherwise.- Returns:
- A boolean.
-
isError
public boolean isError()
Returns true if there is an error condition, and false otherwise.- Returns:
- A boolean.
-
-