All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ejmf.toolkit.util.Utility

java.lang.Object
   |
   +----ejmf.toolkit.util.Utility

public class Utility
extends Object
Static utilites for common JMF routines


Constructor Index

 o Utility()

Method Index

 o appArgToMediaLocator(String)
Converts a string to a URL.
 o appletArgToMediaLocator(Applet, String)
Converts an applet argument to a MediaLocator.
 o createDisabledIcon(ImageIcon)
Create a disabled icon using a gray filter.
 o fileToURL(String)
Convert a File to a URL using file: protocol.
 o getExtension(File)
Given a File object, return a String representing the file's extension.
 o getExtension(String)
Given a String representing a file name, return a String representing the file's extension.
 o getImageResource(String)
Gets an image property from the default EJMF properties table, then constructs an ImageIcon from the named resource.
 o getJMFProperties()
Gets the jmf.properties file for the system.
 o getMaximumLatency(Controller[])
Given an array of Controllers, calculate the maximum startup latency in seconds.
 o getMediaResource(String)
Gets an media file property from the default EJMF properties table and constructs a URL for the file.
 o pickAMaster(Player[])
Pick a master Player for an array of Players.
 o showControls(Controller)
Displays each Control not currently being shown.
 o stateToString(int)
Convert a Controller state to a string
 o vectorizeParameter(Applet, String)
For use by an applet to collect into an array multiple parameters whose names differ only by the addition of a trailing succesive integer.

Constructors

 o Utility
 public Utility()

Methods

 o getJMFProperties
 public static Properties getJMFProperties()
Gets the jmf.properties file for the system.

 o getImageResource
 public static ImageIcon getImageResource(String key)
Gets an image property from the default EJMF properties table, then constructs an ImageIcon from the named resource.

Example: Suppose the ejmf_proprties file contained the following:

     # Directory locations
     imagedir=/images
     mediadir=/media
 

# Images duke_image=duke.gif

To load duke.gif:
     ImageIcon dukeIcon = Utility.getImageResource(duke_image);
     JLabel l = new JLabel(dukeIcon);
     ...
 

Parameters:
key - The image property to load
Returns:
An ImageIcon constructed from the named image, or null if the resource could not be located.
 o getMediaResource
 public static URL getMediaResource(String key)
Gets an media file property from the default EJMF properties table and constructs a URL for the file.

Example: Suppose the ejmf_proprties file contained the following:

     # Directory locations
     mediadir=/media
 

# Media files gulp_media=gulp.wav

To load gulp.wav:
     URL url = Utility.getMediaResource("gulp_media");
     Manager.createPlayer(url);
     ...
 

Parameters:
key - The media file property to load
Returns:
A URL representing a media file or null if the resource could not be located.
 o appletArgToMediaLocator
 public static MediaLocator appletArgToMediaLocator(Applet applet,
                                                    String arg)
Converts an applet argument to a MediaLocator.

Returns:
A MediaLocator for the given argument.
 o fileToURL
 public static URL fileToURL(String fileName) throws IOException, MalformedURLException
Convert a File to a URL using file: protocol.

Parameters:
file - The file to convert
Returns:
a java.net.URL representing file named by input File argument.
 o appArgToMediaLocator
 public static MediaLocator appArgToMediaLocator(String arg)
Converts a string to a URL. Tries first to convert the string itself to a URL. If not successful, assumes arg is a file and tries to create a file URL using the full path name of the specified file. The return value of this routine should be checked to ensure that a URL was successfully created.

Parameters:
arg - the url string to convert
Returns:
a URL if successful, null otherwise
 o stateToString
 public static String stateToString(int state)
Convert a Controller state to a string

Parameters:
state - the state to convert
Returns:
a String representing the given state
 o getMaximumLatency
 public static Time getMaximumLatency(Controller controllers[])
Given an array of Controllers, calculate the maximum startup latency in seconds. If a Controller reports LATENCY_UNKNOWN, its value is ignored.

All Controllers must be at least in the Realized state. If a Controller is not in the realized state, its value is ignored.

If all Controllers report LATENCY_UNKNOWN, return LATENCY_UNKNOWN and let the caller worry about what to do.

Parameters:
controllers - An array of javax.media.Controller objects all at least realized.

Returns:
javax.media.Time object representing the maximum startup latency across all the input Controllers.
 o getExtension
 public static String getExtension(File f)
Given a File object, return a String representing the file's extension. If there is no extension, return null.

Parameters:
file - A java.io.File object
Returns:
A String representing file extension
 o getExtension
 public static String getExtension(String filename)
Given a String representing a file name, return a String representing the file's extension. If there is no extension, return null.

Parameters:
filename - A filename as a java.lang.String object
Returns:
A String representing file extension
 o showControls
 public static void showControls(Controller controller)
Displays each Control not currently being shown.

 o pickAMaster
 public static int pickAMaster(Player players[])
Pick a master Player for an array of Players. Return first Player that has a gain control. If no Player has a gain control, return 0. All the input Players are assumed to be realized, else they will return a null gain control.

Parameters:
players - an array of Players
Returns:
an index into the Player array of the Player chosen as the master Player.
 o createDisabledIcon
 public static Icon createDisabledIcon(ImageIcon imageIcon)
Create a disabled icon using a gray filter.

 o vectorizeParameter
 public static String[] vectorizeParameter(Applet app,
                                           String name)
For use by an applet to collect into an array multiple parameters whose names differ only by the addition of a trailing succesive integer.

Parameters:
app - The applet whose parameters are to be read.
name - The template from which parameter name is built. Parameters are name name0, name1, etc.
Returns:
An array of java.lang.String object representing the value of a vector of applet parameters.

All Packages  Class Hierarchy  This Package  Previous  Next  Index