An Asset Loading Library in Java. Load assets from any source (classpath, file system, web, database, etc) in many formats (XML, JSON, audio, images, etc) either directly or in a background process.
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.settings
Deprecated/org/magnos/asset
Examples/org/magnos/asset
Formats/org/magnos/asset
Server/org/magnos/asset/server
Source/org/magnos/asset
Test
build
lib
.classpath
.gitignore
.project
LICENSE.txt
README.md
TODO.txt
build.properties
build.xml

README.md

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:

  • Classpath
  • File-System
  • Database
  • JAR
  • FTP
  • HTTP/HTTPS
  • UDP
  • TCP
  • SSL
  • UDP Multicast

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.