< prev index next >

src/java.desktop/share/classes/java/awt/MediaTracker.java

Print this page

        

*** 29,45 **** import java.awt.Image; import java.awt.image.ImageObserver; import sun.awt.image.MultiResolutionToolkitImage; /** ! * The <code>MediaTracker</code> class is a utility class to track * the status of a number of media objects. Media objects could * include audio clips as well as images, though currently only * images are supported. * <p> * To use a media tracker, create an instance of ! * <code>MediaTracker</code> and call its <code>addImage</code> * method for each image to be tracked. In addition, each image can * be assigned a unique identifier. This identifier controls the * priority order in which the images are fetched. It can also be used * to identify unique subsets of the images that can be waited on * independently. Images with a lower ID are loaded in preference to --- 29,45 ---- import java.awt.Image; import java.awt.image.ImageObserver; import sun.awt.image.MultiResolutionToolkitImage; /** ! * The {@code MediaTracker} class is a utility class to track * the status of a number of media objects. Media objects could * include audio clips as well as images, though currently only * images are supported. * <p> * To use a media tracker, create an instance of ! * {@code MediaTracker} and call its {@code addImage} * method for each image to be tracked. In addition, each image can * be assigned a unique identifier. This identifier controls the * priority order in which the images are fetched. It can also be used * to identify unique subsets of the images that can be waited on * independently. Images with a lower ID are loaded in preference to
*** 50,73 **** * Tracking an animated image * might not always be useful * due to the multi-part nature of animated image * loading and painting, * but it is supported. ! * <code>MediaTracker</code> treats an animated image * as completely loaded * when the first frame is completely loaded. ! * At that point, the <code>MediaTracker</code> * signals any waiters * that the image is completely loaded. ! * If no <code>ImageObserver</code>s are observing the image * when the first frame has finished loading, * the image might flush itself * to conserve resources * (see {@link Image#flush()}). * * <p> ! * Here is an example of using <code>MediaTracker</code>: * * <hr><blockquote><pre>{@code * import java.applet.Applet; * import java.awt.Color; * import java.awt.Image; --- 50,73 ---- * Tracking an animated image * might not always be useful * due to the multi-part nature of animated image * loading and painting, * but it is supported. ! * {@code MediaTracker} treats an animated image * as completely loaded * when the first frame is completely loaded. ! * At that point, the {@code MediaTracker} * signals any waiters * that the image is completely loaded. ! * If no {@code ImageObserver}s are observing the image * when the first frame has finished loading, * the image might flush itself * to conserve resources * (see {@link Image#flush()}). * * <p> ! * Here is an example of using {@code MediaTracker}: * * <hr><blockquote><pre>{@code * import java.applet.Applet; * import java.awt.Color; * import java.awt.Image;
*** 167,187 **** * @since 1.0 */ public class MediaTracker implements java.io.Serializable { /** ! * A given <code>Component</code> that will be * tracked by a media tracker where the image will * eventually be drawn. * * @serial * @see #MediaTracker(Component) */ Component target; /** ! * The head of the list of <code>Images</code> that is being ! * tracked by the <code>MediaTracker</code>. * * @serial * @see #addImage(Image, int) * @see #removeImage(Image) */ --- 167,187 ---- * @since 1.0 */ public class MediaTracker implements java.io.Serializable { /** ! * A given {@code Component} that will be * tracked by a media tracker where the image will * eventually be drawn. * * @serial * @see #MediaTracker(Component) */ Component target; /** ! * The head of the list of {@code Images} that is being ! * tracked by the {@code MediaTracker}. * * @serial * @see #addImage(Image, int) * @see #removeImage(Image) */
*** 275,289 **** * This method does not start loading the images if they are not * already loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> or <code>isErrorID</code> methods to * check for errors. ! * @return <code>true</code> if all images have finished loading, * have been aborted, or have encountered ! * an error; <code>false</code> otherwise * @see java.awt.MediaTracker#checkAll(boolean) * @see java.awt.MediaTracker#checkID * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID */ --- 275,289 ---- * This method does not start loading the images if they are not * already loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code isErrorAny} or {@code isErrorID} methods to * check for errors. ! * @return {@code true} if all images have finished loading, * have been aborted, or have encountered ! * an error; {@code false} otherwise * @see java.awt.MediaTracker#checkAll(boolean) * @see java.awt.MediaTracker#checkID * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID */
*** 293,315 **** /** * Checks to see if all images being tracked by this media tracker * have finished loading. * <p> ! * If the value of the <code>load</code> flag is <code>true</code>, * then this method starts loading any images that are not yet * being loaded. * <p> * If there is an error while loading or scaling an image, that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> and <code>isErrorID</code> methods to * check for errors. ! * @param load if <code>true</code>, start loading any * images that are not yet being loaded ! * @return <code>true</code> if all images have finished loading, * have been aborted, or have encountered ! * an error; <code>false</code> otherwise * @see java.awt.MediaTracker#checkID * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */ --- 293,315 ---- /** * Checks to see if all images being tracked by this media tracker * have finished loading. * <p> ! * If the value of the {@code load} flag is {@code true}, * then this method starts loading any images that are not yet * being loaded. * <p> * If there is an error while loading or scaling an image, that * image is considered to have finished loading. Use the ! * {@code isErrorAny} and {@code isErrorID} methods to * check for errors. ! * @param load if {@code true}, start loading any * images that are not yet being loaded ! * @return {@code true} if all images have finished loading, * have been aborted, or have encountered ! * an error; {@code false} otherwise * @see java.awt.MediaTracker#checkID * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */
*** 329,341 **** return done; } /** * Checks the error status of all of the images. ! * @return <code>true</code> if any of the images tracked * by this media tracker had an error during ! * loading; <code>false</code> otherwise * @see java.awt.MediaTracker#isErrorID * @see java.awt.MediaTracker#getErrorsAny */ public synchronized boolean isErrorAny() { MediaEntry cur = head; --- 329,341 ---- return done; } /** * Checks the error status of all of the images. ! * @return {@code true} if any of the images tracked * by this media tracker had an error during ! * loading; {@code false} otherwise * @see java.awt.MediaTracker#isErrorID * @see java.awt.MediaTracker#getErrorsAny */ public synchronized boolean isErrorAny() { MediaEntry cur = head;
*** 350,360 **** /** * Returns a list of all media that have encountered an error. * @return an array of media objects tracked by this * media tracker that have encountered ! * an error, or <code>null</code> if * there are none with errors * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsID */ public synchronized Object[] getErrorsAny() { --- 350,360 ---- /** * Returns a list of all media that have encountered an error. * @return an array of media objects tracked by this * media tracker that have encountered ! * an error, or {@code null} if * there are none with errors * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsID */ public synchronized Object[] getErrorsAny() {
*** 386,396 **** * method waits until all the images being tracked have finished * loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> or <code>isErrorID</code> methods to * check for errors. * @see java.awt.MediaTracker#waitForID(int) * @see java.awt.MediaTracker#waitForAll(long) * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID --- 386,396 ---- * method waits until all the images being tracked have finished * loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code isErrorAny} or {@code isErrorID} methods to * check for errors. * @see java.awt.MediaTracker#waitForID(int) * @see java.awt.MediaTracker#waitForAll(long) * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID
*** 403,422 **** /** * 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 <code>ms</code> argument has passed. * <p> * If there is an error while loading or scaling an image, then * that image is considered to have finished loading. Use the ! * <code>isErrorAny</code> or <code>isErrorID</code> methods to * check for errors. * @param ms the number of milliseconds to wait * for the loading to complete ! * @return <code>true</code> if all images were successfully ! * loaded; <code>false</code> otherwise * @see java.awt.MediaTracker#waitForID(int) * @see java.awt.MediaTracker#waitForAll(long) * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID * @exception InterruptedException if any thread has --- 403,422 ---- /** * 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 {@code ms} argument has passed. * <p> * If there is an error while loading or scaling an image, then * that image is considered to have finished loading. Use the ! * {@code isErrorAny} or {@code isErrorID} methods to * check for errors. * @param ms the number of milliseconds to wait * for the loading to complete ! * @return {@code true} if all images were successfully ! * loaded; {@code false} otherwise * @see java.awt.MediaTracker#waitForID(int) * @see java.awt.MediaTracker#waitForAll(long) * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#isErrorID * @exception InterruptedException if any thread has
*** 449,467 **** /** * Calculates and returns the bitwise inclusive <b>OR</b> of the * status of all media that are tracked by this media tracker. * <p> * Possible flags defined by the ! * <code>MediaTracker</code> class are <code>LOADING</code>, ! * <code>ABORTED</code>, <code>ERRORED</code>, and ! * <code>COMPLETE</code>. An image that hasn't started * loading has zero as its status. * <p> ! * If the value of <code>load</code> is <code>true</code>, then * this method starts loading any images that are not yet being loaded. * ! * @param load if <code>true</code>, start loading * any images that are not yet being loaded * @return the bitwise inclusive <b>OR</b> of the status of * all of the media being tracked * @see java.awt.MediaTracker#statusID(int, boolean) * @see java.awt.MediaTracker#LOADING --- 449,467 ---- /** * Calculates and returns the bitwise inclusive <b>OR</b> of the * status of all media that are tracked by this media tracker. * <p> * Possible flags defined by the ! * {@code MediaTracker} class are {@code LOADING}, ! * {@code ABORTED}, {@code ERRORED}, and ! * {@code COMPLETE}. An image that hasn't started * loading has zero as its status. * <p> ! * If the value of {@code load} is {@code true}, then * this method starts loading any images that are not yet being loaded. * ! * @param load if {@code true}, start loading * any images that are not yet being loaded * @return the bitwise inclusive <b>OR</b> of the status of * all of the media being tracked * @see java.awt.MediaTracker#statusID(int, boolean) * @see java.awt.MediaTracker#LOADING
*** 490,505 **** * This method does not start loading the images if they are not * already loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> or <code>isErrorID</code> methods to * check for errors. * @param id the identifier of the images to check ! * @return <code>true</code> if all images have finished loading, * have been aborted, or have encountered ! * an error; <code>false</code> otherwise * @see java.awt.MediaTracker#checkID(int, boolean) * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */ --- 490,505 ---- * This method does not start loading the images if they are not * already loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code isErrorAny} or {@code isErrorID} methods to * check for errors. * @param id the identifier of the images to check ! * @return {@code true} if all images have finished loading, * have been aborted, or have encountered ! * an error; {@code false} otherwise * @see java.awt.MediaTracker#checkID(int, boolean) * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */
*** 509,532 **** /** * Checks to see if all images tracked by this media tracker that * are tagged with the specified identifier have finished loading. * <p> ! * If the value of the <code>load</code> flag is <code>true</code>, * then this method starts loading any images that are not yet * being loaded. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> or <code>isErrorID</code> methods to * check for errors. * @param id the identifier of the images to check ! * @param load if <code>true</code>, start loading any * images that are not yet being loaded ! * @return <code>true</code> if all images have finished loading, * have been aborted, or have encountered ! * an error; <code>false</code> otherwise * @see java.awt.MediaTracker#checkID(int, boolean) * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */ --- 509,532 ---- /** * Checks to see if all images tracked by this media tracker that * are tagged with the specified identifier have finished loading. * <p> ! * If the value of the {@code load} flag is {@code true}, * then this method starts loading any images that are not yet * being loaded. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code isErrorAny} or {@code isErrorID} methods to * check for errors. * @param id the identifier of the images to check ! * @param load if {@code true}, start loading any * images that are not yet being loaded ! * @return {@code true} if all images have finished loading, * have been aborted, or have encountered ! * an error; {@code false} otherwise * @see java.awt.MediaTracker#checkID(int, boolean) * @see java.awt.MediaTracker#checkAll() * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) */
*** 551,563 **** /** * Checks the error status of all of the images tracked by this * media tracker with the specified identifier. * @param id the identifier of the images to check ! * @return <code>true</code> if any of the images with the * specified identifier had an error during ! * loading; <code>false</code> otherwise * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsID */ public synchronized boolean isErrorID(int id) { MediaEntry cur = head; --- 551,563 ---- /** * Checks the error status of all of the images tracked by this * media tracker with the specified identifier. * @param id the identifier of the images to check ! * @return {@code true} if any of the images with the * specified identifier had an error during ! * loading; {@code false} otherwise * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsID */ public synchronized boolean isErrorID(int id) { MediaEntry cur = head;
*** 577,587 **** * have encountered an error. * @param id the identifier of the images to check * @return an array of media objects tracked by this media * tracker with the specified identifier * that have encountered an error, or ! * <code>null</code> if there are none with errors * @see java.awt.MediaTracker#isErrorID * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsAny */ public synchronized Object[] getErrorsID(int id) { --- 577,587 ---- * have encountered an error. * @param id the identifier of the images to check * @return an array of media objects tracked by this media * tracker with the specified identifier * that have encountered an error, or ! * {@code null} if there are none with errors * @see java.awt.MediaTracker#isErrorID * @see java.awt.MediaTracker#isErrorAny * @see java.awt.MediaTracker#getErrorsAny */ public synchronized Object[] getErrorsID(int id) {
*** 617,627 **** * specified identifier. This method waits until all the images with * the specified identifier have finished loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>isErrorAny</code> and <code>isErrorID</code> methods to * check for errors. * @param id the identifier of the images to check * @see java.awt.MediaTracker#waitForAll * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int) --- 617,627 ---- * specified identifier. This method waits until all the images with * the specified identifier have finished loading. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code isErrorAny} and {@code isErrorID} methods to * check for errors. * @param id the identifier of the images to check * @see java.awt.MediaTracker#waitForAll * @see java.awt.MediaTracker#isErrorAny() * @see java.awt.MediaTracker#isErrorID(int)
*** 634,650 **** /** * 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 <code>ms</code> * argument has passed. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * <code>statusID</code>, <code>isErrorID</code>, and ! * <code>isErrorAny</code> methods to check for errors. * @param id the identifier of the images to check * @param ms the length of time, in milliseconds, to wait * for the loading to complete * @return {@code true} if the loading completed in time; * otherwise {@code false} --- 634,650 ---- /** * 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 {@code ms} * argument has passed. * <p> * If there is an error while loading or scaling an image, then that * image is considered to have finished loading. Use the ! * {@code statusID}, {@code isErrorID}, and ! * {@code isErrorAny} methods to check for errors. * @param id the identifier of the images to check * @param ms the length of time, in milliseconds, to wait * for the loading to complete * @return {@code true} if the loading completed in time; * otherwise {@code false}
*** 684,702 **** * Calculates and returns the bitwise inclusive <b>OR</b> of the * status of all media with the specified identifier that are * tracked by this media tracker. * <p> * Possible flags defined by the ! * <code>MediaTracker</code> class are <code>LOADING</code>, ! * <code>ABORTED</code>, <code>ERRORED</code>, and ! * <code>COMPLETE</code>. An image that hasn't started * loading has zero as its status. * <p> ! * If the value of <code>load</code> is <code>true</code>, then * this method starts loading any images that are not yet being loaded. * @param id the identifier of the images to check ! * @param load if <code>true</code>, start loading * any images that are not yet being loaded * @return the bitwise inclusive <b>OR</b> of the status of * all of the media with the specified * identifier that are being tracked * @see java.awt.MediaTracker#statusAll(boolean) --- 684,702 ---- * Calculates and returns the bitwise inclusive <b>OR</b> of the * status of all media with the specified identifier that are * tracked by this media tracker. * <p> * Possible flags defined by the ! * {@code MediaTracker} class are {@code LOADING}, ! * {@code ABORTED}, {@code ERRORED}, and ! * {@code COMPLETE}. An image that hasn't started * loading has zero as its status. * <p> ! * If the value of {@code load} is {@code true}, then * this method starts loading any images that are not yet being loaded. * @param id the identifier of the images to check ! * @param load if {@code true}, start loading * any images that are not yet being loaded * @return the bitwise inclusive <b>OR</b> of the status of * all of the media with the specified * identifier that are being tracked * @see java.awt.MediaTracker#statusAll(boolean)
*** 759,769 **** } /** * Removes the specified image from the specified tracking * ID of this media tracker. ! * All instances of <code>Image</code> being tracked * under the specified ID are removed regardless of scale. * @param image the image to be removed * @param id the tracking ID from which to remove the image * @see java.awt.MediaTracker#removeImage(java.awt.Image) * @see java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int) --- 759,769 ---- } /** * Removes the specified image from the specified tracking * ID of this media tracker. ! * All instances of {@code Image} being tracked * under the specified ID are removed regardless of scale. * @param image the image to be removed * @param id the tracking ID from which to remove the image * @see java.awt.MediaTracker#removeImage(java.awt.Image) * @see java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int)
< prev index next >