use of uk.ac.sussex.gdsc.smlm.data.NamedObject in project GDSC-SMLM by aherbert.
the class SettingsManager method getNames.
/**
* Convert a list of objects into names (e.g. pass in (Object[])enum.getValues()). The first
* letter is capitalised. The rest of the name is converted to lowercase if it is all uppercase.
* Remaining mixed case names are left unchanged.
*
* <p>Used to convert the settings enumerations into names used with dialogs.
*
* @param objects the objects
* @return the names
*/
public static String[] getNames(Object... objects) {
final String[] names = new String[objects.length];
for (int i = 0; i < names.length; i++) {
String name;
if (objects[i] instanceof NamedObject) {
final NamedObject o = (NamedObject) objects[i];
name = getName(o.getName(), o.getShortName());
} else {
name = objects[i].toString();
}
// Capitalise first letter
if (name.length() > 0 && Character.isLowerCase(name.charAt(0))) {
name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
names[i] = name;
}
return names;
}
Aggregations