|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hdcookbook.grin.util.AssetFinder
public class AssetFinder
This class serves two functions. First, it has a bunch of static methods that are used by GRIN and can be used by applications to find various resources. Secondly, an xlet (or other application) can create an instance of AssetFinder and bind it to us with the method setHelper. If this is done, AssetFinder will try to locate assets by first querying the helper. This way, an Xlet can make decisions about where to look for stuff. For example, a signed BD-Live xlet could set up a search path on the BUDA.
Constructor Summary | |
---|---|
protected |
AssetFinder()
See setHelper() |
Method Summary | |
---|---|
static void |
abort()
Called when the disc playback should abort. |
protected void |
abortHelper()
Called when the disc playback should abort. |
static java.awt.Image |
createCompatibleImageBuffer(java.awt.Component c,
int width,
int height)
Get an image buffer that's suitable for use double-buffering drawing to the componet c. |
protected java.awt.Image |
createCompatibleImageBufferHelper(java.awt.Component c,
int width,
int height)
Subclasses can override this to return a different kind of buffered image, e.g. |
static java.awt.Graphics2D |
createGraphicsFromImageBuffer(java.awt.Image buffer)
Create a Graphic2D image for drawing into the given image buffer. |
protected java.awt.Graphics2D |
createGraphicsFromImageBufferHelper(java.awt.Image buffer)
Subclasses can override this to work with a different kind of buffered image, e.g. |
static void |
destroyImageBuffer(java.awt.Image buffer)
Destroy an image buffer, freeing native resources that it uses (such as native memory used to hold a pixmap). |
protected void |
destroyImageBufferHelper(java.awt.Image buffer)
Subclasses can override this to work with a different kind of buffered image, e.g. |
static java.awt.Color |
getColor(int r,
int g,
int b,
int a)
Efficiently get a Color that's used within a Show. |
static int |
getColorKeyCode(java.awt.Color c)
Get the key code for the given color key. |
protected int |
getColorKeyCodeHelper(java.awt.Color c)
Get the key code for the given color key. |
static java.awt.Font |
getFont(java.lang.String fontName,
int style,
int size)
Get a Font that's used within a Show. |
protected java.awt.Font |
getFontHelper(java.lang.String fontName,
int style,
int size)
Helper subclass can override this in order to search for generic assets, like images. |
static java.io.File[] |
getSearchPathFile()
Get the appJarPathArg as set by setSearchPath() |
static java.lang.String[] |
getSearchPathJar()
Get the filePathArg as set by setSearchPath() |
static java.net.URL |
getURL(java.lang.String path)
Get a URL to an asset. |
static java.awt.Image |
loadImage(java.lang.String path)
Load an image from the given path. |
protected java.awt.Image |
loadImageHelper(java.lang.String path)
Helper subclass can override this in order to search for images in some special way. |
static void |
notifyLoaded(ManagedFullImage mi)
Called by ManagedFullImage when an image finishes loading. |
protected void |
notifyLoadedHelper(ManagedFullImage mi)
Called when a ManagedFullImage has finished loading. |
static void |
notifyUnloaded(ManagedFullImage mi,
int width,
int height)
Called by ManagedFullImage when a loaded image has been unloaded (flushed). |
protected void |
notifyUnloadedHelper(ManagedFullImage mi,
int width,
int height)
Called when a ManagedFullImage has been unloaded (flushed). |
static void |
setHelper(AssetFinder helperArg)
An xlet can make an instance of a subclass of AssetFinder, and connect it to us by calling this method. |
static void |
setImageMap(java.lang.String mapFile)
Sets the image map. |
static void |
setImageMap(java.lang.String[] mapFiles)
Sets the image map to the concatination of the maps in the given files. |
static void |
setSearchPath(java.lang.String[] appJarPathArg,
java.io.File[] filePathArg)
|
static java.net.URL |
tryURL(java.lang.String path)
Try to get an asset that might not be there. |
protected java.net.URL |
tryURLHelper(java.lang.String path)
Helper subclass can override this in order to search for generic assets, like images. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AssetFinder()
Method Detail |
---|
public static void setHelper(AssetFinder helperArg)
public static void setSearchPath(java.lang.String[] appJarPathArg, java.io.File[] filePathArg)
appJarPathArg
- A list of paths within the classpath
of the app, for use by Class.getResourcefilePathArg
- A list of paths in the filesystem,
e.g. from mounting a DSMCC carousel.public static java.lang.String[] getSearchPathJar()
public static java.io.File[] getSearchPathFile()
public static void setImageMap(java.lang.String mapFile)
If an image map was previously in place, it will be replaced with the new map as an atomic operation when the image map file has been completely read.
mapFile
- The name of an image map file produced by MosaicMakersetImageMap(String[])
public static void setImageMap(java.lang.String[] mapFiles)
If an image map was previously in place, it will be replaced with the new map as an atomic operation when the image map file has been completely read.
It is up to the callee to make sure that there are no name collisions, either in the name of the source images, or in the names of the mosaics.
mapFiles
- The name of image map files produced by MosaicMakersetImageMap(String)
public static java.net.URL getURL(java.lang.String path)
path
- A string, relative to the search path for assets
TODO: Maybe need to search locators, toopublic static java.net.URL tryURL(java.lang.String path)
protected java.net.URL tryURLHelper(java.lang.String path)
public static java.awt.Color getColor(int r, int g, int b, int a)
public static java.awt.Font getFont(java.lang.String fontName, int style, int size)
protected java.awt.Font getFontHelper(java.lang.String fontName, int style, int size)
public static java.awt.Image createCompatibleImageBuffer(java.awt.Component c, int width, int height)
c.getGraphicsConfiguration().createCompatibleImage(width, height)In GEM-based systems, it is recommended that this be a
DVBBufferedImage
, for improved native memory management. See
http://wiki.java.net/bin/view/Mobileandembedded/BDJImageMemoryManagement
for a discussion of why.
createCompatibleImageBufferHelper(java.awt.Component, int, int)
,
createGraphicsFromImageBuffer(java.awt.Image)
,
destroyImageBuffer(java.awt.Image)
protected java.awt.Image createCompatibleImageBufferHelper(java.awt.Component c, int width, int height)
DVBBufferedImage
createCompatibleImageBufferHelper(java.awt.Component, int, int)
public static java.awt.Graphics2D createGraphicsFromImageBuffer(java.awt.Image buffer)
createCompatibleImageBuffer()
.
createCompatibleImageBuffer(java.awt.Component, int, int)
protected java.awt.Graphics2D createGraphicsFromImageBufferHelper(java.awt.Image buffer)
DVBBufferedImage
createGraphicsFromImageBuffer(java.awt.Image)
public static void destroyImageBuffer(java.awt.Image buffer)
createCompatibleImageBuffer(java.awt.Component, int, int)
protected void destroyImageBufferHelper(java.awt.Image buffer)
DVBBufferedImage
destroyImageBuffer(java.awt.Image)
public static java.awt.Image loadImage(java.lang.String path)
path
- should be an absolute path within asset finder's path.protected java.awt.Image loadImageHelper(java.lang.String path)
public static int getColorKeyCode(java.awt.Color c)
c
- A color that is == to one of the standard
constants Color.red, Color.green, Color.yellow
or Color.blue.
protected int getColorKeyCodeHelper(java.awt.Color c)
An implementation of the cookbook's color key algorithm is also available, in the GrinXlet directory project. See, for example, xlets/GrinXlet/src/deploy/com/hdcookbook/grinxlet/GrinXlet.java
c
- A color that is == to one of the standard
constants Color.red, Color.green, Color.yellow
or Color.blue.
public static void abort()
protected void abortHelper()
public static void notifyLoaded(ManagedFullImage mi)
notifyLoadedHelper(ManagedFullImage)
,
notifyUnloaded(ManagedFullImage, int, int)
protected void notifyLoadedHelper(ManagedFullImage mi)
notifyLoaded(ManagedFullImage)
,
notifyUnloadedHelper(ManagedFullImage, int, int)
public static void notifyUnloaded(ManagedFullImage mi, int width, int height)
notifyUnloadedHelper(ManagedFullImage, int, int)
,
notifyLoaded(ManagedFullImage)
protected void notifyUnloadedHelper(ManagedFullImage mi, int width, int height)
notifyLoaded(ManagedFullImage)
,
notifyLoadedHelper(ManagedFullImage)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |