org.opensourcephysics.tools
Class ResourceLoader

java.lang.Object
  extended byorg.opensourcephysics.tools.ResourceLoader

public class ResourceLoader
extends java.lang.Object

This defines static methods for loading resources.


Field Summary
protected static boolean cacheEnabled
           
protected static java.lang.String launchJarName
           
protected static java.lang.String launchJarPath
           
protected static int maxPaths
           
protected static java.util.Hashtable resources
           
protected static java.util.ArrayList searchPaths
           
protected static java.net.URLClassLoader xsetZipLoader
           
protected static java.util.Map zipLoaders
           
 
Method Summary
static void addSearchPath(java.lang.String base)
          Adds a path at the beginning of the searchPaths list.
static java.applet.AudioClip getAudioClip(java.lang.String path)
           
static java.awt.image.BufferedImage getBufferedImage(java.lang.String path)
           
static javax.swing.ImageIcon getIcon(java.lang.String path)
           
static java.awt.Image getImage(java.lang.String path)
           
static java.lang.String getLaunchJarPath()
           
static Resource getResource(java.lang.String name)
          Gets a resource specified by name.
static Resource getResource(java.lang.String name, java.lang.Class type)
          Gets a resource specified by name and Class.
static Resource getResource(java.lang.String basePath, java.lang.String name)
          Gets a resource specified by base path and name.
static Resource getResource(java.lang.String basePath, java.lang.String name, java.lang.Class type)
          Gets a resource specified by base path, name and class.
static java.lang.String getString(java.lang.String path)
           
static boolean isCacheEnabled()
          Gets the cacheEnabled property.
static java.io.InputStream openInputStream(java.lang.String path)
           
static java.io.Reader openReader(java.lang.String path)
           
static void removeSearchPath(java.lang.String base)
          Removes a path from the searchPaths list.
static void setCacheEnabled(boolean enabled)
          Sets the cacheEnabled property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

searchPaths

protected static java.util.ArrayList searchPaths

maxPaths

protected static int maxPaths

resources

protected static java.util.Hashtable resources

cacheEnabled

protected static boolean cacheEnabled

zipLoaders

protected static java.util.Map zipLoaders

xsetZipLoader

protected static java.net.URLClassLoader xsetZipLoader

launchJarName

protected static java.lang.String launchJarName

launchJarPath

protected static java.lang.String launchJarPath
Method Detail

getResource

public static Resource getResource(java.lang.String name)
Gets a resource specified by name. If no resource is found using the name alone, the searchPaths are searched.

Parameters:
name - the file or URL name
Returns:
the Resource, or null if none found

getResource

public static Resource getResource(java.lang.String name,
                                   java.lang.Class type)
Gets a resource specified by name and Class. If no resource is found using the name alone, the searchPaths are searched.

Parameters:
name - the file or URL name
type - the Class providing default ClassLoader resource loading
Returns:
the Resource, or null if none found

getResource

public static Resource getResource(java.lang.String basePath,
                                   java.lang.String name)
Gets a resource specified by base path and name. If base path is relative and no resource is found using the base alone, the searchPaths are searched.

Parameters:
basePath - the base path
name - the file or URL name
Returns:
the Resource, or null if none found

getResource

public static Resource getResource(java.lang.String basePath,
                                   java.lang.String name,
                                   java.lang.Class type)
Gets a resource specified by base path, name and class. If base path is relative and no resource is found using the base alone, the searchPaths are searched.

Parameters:
basePath - the base path
name - the file or URL name
type - the Class providing ClassLoader resource loading
Returns:
the Resource, or null if none found

addSearchPath

public static void addSearchPath(java.lang.String base)
Adds a path at the beginning of the searchPaths list.

Parameters:
base - the base path to add

removeSearchPath

public static void removeSearchPath(java.lang.String base)
Removes a path from the searchPaths list.

Parameters:
base - the base path to remove

setCacheEnabled

public static void setCacheEnabled(boolean enabled)
Sets the cacheEnabled property.

Parameters:
enabled - true to enable the cache

isCacheEnabled

public static boolean isCacheEnabled()
Gets the cacheEnabled property.

Returns:
true if the cache is enabled

openInputStream

public static java.io.InputStream openInputStream(java.lang.String path)

openReader

public static java.io.Reader openReader(java.lang.String path)

getString

public static java.lang.String getString(java.lang.String path)

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String path)

getImage

public static java.awt.Image getImage(java.lang.String path)

getBufferedImage

public static java.awt.image.BufferedImage getBufferedImage(java.lang.String path)

getAudioClip

public static java.applet.AudioClip getAudioClip(java.lang.String path)

getLaunchJarPath

public static java.lang.String getLaunchJarPath()