com.threerings.media.image
Class ColorPository.ClassRecord

java.lang.Object
  extended by com.threerings.media.image.ColorPository.ClassRecord
All Implemented Interfaces:
Serializable, Comparable<ColorPository.ClassRecord>
Enclosing class:
ColorPository

public static class ColorPository.ClassRecord
extends Object
implements Serializable, Comparable<ColorPository.ClassRecord>

Used to store information on a class of colors. These are public to simplify the XML parsing process, so pay them no mind.

See Also:
Serialized Form

Field Summary
protected  ColorPository.ColorRecord[] _starters
           
 int classId
          An integer identifier for this class.
 HashIntMap<ColorPository.ColorRecord> colors
          A table of target colors included in this class.
 int defaultId
          The default colorId to use for recoloration in this class, or 0 if there is no default defined.
 String name
          The name of the color class.
 float[] range
          Data identifying the range of colors around the source color that will be recolored when recoloring using this class.
 Color source
          The source color to use when recoloring colors in this class.
 boolean starter
          The default starting legality value for this color class.
 
Constructor Summary
ColorPository.ClassRecord()
           
 
Method Summary
 void addColor(ColorPository.ColorRecord record)
          Used when parsing the color definitions.
 int compareTo(ColorPository.ClassRecord other)
           
 int getColorId(String name)
          Translates a color identified in string form into the id that should be used to look up its information.
 ColorPository.ColorRecord getDefault()
          Get the default ColorRecord defined for this color class, or null if none.
 ColorPository.ColorRecord randomStartingColor()
          Returns a random starting id from the entries in this class.
 ColorPository.ColorRecord randomStartingColor(Random rand)
          Returns a random starting id from the entries in this class.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

classId

public int classId
An integer identifier for this class.


name

public String name
The name of the color class.


source

public Color source
The source color to use when recoloring colors in this class.


range

public float[] range
Data identifying the range of colors around the source color that will be recolored when recoloring using this class.


starter

public boolean starter
The default starting legality value for this color class. See ColorPository.ColorRecord.starter.


defaultId

public int defaultId
The default colorId to use for recoloration in this class, or 0 if there is no default defined.


colors

public HashIntMap<ColorPository.ColorRecord> colors
A table of target colors included in this class.


_starters

protected transient ColorPository.ColorRecord[] _starters
Constructor Detail

ColorPository.ClassRecord

public ColorPository.ClassRecord()
Method Detail

addColor

public void addColor(ColorPository.ColorRecord record)
Used when parsing the color definitions.


getColorId

public int getColorId(String name)
               throws ParseException
Translates a color identified in string form into the id that should be used to look up its information. Throws an exception if no color could be found that associates with that name. FIXME: This lookup could be sped up a lot with some cached data tables if it looked like this function would get called in time critical situations.

Throws:
ParseException

randomStartingColor

public ColorPository.ColorRecord randomStartingColor()
Returns a random starting id from the entries in this class.


randomStartingColor

public ColorPository.ColorRecord randomStartingColor(Random rand)
Returns a random starting id from the entries in this class.


getDefault

public ColorPository.ColorRecord getDefault()
Get the default ColorRecord defined for this color class, or null if none.


compareTo

public int compareTo(ColorPository.ClassRecord other)
Specified by:
compareTo in interface Comparable<ColorPository.ClassRecord>

toString

public String toString()
Overrides:
toString in class Object