Some convenience functions for getting color information entirely by name.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@145 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2007-02-03 00:22:14 +00:00
parent a2da7a8629
commit 9006af28b9
@@ -351,6 +351,29 @@ public class ColorPository implements Serializable
return null;
}
/**
* Looks up a colorization by class and color names.
*/
public Colorization getColorization (String className, String colorName)
{
ClassRecord crec = getClassRecord(className);
if (crec != null) {
int colorId = 0;
try {
colorId = crec.getColorId(colorName);
} catch (ParseException pe) {
Log.info("Error getting colorization by name. [error=" + pe + "]");
return null;
}
ColorRecord color = (ColorRecord)crec.colors.get(colorId);
if (color != null) {
return color.getColorization();
}
}
return null;
}
/**
* Loads up a colorization class by name and logs a warning if it
* doesn't exist.
@@ -389,6 +412,30 @@ public class ColorPository implements Serializable
return (ColorRecord)record.colors.get(colorId);
}
/**
* Looks up the requested color record by class & color names.
*/
public ColorRecord getColorRecord (String className, String colorName)
{
ClassRecord record = getClassRecord(className);
if (record == null) {
Log.warning("Requested unknown color class " +
"[className=" + className + ", colorName=" + colorName + "].");
Thread.dumpStack();
return null;
}
int colorId = 0;
try {
colorId = record.getColorId(colorName);
} catch (ParseException pe) {
Log.info("Error getting color record by name. [error=" + pe + "]");
return null;
}
return (ColorRecord)record.colors.get(colorId);
}
/**
* Adds a fully configured color class record to the pository. This is
* only called by the XML parsing code, so pay it no mind.