use of org.freeplane.features.icon.UserIcon in project freeplane by freeplane.
the class IconStoreFactory method getUserIcons.
private static List<MindIcon> getUserIcons(final File iconDir, final String dir) {
final String[] userIconArray = iconDir.list(new FilenameFilter() {
public boolean accept(final File dir, final String name) {
final int nameLength = name.length();
return nameLength > 4 && name.substring(nameLength - 4).equalsIgnoreCase(".png") || new File(dir, name).isDirectory();
}
});
if (userIconArray == null) {
return Collections.emptyList();
}
final List<MindIcon> icons = new ArrayList<MindIcon>(userIconArray.length);
for (final String fileName : userIconArray) {
final File childDir = new File(iconDir, fileName);
final String fullName = dir + fileName;
if (childDir.isDirectory()) {
final List<MindIcon> childUserIcons = IconStoreFactory.getUserIcons(childDir, fullName + '/');
icons.addAll(childUserIcons);
}
}
for (final String fileName : userIconArray) {
final File childDir = new File(iconDir, fileName);
final String fullName = dir + fileName;
if (childDir.isDirectory()) {
continue;
}
final String iconName = fullName.substring(0, fullName.length() - 4);
final String iconDescription = fileName.substring(0, fileName.length() - 4);
if (iconName.equals("")) {
continue;
}
final UserIcon icon = new UserIcon(iconName, fullName, iconDescription);
icons.add(icon);
}
return icons;
}
Aggregations