Azzet

Stable

Azzet is a simple Java library for loading assets from various sources

BufferedImage img = Assets.load("http://www.google.com/logos/classicplus.png"); // loaded from website
Font fnt = Assets.load("myfont.ttf", new FontInfo(32.0f)); // loaded from classpath
Clip snd = Assets.load("C:\UserData\MyMusic.wav"); // loaded from file-system
BufferedImage gif = Assets.loadFrom("mygif.gif", BufferedImage.class); // you can request the return type
BufferedImage[] animatedGif = Assets.loadFrom("mygif.gif", "db"); // loads from DatabaseSource saved as "db"
Properties props = Assets.loadFrom("app.properties", "tcp"); // loads from TcpSource saved as "tcp"

Formats (and equivalent java objects):

Sources:

You can also load assets in the background:

FutureAsset<BufferedImage> future = Assets.loadFuture("mypic.png");
BufferedImage mypic = null;

while (running) {
  // do stuff
  if ( future.getStatus() == FutureAssetStatus.Loaded ) {
     future.loaded(); // mark the future as loaded
     mypic = future.get();  // get the loaded asset
  }
  // do other stuff
}

This type of deferred/lazy loading is especially useful for applications like games with loading screens. You can bundle all of the FutureAssets up to easily manage several assets loading in the background:

FutureAssetBundle bundle = new FutureAssetBundle();
bundle.add( Assets.loadFuture("image.gif", BufferedImage.class) );
bundle.add( Assets.loadFuture("sound.wav", Clip.class) );

BufferedImage image = null;
Clip sound = null;

// game loop
while (running) {
   // do stuff
   // this occurs during the loading screen....
   if (bundle.isComplete()) {
       bundle.loaded(); // notify all FutureAsset implementations the asset has been accepted.
       image = bundle.getAsset("image.gif");
       sound = bundle.getAsset("sound.wav");
       // move from loading to play screen
   } else {
       display bundle.percentComplete();     
   }
   // do other stuff
}

Links:

The Formats and Sources are registered with the Assets class. The Assets class determines the format and source to use for a given request based on extension, requested asset type, the default source, and any registered sources and completes the request.

The Asset class also caches assets to avoid re-retrieving and parsing an asset.

The library can be extended further by adding your own AssetFormat and AssetSource implementations.

Checkout the Test source folder for examples on how to load and use assets created by Azzet.