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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations