|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.common.util.ClientImageCache wyvern.lib.ImageCache
Server-side cache for mapping tile numbers to images.
The cache provides methods for extracting 32x32 pieces of an image, and it will cache the pieces.
Field Summary |
Fields inherited from class wyvern.common.util.ClientImageCache |
cache_, images_, itemList_, maxSize_, QMARK, TILE_WIDTH, tiles_ |
Constructor Summary | |
protected |
ImageCache()
Prevent instantiation. |
Method Summary | |
static java.awt.Image |
extractImage(int tile,
int x,
int y)
Loads (and caches) a piece of an image given its tile number and (x,y) offsets. |
static java.awt.Image |
getImage(Archetype arch)
Retrieves (and caches) the image for the specified archetype. |
static java.awt.Image |
getImage(int tile)
Loads an image from its tile number. |
java.lang.String |
getImageNameFromTile(int tile)
Looks up the image name in our cache. |
static java.awt.Image |
loadImage(java.lang.String path)
Loads an image from a resource (a file or jar file). |
static java.awt.Image |
loadImageFromRelativePath(java.lang.String path)
Loads an image, given a "normal" image path that's relative to a wiz directory or the built-in game art directory. |
protected java.awt.Image |
loadImageResource(java.lang.String path)
Loads resource headlessly. |
Methods inherited from class wyvern.common.util.ClientImageCache |
addTileNumber, clear, extractPiece, extractSpecial, getInstance, iextractImage, igetImage, setInitialTileMappings, setMaxSize, storeImage, uncacheImage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ImageCache()
Method Detail |
public static java.awt.Image getImage(int tile)
tile
- the database tile number
public static java.awt.Image extractImage(int tile, int x, int y)
The (x,y) offsets correspond to the tile location within the image to extract. For instance, if the image is 64x64, i.e. 2x2 tiles, then an (x,y) offset of (0,1) will extract and return the lower-left corner of the image.
tile
- the TileDatabase number of the imagex
- the x tile offset into the imagey
- the y tile offset into the image
java.lang.IllegalArgumentException
- if either offset is invalidpublic static java.awt.Image getImage(Archetype arch)
arch
- the Archetype whose image to loadpublic java.lang.String getImageNameFromTile(int tile)
This version of the ImageCache is used by the map editor, so load the image synchronously when it's requested. Our superclass returns null unless the image is available.
getImageNameFromTile
in class ClientImageCache
tile
- the tile database number
public static java.awt.Image loadImage(java.lang.String path)
path
- the path to the image, relative to the
system classpath. Example: "wyvern/art/game/foo/bar".
Don't pass in the extension unless it's a PNG file,
in which case pass the ".png" extension.
java.lang.NullPointerException
- if the passed path is nullprotected java.awt.Image loadImageResource(java.lang.String path)
loadImageResource
in class ClientImageCache
path
- the relative path to the image, using the naming
conventions required by wyvern.common.config.Wyvern.loadImage()public static java.awt.Image loadImageFromRelativePath(java.lang.String path)
path
- the relative image path, e.g. "wiz/foobar/blah.gif",
or "monsters/goblin/troll.S.gif"
java.lang.NullPointerException
- if you pass a null path
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |