|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectacm.util.MediaTools
public class MediaTools
This class implements a standard mechanism for loading images, sounds, and data files from the resources associated with a jar file.
Field Summary | |
---|---|
String |
DEFAULT_AUDIO_PATH
|
String |
DEFAULT_DATAFILE_PATH
|
String |
DEFAULT_IMAGE_PATH
|
Method Summary | |
---|---|
void |
beep()
|
AudioClip |
createAudioClip(InputStream in)
|
AudioClip |
createAudioClip(String[] hexData)
|
BufferedImage |
createBufferedImage(Image image,
int type)
BufferedImage from the specified image. |
Image |
createImage(InputStream in)
|
Image |
createImage(int[][] array)
|
Image |
createImage(int[] pixels,
int width,
int height)
|
Image |
createImage(String[] hexData)
|
void |
defineAudioClip(String name,
AudioClip clip)
|
void |
defineImage(String name,
Image image)
|
void |
flushAudioClip(String name)
|
void |
flushImage(String name)
|
InputStream |
getHexInputStream(String[] hexData)
hex ,
in which the elements consist of continuous bytes of hex data. |
Component |
getImageObserver()
imageObserver . |
int[][] |
getPixelArray(Image image)
|
boolean |
isCachingEnabled()
setCachingEnabled . |
AudioClip |
loadAudioClip(String name)
AudioClip . |
AudioClip |
loadAudioClip(URL url)
|
AudioClip |
loadAudioClip(URL url,
boolean topLevel)
|
Image |
loadImage(Image image)
|
Image |
loadImage(String name)
Image . |
Image |
loadImage(URL url)
|
Image |
loadImage(URL url,
boolean topLevel)
|
InputStream |
openDataFile(String name)
InputStream . |
InputStream |
openDataFile(String name,
String path)
InputStream . |
InputStream |
openDataFile(URL url)
InputStream . |
InputStream |
openDataFile(URL url,
boolean topLevel)
|
void |
saveImage(Image image,
File file)
|
void |
saveImage(Image image,
String filename)
|
void |
setCachingEnabled(boolean flag)
MediaTools package to indicate
whether images and audio clips are cached internally by name. |
Field Detail |
---|
public static final String DEFAULT_AUDIO_PATH
public static final String DEFAULT_DATAFILE_PATH
public static final String DEFAULT_IMAGE_PATH
Method Detail |
---|
public static void beep()
Usage: | MediaTools.beep(); |
public static AudioClip createAudioClip(InputStream in)
SoundClip
object from the data. If that fails, it then backs up to the older strategy
of using the SunAudioClip
class.
Usage: | AudioClip clip = MediaTools.createAudioClip(in); | ||
Parameter: |
| ||
Returns: | An AudioClip object
|
public static AudioClip createAudioClip(String[] hexData)
Usage: | AudioClip audio clip = MediaTools.createAudioClip(hexData); | ||
Parameter: |
| ||
Returns: | An AudioClip object
|
public static BufferedImage createBufferedImage(Image image,
int type)
BufferedImage
from the specified image. The
type
parameter is used to specify the image type, as
described in the BufferedImage
documentation.
Usage: | BufferedImage image = MediaTools.createBufferedImage(image, type); | ||||||
Parameters: |
|
public static Image createImage(InputStream in)
Usage: | Image image = MediaTools.createImage(in); | ||
Parameter: |
| ||
Returns: | An Image object
|
public static Image createImage(int[][] array)
Usage: | Image image = MediaTools.createImage(array); | ||
Parameter: |
| ||
Returns: | An Image object
|
public static Image createImage(int[] pixels,
int width,
int height)
Usage: | Image image = MediaTools.createImage(pixels, width, height); | ||||||
Parameters: |
| ||||||
Returns: | An Image object
|
public static Image createImage(String[] hexData)
Usage: | Image image = MediaTools.createImage(hexData); | ||
Parameter: |
| ||
Returns: | An Image object
|
public static void defineAudioClip(String name,
AudioClip clip)
Usage: | MediaTools.defineAudioClip(name, clip); | ||||
Parameters: |
|
public static void defineImage(String name,
Image image)
Usage: | MediaTools.defineImage(name, image); | ||||
Parameters: |
|
public static void flushAudioClip(String name)
Usage: | MediaTools.flushAudioClip(name); | ||
Parameter: |
|
public static void flushImage(String name)
Usage: | MediaTools.flushImage(name); | ||
Parameter: |
|
public static InputStream getHexInputStream(String[] hexData)
hex
,
in which the elements consist of continuous bytes of hex data.
Usage: | InputStream in = MediaTools.getHexInputStream(hexData); | ||
Parameter: |
| ||
Returns: | An input stream for reading the bytes |
public static Component getImageObserver()
imageObserver
.
Usage: | Component imageObserver = MediaTools.getImageObserver(); |
Returns: | A new lightweight component suitable as an imageObserver .
|
public static int[][] getPixelArray(Image image)
Parameter: |
| ||
Returns: | A two-dimensional array of pixels |
public static boolean isCachingEnabled()
setCachingEnabled
.
Usage: | boolean flag = MediaTools.isCachingEnabled(); |
Returns: | true if caching by name is enabled, false otherwise.
|
public static AudioClip loadAudioClip(String name)
AudioClip
. The search process
consists of the following steps:
AudioClip
. If so, read the
audio clip from the resource file.
The second and third steps are repeated for each element of the audio clip search path, which consists of a list of directories separated by colons.
Usage: | AudioClip clip = MediaTools.loadAudioClip(name); | ||
Parameter: |
| ||
Returns: | A new AudioClip object
|
public static AudioClip loadAudioClip(URL url)
Usage: | AudioClip clip = MediaTools.loadAudioClip(url); | ||
Parameter: |
| ||
Returns: | A new AudioClip object
|
public static AudioClip loadAudioClip(URL url,
boolean topLevel)
topLevel
flag
is false
if this is invoked internally.
public static Image loadImage(Image image)
Usage: | image = MediaTools.loadImage(image); | ||
Parameter: |
| ||
Returns: | The same Image after ensuring that it is fully loaded
|
public static Image loadImage(String name)
Image
. The search process
consists of the following steps:
Image
. If so, read the image
from the resource file.
The second and third steps are repeated for each element of the image search path, which consists of a list of directories separated by colons.
Unlike the getImage
method in the Applet
class,
loadImage
waits for an image to be fully loaded before returning.
Usage: | Image image = MediaTools.loadImage(name); | ||
Parameter: |
| ||
Returns: | A fully loaded Image object
|
public static Image loadImage(URL url)
Usage: | Image image = MediaTools.loadImage(url); | ||
Parameter: |
| ||
Returns: | A fully loaded Image object
|
public static Image loadImage(URL url,
boolean topLevel)
topLevel
flag
is false
if this is invoked internally.
public static InputStream openDataFile(String name)
InputStream
. The search process
consists of the following steps:
InputStream
open on that resource.
These steps are repeated for each element of the datafile search path, which consists of a list of directories separated by colons.
Usage: | InputStream in = MediaTools.openDataFile(name); | ||
Parameter: |
| ||
Returns: | A new InputStream open on the specified file
|
public static InputStream openDataFile(String name,
String path)
InputStream
. Its operation is identical to the single-argument
openDataFile
call except
in that this version allows the client to specify the search path
explicitly.
Usage: | InputStream in = MediaTools.openDataFile(name, path); | ||||
Parameters: |
| ||||
Returns: | A new InputStream open on the specified file
|
public static InputStream openDataFile(URL url)
InputStream
.
Usage: | InputStream in = MediaTools.openDataFile(url); | ||
Parameter: |
| ||
Returns: | A new InputStream open on the specified URL
|
public static InputStream openDataFile(URL url,
boolean topLevel)
topLevel
flag
is false
if this is invoked internally.
public static void saveImage(Image image,
File file)
Usage: | MediaTools.saveImage(image, file); | ||||
Parameters: |
|
public static void saveImage(Image image,
String filename)
Usage: | MediaTools.saveImage(image, filename); | ||||
Parameters: |
|
public static void setCachingEnabled(boolean flag)
MediaTools
package to indicate
whether images and audio clips are cached internally by name. This flag is disabled
by default.
Usage: | MediaTools.setCachingEnabled(flag); | ||
Parameter: |
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |