Search in sources :

Example 1 with UserIcon

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;
}
Also used : FilenameFilter(java.io.FilenameFilter) UserIcon(org.freeplane.features.icon.UserIcon) ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon) File(java.io.File)

Aggregations

File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 MindIcon (org.freeplane.features.icon.MindIcon)1 UserIcon (org.freeplane.features.icon.UserIcon)1