Add factory method which constructs a user material which uses a localizable key.

This commit is contained in:
Kevin Ruland 2012-08-04 03:09:36 +00:00
parent 59ef1b0888
commit f9c450c79c

View File

@ -215,6 +215,26 @@ public abstract class Material implements Comparable<Material> {
}
}
/**
* Return a new user defined material of the specified type and localizable key.
*/
public static Material newUserMaterialWithKey(Type type, String key, double density) {
switch (type) {
case LINE:
return new Material.Line(null, key, density, true);
case SURFACE:
return new Material.Surface(null, key, density, true);
case BULK:
return new Material.Bulk(null, key, density, true);
default:
throw new IllegalArgumentException("Unknown material type: " + type);
}
}
public String toStorableString() {
return getType().name() + "|" + key + "|" + name.replace('|', ' ') + '|' + density;