|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gjt.universe.UniverseData
Encapsulates searching for resources (e.g. images, sounds, custom data files) used by the game into a single facade, so that callers need not know how or where these data are stored.
Currently all resources are kept in a single jar file, UniverseData.jar, which should be in the same directory as the game's jar. However, in the future a more complex scheme may be employed (e.g. to support custom variations of the game, localization, etc.).
Note that the game is unable to run without UniverseData.jar and if it is not detected or is believed to be damaged, an fatal error explaining this will be reported ot the user and the application will exit.
Note: if additional resource files are desired (in addition
to UniverseData.jar, they can be automatically used just by
adding the file name to the urlsToLoadFrom
variable.
Some changes were made: file-handling methods will throw a FileNotFoundException instead of null, to make error handling easier (no need to test for null case).
Field Summary | |
private static java.lang.String |
CHECK_FILE
|
private static java.net.URLClassLoader |
classLoader
|
private static UniverseData |
singleton
|
Constructor Summary | |
private |
UniverseData()
|
Method Summary | |
static void |
checkDataPresent()
Checks the presence of the UniverseData.jar file, and, if not present, informs the user and exits. |
static java.awt.Image |
getImage(java.lang.String name)
Gets an Image to the named resource. |
static javax.swing.ImageIcon |
getImageIcon(java.lang.String name)
Get an ImageIcon. |
static java.io.InputStream |
getInputStream(java.lang.String name)
Gets an InputStream to the named resource; throws an exception if the resource could not be found. |
static java.io.InputStreamReader |
getInputStreamReader(java.lang.String name)
Gets an InputStreamReader to the named resource. |
static java.lang.String |
getText(java.lang.String name)
Returns a resource as a String. |
static java.net.URL |
getURL(java.lang.String name)
Given a resource name, extract a URL for the given resource. |
static boolean |
isDataPresent()
Check if the UniverseData.jar (or whatever it is named) is available (on the classpath). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static UniverseData singleton
private static java.net.URLClassLoader classLoader
private static final java.lang.String CHECK_FILE
Constructor Detail |
private UniverseData()
Method Detail |
public static boolean isDataPresent()
public static void checkDataPresent()
public static java.net.URL getURL(java.lang.String name)
public static javax.swing.ImageIcon getImageIcon(java.lang.String name)
public static java.io.InputStream getInputStream(java.lang.String name) throws java.io.IOException
java.io.IOException
public static java.io.InputStreamReader getInputStreamReader(java.lang.String name) throws java.io.IOException
java.io.IOException
public static java.awt.Image getImage(java.lang.String name)
We take the easy way out here....
public static java.lang.String getText(java.lang.String name)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |