java.awt
Class MediaTracker
- Serializable
This class is used for keeping track of the status of various media
objects.
Media objects are tracked by assigning them an ID. It is possible
to assign the same ID to mutliple objects, effectivly grouping them
together. In this case the status flags (
statusID(int,boolean)
) and error flag
(@link #isErrorID} and
getErrorsID(int)
) are ORed together. This
means that you cannot say exactly which media object has which status,
at most you can say that there
are certain media objects with
some certain status.
At the moment only images are supported by this class.
static int | ABORTED - Indicates that the loading operation has been aborted.
|
static int | COMPLETE - Indicates that the media has been successfully and completely loaded.
|
static int | ERRORED - Indicates that an error has occured during loading of the media.
|
static int | LOADING - Indicates that the media is still loading.
|
void | addImage(Image image, int id) - Adds an image to the tracker with the specified
ID .
|
void | addImage(Image image, int id, int width, int height) - Adds an image to the tracker with the specified
ID .
|
boolean | checkAll() - Checks if all media objects have finished loading, i.e. are
COMPLETE , ABORTED or ERRORED .
|
boolean | checkAll(boolean load) - Checks if all media objects have finished loading, i.e. are
COMPLETE , ABORTED or ERRORED .
|
boolean | checkID(int id) - Checks if the media objects with
ID have completed loading.
|
boolean | checkID(int id, boolean load) - Checks if the media objects with
ID have completed loading.
|
Object[] | getErrorsAny() - Returns all media objects that have encountered errors during loading.
|
Object[] | getErrorsID(int id) - Returns all media objects with the specified ID that have encountered
an error.
|
boolean | isErrorAny() - Checks if any of the registered media objects has encountered an error
during loading.
|
boolean | isErrorID(int id) - Returns
true if any of the media objects with ID
have encountered errors during loading, false otherwise.
|
void | removeImage(Image image) - Removes an image from this MediaTracker.
|
void | removeImage(Image image, int id) - Removes an image with the specified ID from this MediaTracker.
|
void | removeImage(Image image, int id, int width, int height) - Removes an image with the specified ID and scale from this MediaTracker.
|
int | statusAll(boolean load) - Returns the status flags of all registered media objects ORed together.
|
int | statusID(int id, boolean load) - Returns the status flags of the media objects with the specified ID
ORed together.
|
void | waitForAll() - Waits for all media objects to finish loading, either by completing
successfully or by aborting or encountering an error.
|
boolean | waitForAll(long ms) - Waits for all media objects to finish loading, either by completing
successfully or by aborting or encountering an error.
|
void | waitForID(int id) - Waits for all media objects with the specified ID to finish loading,
either by completing successfully or by aborting or encountering an error.
|
boolean | waitForID(int id, long ms) - Waits for all media objects with the specified ID to finish loading,
either by completing successfully or by aborting or encountering an error.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
ABORTED
public static final int ABORTED
Indicates that the loading operation has been aborted.
COMPLETE
public static final int COMPLETE
Indicates that the media has been successfully and completely loaded.
ERRORED
public static final int ERRORED
Indicates that an error has occured during loading of the media.
LOADING
public static final int LOADING
Indicates that the media is still loading.
MediaTracker
public MediaTracker(Component c)
Constructs a new MediaTracker for the component c
. The
component should be the component that uses the media (i.e. draws it).
c
- the Component that wants to use the media
addImage
public void addImage(Image image,
int id)
Adds an image to the tracker with the specified ID
.
image
- the image to be addedid
- the ID of the tracker list to which the image is added
addImage
public void addImage(Image image,
int id,
int width,
int height)
Adds an image to the tracker with the specified ID
.
The image is expected to be rendered with the specified width and
height.
image
- the image to be addedid
- the ID of the tracker list to which the image is addedwidth
- the width of the imageheight
- the height of the image
checkAll
public boolean checkAll()
Checks if all media objects have finished loading, i.e. are
COMPLETE
,
ABORTED
or
ERRORED
.
If the media objects are not already loading, a call to this
method does
not start loading. This is equivalent to
a call to
checkAll(false)
.
- if all media objects have finished loading either by beeing
complete, have been aborted or errored.
checkAll
public boolean checkAll(boolean load)
Checks if all media objects have finished loading, i.e. are
COMPLETE
,
ABORTED
or
ERRORED
.
If the media objects are not already loading, and
load
is
true
then a call to this
method starts loading the media objects.
load
- if true
this method starts loading objects
that are not already loading
- if all media objects have finished loading either by beeing
complete, have been aborted or errored.
checkID
public boolean checkID(int id)
Checks if the media objects with ID
have completed loading.
id
- the ID of the media objects to check
true
if all media objects with ID
have successfully finished
checkID
public boolean checkID(int id,
boolean load)
Checks if the media objects with ID
have completed loading.
If load
is true
then media objects that
are not already loading will be started to load.
id
- the ID of the media objects to checkload
- if set to true
then media objects that are
not already loading are started
true
if all media objects with ID
have successfully finished
getErrorsAny
public Object[] getErrorsAny()
Returns all media objects that have encountered errors during loading.
- an array of all media objects that have encountered errors
or
null
if there were no errors at all
getErrorsID
public Object[] getErrorsID(int id)
Returns all media objects with the specified ID that have encountered
an error.
id
- the ID of the media objects to check
- an array of all media objects with the specified ID that
have encountered an error
isErrorAny
public boolean isErrorAny()
Checks if any of the registered media objects has encountered an error
during loading.
true
if at least one media object has encountered
an error during loading, false
otherwise
isErrorID
public boolean isErrorID(int id)
Returns true
if any of the media objects with ID
have encountered errors during loading, false otherwise.
id
- the ID of the media objects to check
true
if any of the media objects with ID
have encountered errors during loading, false otherwise
removeImage
public void removeImage(Image image)
Removes an image from this MediaTracker.
image
- the image to be removed
removeImage
public void removeImage(Image image,
int id)
Removes an image with the specified ID from this MediaTracker.
image
- the image to be removed
removeImage
public void removeImage(Image image,
int id,
int width,
int height)
Removes an image with the specified ID and scale from this MediaTracker.
image
- the image to be removed
statusAll
public int statusAll(boolean load)
Returns the status flags of all registered media objects ORed together.
If load
is true
then media objects that
are not already loading will be started to load.
load
- if set to true
then media objects that are
not already loading are started
- the status flags of all tracked media objects ORed together
statusID
public int statusID(int id,
boolean load)
Returns the status flags of the media objects with the specified ID
ORed together.
If load
is true
then media objects that
are not already loading will be started to load.
load
- if set to true
then media objects that are
not already loading are started
- the status flags of all tracked media objects ORed together
waitForAll
public void waitForAll()
throws InterruptedException
Waits for all media objects to finish loading, either by completing
successfully or by aborting or encountering an error.
waitForAll
public boolean waitForAll(long ms)
throws InterruptedException
Waits for all media objects to finish loading, either by completing
successfully or by aborting or encountering an error.
This method waits at most ms
milliseconds. If the
media objects have not completed loading within this timeframe, this
method returns false
, otherwise true
.
ms
- timeframe in milliseconds to wait for the media objects to
finish
true
if all media objects have successfully loaded
within the timeframe, false
otherwise
waitForID
public void waitForID(int id)
throws InterruptedException
Waits for all media objects with the specified ID to finish loading,
either by completing successfully or by aborting or encountering an error.
id
- the ID of the media objects to wait for
waitForID
public boolean waitForID(int id,
long ms)
throws InterruptedException
Waits for all media objects with the specified ID to finish loading,
either by completing successfully or by aborting or encountering an error.
This method waits at most ms
milliseconds. If the
media objects have not completed loading within this timeframe, this
method returns false
, otherwise true
.
id
- the ID of the media objects to wait forms
- timeframe in milliseconds to wait for the media objects to
finish
true
if all media objects have successfully loaded
within the timeframe, false
otherwise
MediaTracker.java -- Class used for keeping track of images
Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.