public class ResourceManager extends Object
The Kiwi library includes a resource library of its own; the resources
within the library are accessible through the internal
ResourceManager
, a reference to which may be obtained via
a call to kiwi.util.KiwiUtils.getResourceManager()
. Links to
index files of some of the resources are listed below:
ResourceLoader
Modifier and Type | Field and Description |
---|---|
private Hashtable |
bundles |
static String |
HTML_PATH
The default base path for HTML documents.
|
protected String |
htmlPath
The base path for HTML documents.
|
private Hashtable |
icons |
static String |
IMAGE_PATH
The default base path for images.
|
protected String |
imagePath
The base path for images.
|
private Hashtable |
images |
private static ResourceManager |
kiwiResourceManager |
private ResourceLoader |
loader |
static String |
PROPERTY_PATH
The default base path for property files.
|
protected String |
propertyPath
The base path for property files.
|
static String |
RESBUNDLE_EXT
The file extension for resource bundles.
|
static String |
RESBUNDLE_PATH
The default base path for message bundles.
|
protected String |
resbundlePath
The base path for message bundles.
|
private static String |
respathSeparator |
static String |
SOUND_PATH
The default base path for audio clips.
|
protected String |
soundPath
The base path for audio clips.
|
private Hashtable |
sounds |
static String |
TEXTURE_PATH
The default base path for textures.
|
protected String |
texturePath
The base path for textures.
|
private Hashtable |
textures |
static String |
THEME_EXT
The file extension for color themes.
|
static String |
THEME_PATH
The default base path for color themes.
|
protected String |
themePath
The base path for color themes.
|
Constructor and Description |
---|
ResourceManager(Class clazz)
Construct a new
ResourceManager . |
Modifier and Type | Method and Description |
---|---|
private String |
_checkPath(String path) |
private void |
checkResourceName(String name) |
void |
clearAudioClipCache()
Clear the audio clip resource cache.
|
void |
clearIconCache()
Clear the icon resource cache.
|
void |
clearImageCache()
Clear the image resource cache.
|
void |
clearResourceBundleCache()
Clear the resource bundle cache.
|
void |
clearTextureCache()
Clear the texture resource cache.
|
Icon |
getIcon(String name)
Retrieve an internal
Icon resource. |
Image |
getImage(String name)
Retrieve an internal
Image resource. |
static ResourceManager |
getKiwiResourceManager()
Get a reference to the internal Kiwi resource manager.
|
Properties |
getProperties(String name)
Get a reference to a
Properties resource. |
LocaleData |
getResourceBundle(String name)
Get a reference to a
LocaleData object for the default
locale. |
LocaleData |
getResourceBundle(String name,
Locale locale)
Get a reference to a
LocaleData object for a specified
locale. |
AudioClip |
getSound(String name)
Retrieve an internal
AudioClip resource. |
InputStream |
getStream(String name)
Get a stream to a resource.
|
Image |
getTexture(String name)
Retrieve an internal texture resource.
|
ColorTheme |
getTheme(String name)
Get a reference to a
ColorTheme resource. |
URL |
getURL(String name)
Retrieve an internal
URL resource. |
void |
setHTMLPath(String path)
Set an alternate path (relative to the anchor class) for HTML document
resources.
|
void |
setImagePath(String path)
Set an alternate path (relative to the anchor class) for image and icon
resources.
|
void |
setPropertyPath(String path)
Set an alternate path (relative to the anchor class) for property
resources.
|
void |
setResourceBundlePath(String path)
Set an alternate path (relative to the anchor class) for message bundle
resources.
|
void |
setSoundPath(String path)
Set an alternate path (relative to the anchor class) for audio clip
resources.
|
void |
setTexturePath(String path)
Set an alternate path (relative to the anchor class) for texture
resources.
|
void |
setThemePath(String path)
Set an alternate path (relative to the anchor class) for theme
resources.
|
private ResourceLoader loader
private static ResourceManager kiwiResourceManager
private static final String respathSeparator
public static final String IMAGE_PATH
public static final String SOUND_PATH
public static final String HTML_PATH
public static final String THEME_PATH
public static final String TEXTURE_PATH
public static final String PROPERTY_PATH
public static final String RESBUNDLE_PATH
public static final String RESBUNDLE_EXT
public static final String THEME_EXT
protected String texturePath
protected String propertyPath
protected String resbundlePath
public ResourceManager(Class clazz)
ResourceManager
.clazz
- The resource anchor class.private String _checkPath(String path)
public void setImagePath(String path)
path
- The new resource path.public void setSoundPath(String path)
path
- The new resource path.public void setHTMLPath(String path)
path
- The new resource path.public void setThemePath(String path)
path
- The new resource path.public void setTexturePath(String path)
path
- The new resource path.public void setPropertyPath(String path)
path
- The new resource path.public void setResourceBundlePath(String path)
path
- The new resource path.public static ResourceManager getKiwiResourceManager()
public void clearImageCache()
public void clearIconCache()
public void clearTextureCache()
public void clearAudioClipCache()
public void clearResourceBundleCache()
public Icon getIcon(String name)
Icon
resource. This is a convenience
method that makes a call to getImage()
and then wraps the
result in a Swing ImageIcon
object.name
- The name of the resource.Icon
for the specified image. If an icon for this
image has previously been constructed, the cached copy is returned.ResourceNotFoundException
- If the resource was not
found.ImageIcon
public Image getImage(String name)
Image
resource. If the named image has
previously been loaded, a cached copy is returned.name
- The name of the resource.Image
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public Image getTexture(String name)
name
- The name of the resource.Image
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public URL getURL(String name)
URL
resource.name
- The name of the resource.ResourceNotFoundException
- If the resource was not
found.public AudioClip getSound(String name)
AudioClip
resource. If the named sound
has previously been loaded, a cached copy is returned.name
- The name of the resource.AudioClip
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public Properties getProperties(String name)
Properties
resource.name
- The name of the resource.Properties
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public LocaleData getResourceBundle(String name) throws ResourceNotFoundException
LocaleData
object for the default
locale. The locale naming convention
basename_language_country_variant is
supported; a search is performed starting with the most specific name
and ending with the most generic.name
- The name of the resource; this should be the base name of
the resource bundle; the appropriate locale country, language, and
variant codes and the ".msg" extension will be automatically
appended to the name.LocaleData
object representing the resource.
If the resource bundle has been previously loaded, a cached copy is
returned.ResourceNotFoundException
- If the resource was not
found.public LocaleData getResourceBundle(String name, Locale locale) throws ResourceNotFoundException
LocaleData
object for a specified
locale. The locale naming convention
basename_language_country_variant is
supported; a search is performed starting with the most specific name
and ending with the most generic. If the resource bundle has been
previously loaded, a cached copy is returned.name
- The name of the resource; this should be the base name of
the resource bundle; the appropriate locale contry, language, and
variant codes and the ".msg" extension will be automatically
appended to the name.locale
- The locale for the resource.LocaleData
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public ColorTheme getTheme(String name)
ColorTheme
resource.name
- The name of the resource; this should be the base name of
the color theme; the ".thm" extension will be automatically
appended to the name.ColorTheme
object representing the resource.ResourceNotFoundException
- If the resource was not
found.public InputStream getStream(String name) throws ResourceNotFoundException
name
- The name of the resource.InputStream
from which the resource can be read.ResourceNotFoundException
- If the resource was not
found.private void checkResourceName(String name) throws IllegalArgumentException
IllegalArgumentException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses