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:
@@ -351,6 +351,29 @@ public class ColorPository implements Serializable
|
|||||||
return null;
|
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
|
* Loads up a colorization class by name and logs a warning if it
|
||||||
* doesn't exist.
|
* doesn't exist.
|
||||||
@@ -389,6 +412,30 @@ public class ColorPository implements Serializable
|
|||||||
return (ColorRecord)record.colors.get(colorId);
|
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
|
* Adds a fully configured color class record to the pository. This is
|
||||||
* only called by the XML parsing code, so pay it no mind.
|
* only called by the XML parsing code, so pay it no mind.
|
||||||
|
|||||||
Reference in New Issue
Block a user