|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.4.2
java.awt
|
Field Summary | |
static int |
ABORTED
Flag indicating that the downloading of media was aborted. |
static int |
COMPLETE
Flag indicating that the downloading of media was completed successfully. |
static int |
ERRORED
Flag indicating that the downloading of media encountered an error. |
static int |
LOADING
Flag indicating that media is currently being loaded. |
Constructor Summary | |
MediaTracker(Component comp)
Creates a media tracker to track images for a given component. |
Method Summary | |
void |
addImage(Image image,
int id)
Adds an image to the list of images being tracked by this media tracker. |
void |
addImage(Image image,
int id,
int w,
int h)
Adds a scaled image to the list of images being tracked by this media tracker. |
boolean |
checkAll()
Checks to see if all images being tracked by this media tracker have finished loading. |
boolean |
checkAll(boolean load)
Checks to see if all images being tracked by this media tracker have finished loading. |
boolean |
checkID(int id)
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)
Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading. |
Object[] |
getErrorsAny()
Returns a list of all media that have encountered an error. |
Object[] |
getErrorsID(int id)
Returns a list of media with the specified ID that have encountered an error. |
boolean |
isErrorAny()
Checks the error status of all of the images. |
boolean |
isErrorID(int id)
Checks the error status of all of the images tracked by this media tracker with the specified identifier. |
void |
removeImage(Image image)
Removes the specified image from this media tracker. |
void |
removeImage(Image image,
int id)
Removes the specified image from the specified tracking ID of this media tracker. |
void |
removeImage(Image image,
int id,
int width,
int height)
Removes the specified image with the specified width, height, and ID from this media tracker. |
int |
statusAll(boolean load)
Calculates and returns the bitwise inclusive OR of the status of all media that are tracked by this media tracker. |
int |
statusID(int id,
boolean load)
Calculates and returns the bitwise inclusive OR of the status of all media with the specified identifier that are tracked by this media tracker. |
void |
waitForAll()
Starts loading all images tracked by this media tracker. |
boolean |
waitForAll(long ms)
Starts loading all images tracked by this media tracker. |
void |
waitForID(int id)
Starts loading all images tracked by this media tracker with the specified identifier. |
boolean |
waitForID(int id,
long ms)
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 |
public static final int LOADING
public static final int ABORTED
public static final int ERRORED
public static final int COMPLETE
Constructor Detail |
public MediaTracker(Component comp)
comp
- the component on which the images
will eventually be drawnMethod Detail |
public void addImage(Image image, int id)
image
- the image to be trackedid
- an identifier used to track this imagepublic void addImage(Image image, int id, int w, int h)
image
- the image to be trackedid
- an identifier that can be used to track this imagew
- the width at which the image is renderedh
- the height at which the image is renderedpublic boolean checkAll()
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.
true
if all images have finished loading,
have been aborted, or have encountered
an error; false
otherwisecheckAll(boolean)
,
checkID(int)
,
isErrorAny()
,
isErrorID(int)
public boolean checkAll(boolean load)
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.
load
- if true
, start loading any
images that are not yet being loaded
true
if all images have finished loading,
have been aborted, or have encountered
an error; false
otherwisecheckID(int)
,
checkAll()
,
isErrorAny()
,
isErrorID(int)
public boolean isErrorAny()
true
if any of the images tracked
by this media tracker had an error during
loading; false
otherwiseisErrorID(int)
,
getErrorsAny()
public Object[] getErrorsAny()
null
if
there are none with errorsisErrorAny()
,
getErrorsID(int)
public void waitForAll() throws InterruptedException
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
- if another thread has
interrupted this threadwaitForID(int)
,
waitForAll(long)
,
isErrorAny()
,
isErrorID(int)
public boolean waitForAll(long ms) throws InterruptedException
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.
ms
- the number of milliseconds to wait
for the loading to complete
true
if all images were successfully
loaded; false
otherwise
InterruptedException
- if another thread has
interrupted this thread.waitForID(int)
,
waitForAll(long)
,
isErrorAny()
,
isErrorID(int)
public int statusAll(boolean load)
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.
load
- if true
, start loading
any images that are not yet being loaded
statusID(int, boolean)
,
LOADING
,
ABORTED
,
ERRORED
,
COMPLETE
public boolean checkID(int id)
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.
id
- the identifier of the images to check
true
if all images have finished loading,
have been aborted, or have encountered
an error; false
otherwisecheckID(int, boolean)
,
checkAll()
,
isErrorAny()
,
isErrorID(int)
public boolean checkID(int id, boolean load)
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.
id
- the identifier of the images to checkload
- if true
, start loading any
images that are not yet being loaded
true
if all images have finished loading,
have been aborted, or have encountered
an error; false
otherwisecheckID(int, boolean)
,
checkAll()
,
isErrorAny()
,
isErrorID(int)
public boolean isErrorID(int id)
id
- the identifier of the images to check
true
if any of the images with the
specified identifier had an error during
loading; false
otherwiseisErrorAny()
,
getErrorsID(int)
public Object[] getErrorsID(int id)
id
- the identifier of the images to check
null
if there are none with errorsisErrorID(int)
,
isErrorAny()
,
getErrorsAny()
public void waitForID(int id) throws InterruptedException
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.
id
- the identifier of the images to check
InterruptedException
- if another thread has
interrupted this thread.waitForAll()
,
isErrorAny()
,
isErrorID(int)
public boolean waitForID(int id, long ms) throws InterruptedException
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.
id
- the identifier of the images to checkms
- the length of time, in milliseconds, to wait
for the loading to complete
InterruptedException
- if another thread has
interrupted this thread.waitForAll()
,
waitForID(int)
,
statusID(int, boolean)
,
isErrorAny()
,
isErrorID(int)
public int statusID(int id, boolean load)
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.
id
- the identifier of the images to checkload
- if true
, start loading
any images that are not yet being loaded
statusAll(boolean)
,
LOADING
,
ABORTED
,
ERRORED
,
COMPLETE
public void removeImage(Image image)
image
- the image to be removedremoveImage(java.awt.Image, int)
,
removeImage(java.awt.Image, int, int, int)
public void removeImage(Image image, int id)
Image
being tracked
under the specified ID are removed regardless of scale.
image
- the image to be removedid
- the tracking ID frrom which to remove the imageremoveImage(java.awt.Image)
,
removeImage(java.awt.Image, int, int, int)
public void removeImage(Image image, int id, int width, int height)
image
- the image to be removedid
- the tracking ID from which to remove the imagewidth
- the width to remove (-1 for unscaled)height
- the height to remove (-1 for unscaled)removeImage(java.awt.Image)
,
removeImage(java.awt.Image, int)