java.awt
Class MediaTracker

java.lang.Object
  |
  +--java.awt.MediaTracker
All Implemented Interfaces:
Serializable

public class MediaTracker
extends Object
implements Serializable

Safe:

See Also:
Serialized Form

Field Summary
static int ABORTED
          Enabled: Flag indicating that the downloading of media was aborted.
static int COMPLETE
          Enabled: Flag indicating that the downloading of media was completed successfully.
(package private) static int DONE
           
static int ERRORED
          Enabled: Flag indicating that the downloading of media encountered an error.
(package private)  MediaEntry head
          The head of the list of Images that is being tracked by the MediaTracker.
static int LOADING
          Enabled: Flag indicating that media is currently being loaded.
private static long serialVersionUID
           
(package private)  Component target
          A given Component that will be tracked by a media tracker where the image will eventually be drawn.
 
Constructor Summary
MediaTracker(Component comp)
          Enabled: Creates a media tracker to track images for a given component.
 
Method Summary
 void addImage(Image image, int id)
          Enabled: Adds an image to the list of images being tracked by this media tracker.
 void addImage(Image image, int id, int w, int h)
          Enabled: Adds a scaled image to the list of images being tracked by this media tracker.
 boolean checkAll()
          Enabled: Checks to see if all images being tracked by this media tracker have finished loading.
 boolean checkAll(boolean load)
          Enabled: Checks to see if all images being tracked by this media tracker have finished loading.
private  boolean checkAll(boolean load, boolean verify)
           
 boolean checkID(int id)
          Enabled: Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.
 boolean checkID(int id, boolean load)
          Enabled: Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.
private  boolean checkID(int id, boolean load, boolean verify)
           
 Object[] getErrorsAny()
          Enabled: Returns a list of all media that have encountered an error.
 Object[] getErrorsID(int id)
          Enabled: Returns a list of media with the specified ID that have encountered an error.
 boolean isErrorAny()
          Enabled: Checks the error status of all of the images.
 boolean isErrorID(int id)
          Enabled: Checks the error status of all of the images tracked by this media tracker with the specified identifier.
 void removeImage(Image image)
          Enabled: Removes the specified image from this media tracker.
 void removeImage(Image image, int id)
          Enabled: Removes the specified image from the specified tracking ID of this media tracker.
 void removeImage(Image image, int id, int width, int height)
          Enabled: Removes the specified image with the specified width, height, and ID from this media tracker.
(package private)  void setDone()
           
 int statusAll(boolean load)
          Enabled: Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker.
private  int statusAll(boolean load, boolean verify)
           
 int statusID(int id, boolean load)
          Enabled: Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.
private  int statusID(int id, boolean load, boolean verify)
           
 void waitForAll()
          Enabled: Starts loading all images tracked by this media tracker.
 boolean waitForAll(long ms)
          Enabled: Starts loading all images tracked by this media tracker.
 void waitForID(int id)
          Enabled: Starts loading all images tracked by this media tracker with the specified identifier.
 boolean waitForID(int id, long ms)
          Enabled: Starts loading all images tracked by this media tracker with the specified identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target

Component target
A given Component that will be tracked by a media tracker where the image will eventually be drawn.

See Also:
MediaTracker()

head

MediaEntry head
The head of the list of Images that is being tracked by the MediaTracker.

See Also:
addImage(), removeImage()

serialVersionUID

private static final long serialVersionUID

LOADING

public static final int LOADING
Enabled: Flag indicating that media is currently being loaded.

See Also:
java.awt.MediaTracker#statusAll, java.awt.MediaTracker#statusID

ABORTED

public static final int ABORTED
Enabled: Flag indicating that the downloading of media was aborted.

See Also:
java.awt.MediaTracker#statusAll, java.awt.MediaTracker#statusID

ERRORED

public static final int ERRORED
Enabled: Flag indicating that the downloading of media encountered an error.

See Also:
java.awt.MediaTracker#statusAll, java.awt.MediaTracker#statusID

COMPLETE

public static final int COMPLETE
Enabled: Flag indicating that the downloading of media was completed successfully.

See Also:
java.awt.MediaTracker#statusAll, java.awt.MediaTracker#statusID

DONE

static final int DONE
Constructor Detail

MediaTracker

public MediaTracker(Component comp)
Enabled: Creates a media tracker to track images for a given component.

Parameters:
comp - the component on which the images will eventually be drawn
Method Detail

addImage

public void addImage(Image image,
                     int id)
Enabled: Adds an image to the list of images being tracked by this media tracker. The image will eventually be rendered at its default (unscaled) size.

Parameters:
image - the image to be tracked
id - an identifier used to track this image

addImage

public void addImage(Image image,
                     int id,
                     int w,
                     int h)
Enabled: Adds a scaled image to the list of images being tracked by this media tracker. The image will eventually be rendered at the indicated width and height.

Parameters:
image - the image to be tracked
id - an identifier that can be used to track this image
w - the width at which the image is rendered
h - the height at which the image is rendered

checkAll

public boolean checkAll()
Enabled: Checks to see if all images being tracked by this media tracker have finished loading.

This method does not start loading the images if they are not already loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
java.awt.MediaTracker#checkAll(boolean), java.awt.MediaTracker#checkID, java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#isErrorID

checkAll

public boolean checkAll(boolean load)
Enabled: Checks to see if all images being tracked by this media tracker have finished loading.

If the value of the load flag is true, then this method starts loading any images that are not yet being loaded.

If there is an error while loading or scaling an image, that image is considered to have finished loading. Use the isErrorAny and isErrorID methods to check for errors.

Parameters:
load - if true, start loading any images that are not yet being loaded
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
java.awt.MediaTracker#checkID, java.awt.MediaTracker#checkAll(), java.awt.MediaTracker#isErrorAny(), java.awt.MediaTracker#isErrorID(int)

checkAll

private boolean checkAll(boolean load,
                         boolean verify)

isErrorAny

public boolean isErrorAny()
Enabled: Checks the error status of all of the images.

Returns:
true if any of the images tracked by this media tracker had an error during loading; false otherwise
See Also:
java.awt.MediaTracker#isErrorID, java.awt.MediaTracker#getErrorsAny

getErrorsAny

public Object[] getErrorsAny()
Enabled: Returns a list of all media that have encountered an error.

Returns:
an array of media objects tracked by this media tracker that have encountered an error, or null if there are none with errors
See Also:
java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#getErrorsID

waitForAll

public void waitForAll()
                throws InterruptedException
Enabled: Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

InterruptedException
See Also:
java.awt.MediaTracker#waitForID(int), java.awt.MediaTracker#waitForAll(long), java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#isErrorID

waitForAll

public boolean waitForAll(long ms)
                   throws InterruptedException
Enabled: Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading, or until the length of time specified in milliseconds by the ms argument has passed.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
ms - the number of milliseconds to wait for the loading to complete
Returns:
true if all images were successfully loaded; false otherwise
InterruptedException
See Also:
java.awt.MediaTracker#waitForID(int), java.awt.MediaTracker#waitForAll(long), java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#isErrorID

statusAll

public int statusAll(boolean load)
Enabled: Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker.

Possible flags defined by the MediaTracker class are LOADING, ABORTED, ERRORED, and COMPLETE. An image that hasn't started loading has zero as its status.

If the value of load is true, then this method starts loading any images that are not yet being loaded.

Parameters:
load - if true, start loading any images that are not yet being loaded
Returns:
the bitwise inclusive OR of the status of all of the media being tracked
See Also:
java.awt.MediaTracker#statusID(int, boolean), java.awt.MediaTracker#LOADING, java.awt.MediaTracker#ABORTED, java.awt.MediaTracker#ERRORED, java.awt.MediaTracker#COMPLETE

statusAll

private int statusAll(boolean load,
                      boolean verify)

checkID

public boolean checkID(int id)
Enabled: Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.

This method does not start loading the images if they are not already loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
java.awt.MediaTracker#checkID(int, boolean), java.awt.MediaTracker#checkAll(), java.awt.MediaTracker#isErrorAny(), java.awt.MediaTracker#isErrorID(int)

checkID

public boolean checkID(int id,
                       boolean load)
Enabled: Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading.

If the value of the load flag is true, then this method starts loading any images that are not yet being loaded.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny or isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
load - if true, start loading any images that are not yet being loaded
Returns:
true if all images have finished loading, have been aborted, or have encountered an error; false otherwise
See Also:
java.awt.MediaTracker#checkID(int, boolean), java.awt.MediaTracker#checkAll(), java.awt.MediaTracker#isErrorAny(), java.awt.MediaTracker#isErrorID(int)

checkID

private boolean checkID(int id,
                        boolean load,
                        boolean verify)

isErrorID

public boolean isErrorID(int id)
Enabled: Checks the error status of all of the images tracked by this media tracker with the specified identifier.

Parameters:
id - the identifier of the images to check
Returns:
true if any of the images with the specified identifier had an error during loading; false otherwise
See Also:
java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#getErrorsID

getErrorsID

public Object[] getErrorsID(int id)
Enabled: Returns a list of media with the specified ID that have encountered an error.

Parameters:
id - the identifier of the images to check
Returns:
an array of media objects tracked by this media tracker with the specified identifier that have encountered an error, or null if there are none with errors
See Also:
java.awt.MediaTracker#isErrorID, java.awt.MediaTracker#isErrorAny, java.awt.MediaTracker#getErrorsAny

waitForID

public void waitForID(int id)
               throws InterruptedException
Enabled: Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the isErrorAny and isErrorID methods to check for errors.

Parameters:
id - the identifier of the images to check
InterruptedException
See Also:
java.awt.MediaTracker#waitForAll, java.awt.MediaTracker#isErrorAny(), java.awt.MediaTracker#isErrorID(int)

waitForID

public boolean waitForID(int id,
                         long ms)
                  throws InterruptedException
Enabled: Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading, or until the length of time specified in milliseconds by the ms argument has passed.

If there is an error while loading or scaling an image, then that image is considered to have finished loading. Use the statusID, isErrorID, and isErrorAny methods to check for errors.

Parameters:
id - the identifier of the images to check
ms - the length of time, in milliseconds, to wait for the loading to complete
InterruptedException
See Also:
java.awt.MediaTracker#waitForAll, java.awt.MediaTracker#waitForID(int), java.awt.MediaTracker#statusID, java.awt.MediaTracker#isErrorAny(), java.awt.MediaTracker#isErrorID(int)

statusID

public int statusID(int id,
                    boolean load)
Enabled: Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker.

Possible flags defined by the MediaTracker class are LOADING, ABORTED, ERRORED, and COMPLETE. An image that hasn't started loading has zero as its status.

If the value of load is true, then this method starts loading any images that are not yet being loaded.

Parameters:
id - the identifier of the images to check
load - if true, start loading any images that are not yet being loaded
Returns:
the bitwise inclusive OR of the status of all of the media with the specified identifier that are being tracked
See Also:
java.awt.MediaTracker#statusAll(boolean), java.awt.MediaTracker#LOADING, java.awt.MediaTracker#ABORTED, java.awt.MediaTracker#ERRORED, java.awt.MediaTracker#COMPLETE

statusID

private int statusID(int id,
                     boolean load,
                     boolean verify)

removeImage

public void removeImage(Image image)
Enabled: Removes the specified image from this media tracker. All instances of the specified image are removed, regardless of scale or ID.

Parameters:
image - the image to be removed
Since:
JDK1.1
See Also:
java.awt.MediaTracker#removeImage(java.awt.Image, int), java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int)

removeImage

public void removeImage(Image image,
                        int id)
Enabled: Removes the specified image from the specified tracking ID of this media tracker. All instances of Image being tracked under the specified ID are removed regardless of scale.

Parameters:
image - the image to be removed
id - the tracking ID frrom which to remove the image
Since:
JDK1.1
See Also:
java.awt.MediaTracker#removeImage(java.awt.Image), java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int)

removeImage

public void removeImage(Image image,
                        int id,
                        int width,
                        int height)
Enabled: Removes the specified image with the specified width, height, and ID from this media tracker. Only the specified instance (with any duplicates) is removed.

Parameters:
image - the image to be removed
id - the tracking ID from which to remove the image
width - the width to remove (-1 for unscaled)
height - the height to remove (-1 for unscaled)
Since:
JDK1.1
See Also:
java.awt.MediaTracker#removeImage(java.awt.Image), java.awt.MediaTracker#removeImage(java.awt.Image, int)

setDone

void setDone()


comments?