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
-
Utility()
-
-
appArgToMediaLocator(String)
- Converts a string to a URL.
-
appletArgToMediaLocator(Applet, String)
- Converts an applet argument to a MediaLocator.
-
createDisabledIcon(ImageIcon)
-
Create a disabled icon using a gray filter.
-
fileToURL(String)
- Convert a File to a URL using file: protocol.
-
getExtension(File)
- Given a File object, return a String representing
the file's extension.
-
getExtension(String)
- Given a String representing a file name, return a String representing
the file's extension.
-
getImageResource(String)
- Gets an image property from the default EJMF properties
table, then constructs an ImageIcon from the named
resource.
-
getJMFProperties()
- Gets the jmf.properties file for the system.
-
getMaximumLatency(Controller[])
- Given an array of Controllers, calculate the maximum
startup latency in seconds.
-
getMediaResource(String)
- Gets an media file property from the default EJMF properties
table and constructs a URL for the file.
-
pickAMaster(Player[])
- Pick a master Player for an array of Players.
-
showControls(Controller)
- Displays each Control not currently being shown.
-
stateToString(int)
- Convert a Controller state to a string
-
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.
Utility
public Utility()
getJMFProperties
public static Properties getJMFProperties()
- Gets the jmf.properties file for the system.
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.
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.
appletArgToMediaLocator
public static MediaLocator appletArgToMediaLocator(Applet applet,
String arg)
- Converts an applet argument to a MediaLocator.
- Returns:
- A MediaLocator for the given argument.
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.
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
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
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.
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
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
showControls
public static void showControls(Controller controller)
- Displays each Control not currently being shown.
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.
createDisabledIcon
public static Icon createDisabledIcon(ImageIcon imageIcon)
- Create a disabled icon using a gray filter.
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