com.threerings.media.tile.bundle.tools
Class TileSetBundler

java.lang.Object
  extended by com.threerings.media.tile.bundle.tools.TileSetBundler
Direct Known Subclasses:
DirectoryTileSetBundler

public class TileSetBundler
extends Object

The tileset bundler is used to create tileset bundles from a set of XML tileset descriptions in a bundle description file. The bundles contain a serialized representation of the tileset objects along with the actual image files referenced by those tilesets.

The organization of the bundle description file is customizable based on the an XML configuration file provided to the tileset bundler when constructed. The bundler configuration maps XML paths to tileset parsers. An example configuration follows:

 <bundler-config>
   <mapping>
     <path>bundle.tilesets.uniform</path>
     <ruleset>
       com.threerings.media.tile.tools.xml.UniformTileSetRuleSet
     </ruleset>
   </mapping>
   <mapping>
     <path>bundle.tilesets.object</path>
     <ruleset>
       com.threerings.media.tile.tools.xml.ObjectTileSetRuleSet
     </ruleset>
   </mapping>
 </bundler-config>
 
This configuration would be used to parse a bundle description that looked something like the following:
 <bundle>
   <tilesets>
     <uniform>
       <tileset>
         <!-- ... -->
       </tileset>
     </uniform>
     <object>
       <tileset>
         <!-- ... -->
       </tileset>
     </object>
   </tilesets>
 
The class specified in the ruleset element must derive from TileSetRuleSet. The images that will be included in the bundle must be in the same directory as the bundle description file and the tileset descriptions must reference the images without a preceding path.


Nested Class Summary
static class TileSetBundler.Mapping
          Used to parse our configuration.
 
Constructor Summary
TileSetBundler(File configFile)
          Constructs a tileset bundler with the specified bundler config file.
TileSetBundler(File configFile, boolean keepRawPngs, boolean uncompressed)
          Constructs a tileset bundler with the specified bundler config file and whether to keep pngs as-is or if not, re-encode them.
TileSetBundler(String configPath)
          Constructs a tileset bundler with the specified path to a bundler configuration file.
 
Method Summary
 boolean createBundle(File target, TileSetBundle bundle, ImageProvider improv, String imageBase, long newestMod)
          Finish the creation of a tileset bundle jar file.
 boolean createBundle(TileSetIDBroker idBroker, File bundleDesc, File target)
          Creates a tileset bundle at the location specified by the targetPath parameter, based on the description provided via the bundleDesc parameter.
 void createBundle(TileSetIDBroker idBroker, File bundleDesc, String targetPath)
          Creates a tileset bundle at the location specified by the targetPath parameter, based on the description provided via the bundleDesc parameter.
static boolean createBundleJar(File target, TileSetBundle bundle, ImageProvider improv, String imageBase, boolean keepOriginalPngs, boolean uncompressed)
          Create a tileset bundle jar file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TileSetBundler

public TileSetBundler(String configPath)
               throws IOException
Constructs a tileset bundler with the specified path to a bundler configuration file. The configuration file will be loaded and used to configure this tileset bundler.

Throws:
IOException

TileSetBundler

public TileSetBundler(File configFile)
               throws IOException
Constructs a tileset bundler with the specified bundler config file.

Throws:
IOException

TileSetBundler

public TileSetBundler(File configFile,
                      boolean keepRawPngs,
                      boolean uncompressed)
               throws IOException
Constructs a tileset bundler with the specified bundler config file and whether to keep pngs as-is or if not, re-encode them.

Throws:
IOException
Method Detail

createBundle

public void createBundle(TileSetIDBroker idBroker,
                         File bundleDesc,
                         String targetPath)
                  throws IOException
Creates a tileset bundle at the location specified by the targetPath parameter, based on the description provided via the bundleDesc parameter.

Parameters:
idBroker - the tileset id broker that will be used to map tileset names to tileset ids.
bundleDesc - a file object pointing to the bundle description file.
targetPath - the path of the tileset bundle file that will be created.
Throws:
IOException - thrown if an error occurs reading, writing or processing anything.

createBundle

public boolean createBundle(TileSetIDBroker idBroker,
                            File bundleDesc,
                            File target)
                     throws IOException
Creates a tileset bundle at the location specified by the targetPath parameter, based on the description provided via the bundleDesc parameter.

Parameters:
idBroker - the tileset id broker that will be used to map tileset names to tileset ids.
bundleDesc - a file object pointing to the bundle description file.
target - the tileset bundle file that will be created.
Returns:
true if the bundle was rebuilt, false if it was not because the bundle file was newer than all involved source files.
Throws:
IOException - thrown if an error occurs reading, writing or processing anything.

createBundle

public boolean createBundle(File target,
                            TileSetBundle bundle,
                            ImageProvider improv,
                            String imageBase,
                            long newestMod)
                     throws IOException
Finish the creation of a tileset bundle jar file.

Parameters:
target - the tileset bundle file that will be created.
bundle - contains the tilesets we'd like to save out to the bundle.
improv - the image provider.
imageBase - the base directory for getting images for non
newestMod - the most recent modification to any part of the bundle. By default we ignore this since we normally duck out if we're up to date. ObjectTileSet tilesets.
Throws:
IOException

createBundleJar

public static boolean createBundleJar(File target,
                                      TileSetBundle bundle,
                                      ImageProvider improv,
                                      String imageBase,
                                      boolean keepOriginalPngs,
                                      boolean uncompressed)
                               throws IOException
Create a tileset bundle jar file.

Parameters:
target - the tileset bundle file that will be created.
bundle - contains the tilesets we'd like to save out to the bundle.
improv - the image provider.
imageBase - the base directory for getting images for non-ObjectTileSet tilesets.
keepOriginalPngs - bundle up the original PNGs as PNGs instead of converting to the FastImageIO raw format
Throws:
IOException


Copyright © 2011. All Rights Reserved.