Search in sources :

Example 1 with MindIcon

use of org.freeplane.features.icon.MindIcon in project freeplane by freeplane.

the class MenuUtils method insertAsNodeModel.

private static NodeModel insertAsNodeModel(final NodeModel nodeModel, final DefaultMutableTreeNode treeNode, final MapController mapController) {
    final MenuEntry menuEntry = (MenuEntry) treeNode.getUserObject();
    final String text = menuEntry.getKeyStroke() == null ? menuEntry.getLabel() : menuEntry.getLabel() + ": " + MenuUtils.formatKeyStroke(menuEntry.getKeyStroke());
    final NodeModel newNodeModel = mapController.newNode(text, nodeModel.getMap());
    if (!treeNode.isLeaf()) {
        newNodeModel.setFolded(true);
    }
    if (menuEntry.getIconKey() != null) {
        final MindIcon mindIcon = menuEntry.createMindIcon();
        if (mindIcon != null)
            newNodeModel.addIcon(mindIcon);
    }
    nodeModel.insert(newNodeModel);
    return newNodeModel;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MindIcon(org.freeplane.features.icon.MindIcon)

Example 2 with MindIcon

use of org.freeplane.features.icon.MindIcon in project freeplane by freeplane.

the class IconStoreFactory method getIcons.

private static Map<String, MindIcon> getIcons(final String groupName) {
    final String[] iconNames = RESOURCE_CONTROLLER.getProperty(String.format(GROUP_KEY, groupName)).split(SEPARATOR);
    final Map<String, MindIcon> icons = new LinkedHashMap<String, MindIcon>(iconNames.length);
    for (final String iconName : iconNames) {
        final MindIcon icon = MindIconFactory.createIcon(iconName);
        icons.put(iconName, icon);
    }
    return icons;
}
Also used : MindIcon(org.freeplane.features.icon.MindIcon) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with MindIcon

use of org.freeplane.features.icon.MindIcon 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) {
            return hasValidIconFileExtension(name) || new File(dir, name).isDirectory();
        }
    });
    Arrays.sort(userIconArray, new Comparator<String>() {

        @Override
        public int compare(String o1, String o2) {
            return getIconFileNameWithoutExtension(o1).compareTo(getIconFileNameWithoutExtension(o2));
        }
    });
    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);
        if (childDir.isDirectory()) {
            final String fullName = dir + fileName;
            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)

Example 4 with MindIcon

use of org.freeplane.features.icon.MindIcon in project freeplane by freeplane.

the class MIconController method listStandardIconKeys.

/**
 * lists all icons that are available in the icon selection dialog. This may include user icons
 * if there are some installed.
 */
public static List<String> listStandardIconKeys() {
    // the source of this list is the property "icons.list" in freeplane.properties
    ArrayList<String> result = new ArrayList<String>();
    final MIconController mIconController = (MIconController) IconController.getController();
    for (MindIcon mindIcon : mIconController.getMindIcons()) result.add(mindIcon.getName());
    return result;
}
Also used : ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon)

Example 5 with MindIcon

use of org.freeplane.features.icon.MindIcon in project freeplane by freeplane.

the class MIconController method removeIcon.

public int removeIcon(final NodeModel node, final int position) {
    final int size = node.getIcons().size();
    final int index = position >= 0 ? position : size + position;
    if (size == 0 || size <= index) {
        return size;
    }
    final IActor actor = new IActor() {

        private final MindIcon icon = node.getIcon(index);

        public void act() {
            node.removeIcon(index);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, icon, null);
        }

        public String getDescription() {
            return "removeIcon";
        }

        public void undo() {
            node.addIcon(icon, index);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, null, icon);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
    return node.getIcons().size();
}
Also used : IActor(org.freeplane.core.undo.IActor) MindIcon(org.freeplane.features.icon.MindIcon) Point(java.awt.Point)

Aggregations

MindIcon (org.freeplane.features.icon.MindIcon)20 ArrayList (java.util.ArrayList)6 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)3 NodeModel (org.freeplane.features.map.NodeModel)3 Point (java.awt.Point)2 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 MultipleImage (org.freeplane.core.ui.components.MultipleImage)2 IconController (org.freeplane.features.icon.IconController)2 UIIcon (org.freeplane.features.icon.UIIcon)2 ModeController (org.freeplane.features.mode.ModeController)2 Component (java.awt.Component)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 URL (java.net.URL)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 NoSuchElementException (java.util.NoSuchElementException)1 Action (javax.swing.Action)1 JMenu (javax.swing.JMenu)1 ResourceController (org.freeplane.core.resources.ResourceController)1