com.threerings.media.image
Class ColorPository

java.lang.Object
  extended by com.threerings.media.image.ColorPository
All Implemented Interfaces:
Serializable

public class ColorPository
extends Object
implements Serializable

A repository of image recoloration information. It was called the recolor repository but the re-s cancelled one another out.

See Also:
Serialized Form

Nested Class Summary
static class ColorPository.ClassRecord
          Used to store information on a class of colors.
static class ColorPository.ColorRecord
          Used to store information on a particular color.
 
Field Summary
protected  HashIntMap<ColorPository.ClassRecord> _classes
          Our mapping from class names to class records.
protected static String CONFIG_PATH
          The path (relative to the resource directory) at which the serialized recolorization repository should be loaded and stored.
 
Constructor Summary
ColorPository()
           
 
Method Summary
 void addClass(ColorPository.ClassRecord record)
          Adds a fully configured color class record to the pository.
 Iterator<ColorPository.ClassRecord> enumerateClasses()
          Returns an iterator over all color classes in this pository.
 int[] enumerateColorIds(String className)
          Returns an array containing the ids of the colors in the specified class.
 ColorPository.ColorRecord[] enumerateColors(String className)
          Returns an array containing the records for the colors in the specified class.
 Collection<ColorPository.ClassRecord> getClasses()
           
 ColorPository.ClassRecord getClassRecord(int classId)
          Looks up the requested color class record.
 ColorPository.ClassRecord getClassRecord(String className)
          Loads up a colorization class by name and logs a warning if it doesn't exist.
 Colorization getColorization(int colorPrint)
          Looks up a colorization by color print.
 Colorization getColorization(int classId, int colorId)
          Looks up a colorization by id.
 Colorization getColorization(String className, int colorId)
          Looks up a colorization by name.
 Colorization getColorization(String className, String colorName)
          Looks up a colorization by class and color names.
 ColorPository.ColorRecord getColorRecord(int classId, int colorId)
          Looks up the requested color record.
 ColorPository.ColorRecord getColorRecord(String className, String colorName)
          Looks up the requested color record by class & color names.
 ColorPository.ColorRecord getRandomStartingColor(String className)
          Returns a random starting color from the specified color class.
 ColorPository.ColorRecord getRandomStartingColor(String className, Random rand)
          Returns a random starting color from the specified color class.
 boolean isLegalStartColor(int colorPrint)
          Returns true if the specified color is legal for use at character creation time. false is always returned for non-existent colors or classes.
 boolean isLegalStartColor(int classId, int colorId)
          Returns true if the specified color is legal for use at character creation time. false is always returned for non-existent colors or classes.
static ColorPository loadColorPository(InputStream source)
          Loads up a serialized ColorPository from the supplied resource manager.
static ColorPository loadColorPository(ResourceManager rmgr)
          Loads up a serialized ColorPository from the supplied resource manager.
static void saveColorPository(ColorPository posit, File root)
          Serializes and saves color pository to the supplied file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_classes

protected HashIntMap<ColorPository.ClassRecord> _classes
Our mapping from class names to class records.


CONFIG_PATH

protected static final String CONFIG_PATH
The path (relative to the resource directory) at which the serialized recolorization repository should be loaded and stored.

See Also:
Constant Field Values
Constructor Detail

ColorPository

public ColorPository()
Method Detail

enumerateClasses

public Iterator<ColorPository.ClassRecord> enumerateClasses()
Returns an iterator over all color classes in this pository.


getClasses

public Collection<ColorPository.ClassRecord> getClasses()

enumerateColors

public ColorPository.ColorRecord[] enumerateColors(String className)
Returns an array containing the records for the colors in the specified class.


enumerateColorIds

public int[] enumerateColorIds(String className)
Returns an array containing the ids of the colors in the specified class.


isLegalStartColor

public boolean isLegalStartColor(int colorPrint)
Returns true if the specified color is legal for use at character creation time. false is always returned for non-existent colors or classes.


isLegalStartColor

public boolean isLegalStartColor(int classId,
                                 int colorId)
Returns true if the specified color is legal for use at character creation time. false is always returned for non-existent colors or classes.


getRandomStartingColor

public ColorPository.ColorRecord getRandomStartingColor(String className)
Returns a random starting color from the specified color class.


getRandomStartingColor

public ColorPository.ColorRecord getRandomStartingColor(String className,
                                                        Random rand)
Returns a random starting color from the specified color class.


getColorization

public Colorization getColorization(int classId,
                                    int colorId)
Looks up a colorization by id.


getColorization

public Colorization getColorization(int colorPrint)
Looks up a colorization by color print.


getColorization

public Colorization getColorization(String className,
                                    int colorId)
Looks up a colorization by name.


getColorization

public Colorization getColorization(String className,
                                    String colorName)
Looks up a colorization by class and color names.


getClassRecord

public ColorPository.ClassRecord getClassRecord(String className)
Loads up a colorization class by name and logs a warning if it doesn't exist.


getColorRecord

public ColorPository.ColorRecord getColorRecord(int classId,
                                                int colorId)
Looks up the requested color record.


getColorRecord

public ColorPository.ColorRecord getColorRecord(String className,
                                                String colorName)
Looks up the requested color record by class & color names.


getClassRecord

public ColorPository.ClassRecord getClassRecord(int classId)
Looks up the requested color class record.


addClass

public void addClass(ColorPository.ClassRecord record)
Adds a fully configured color class record to the pository. This is only called by the XML parsing code, so pay it no mind.


loadColorPository

public static ColorPository loadColorPository(ResourceManager rmgr)
Loads up a serialized ColorPository from the supplied resource manager.


loadColorPository

public static ColorPository loadColorPository(InputStream source)
Loads up a serialized ColorPository from the supplied resource manager.


saveColorPository

public static void saveColorPository(ColorPository posit,
                                     File root)
Serializes and saves color pository to the supplied file.