Search in sources :

Example 6 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.create(iconName);
        icons.put(iconName, icon);
    }
    return icons;
}
Also used : MindIcon(org.freeplane.features.icon.MindIcon) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with MindIcon

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

the class IconSelectionPlugin method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    final IconRegistry iconRegistry = map.getIconRegistry();
    final ListModel usedIcons = iconRegistry.getIconsAsListModel();
    for (int i = 0; i < usedIcons.getSize(); i++) {
        final Object icon = usedIcons.getElementAt(i);
        if (icon instanceof MindIcon) {
            actions.add(new IconAction((MindIcon) icon));
        }
    }
    final MIconController mIconController = (MIconController) IconController.getController();
    for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
    actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
    actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
    actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
    final ViewController viewController = controller.getViewController();
    final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(viewController.getJFrame(), actions);
    final NodeModel selected = controller.getSelection().getSelected();
    controller.getMapViewManager().scrollNodeToVisible(selected);
    selectionDialog.pack();
    UITools.setDialogLocationRelativeTo(selectionDialog, selected);
    selectionDialog.setModal(true);
    selectionDialog.show();
    final int result = selectionDialog.getResult();
    if (result >= 0) {
        final Action action = (Action) actions.get(result);
        action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
    }
}
Also used : Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) IconSelectionPopupDialog(org.freeplane.core.ui.components.IconSelectionPopupDialog) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ViewController(org.freeplane.features.ui.ViewController) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) NodeModel(org.freeplane.features.map.NodeModel) ViewController(org.freeplane.features.ui.ViewController) ListModel(javax.swing.ListModel) IIconInformation(org.freeplane.features.icon.IIconInformation) IconRegistry(org.freeplane.features.icon.IconRegistry)

Example 8 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)

Example 9 with MindIcon

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

the class ProgressIcons method removeProgressIcons.

/**
 * Removes the progress icons (0%, 25%, 50%, 75%, 100%) from the node
 *
 * @param node : the node from which the progress icons are removed
 */
public static void removeProgressIcons(final NodeModel node) {
    final ProgressUtilities progUtil = new ProgressUtilities();
    if (progUtil.hasProgressIcons(node) || progUtil.hasOKIcon(node)) {
        final MIconController iconController = (MIconController) IconController.getController();
        final String[] progressIconNames = new String[] { "0%", "25%", "50%", "75%", "100%", "button_ok" };
        final List<MindIcon> icons = node.getIcons();
        // remove progress icons
        for (int i = 0; i < icons.size(); i++) {
            String iconName = icons.get(i).getName();
            for (int j = 0; j < progressIconNames.length; j++) {
                if (iconName.equals(progressIconNames[j])) {
                    iconController.removeIcon(node, i);
                    i--;
                    break;
                }
            }
        }
    }
}
Also used : MIconController(org.freeplane.features.icon.mindmapmode.MIconController) MindIcon(org.freeplane.features.icon.MindIcon)

Example 10 with MindIcon

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

the class ProgressIcons method updateProgressIcons.

/**
 * This method increases/ decreases the progress icons.
 * If none is present then the 0% icon is set.
 * At 100% the OK-icon is additionally added
 *
 * @param node : the node to update the icons
 * @param up : true if the progress is increased (0% -> 25% -> 50%...)
 * 				if false the progress is decreased
 */
public static void updateProgressIcons(final NodeModel node, final boolean up) {
    final ProgressUtilities progUtil = new ProgressUtilities();
    final MIconController iconController = (MIconController) IconController.getController();
    String activeIcon = null;
    final List<MindIcon> icons = node.getIcons();
    // get active progress icon and remove it
    if (progUtil.hasProgressIcons(node)) {
        for (int i = 0; i < icons.size(); i++) {
            for (int j = 0; j < iconNames.length; j++) {
                if (icons.get(i).getName().equals(iconNames[j])) {
                    activeIcon = iconNames[j];
                    break;
                }
            }
        }
        ProgressIcons.removeProgressIcons(node);
    }
    // set initial progress icon always 0%
    if (activeIcon == null) {
        ProgressIcons.removeProgressIcons(node);
        iconController.addIcon(node, progressIcons[0], 0);
    } else {
        final int iActiveIcon = Integer.parseInt(activeIcon.substring(0, activeIcon.length() - 1));
        // progress is increased
        if (up) {
            switch(iActiveIcon) {
                case 0:
                    iconController.addIcon(node, progressIcons[1], 0);
                    break;
                case 25:
                    iconController.addIcon(node, progressIcons[2], 0);
                    break;
                case 50:
                    iconController.addIcon(node, progressIcons[3], 0);
                    break;
                case 75:
                    iconController.addIcon(node, progressIcons[4], 0);
                    if (!progUtil.hasOKIcon(node)) {
                        iconController.addIcon(node, OKIcon, 0);
                    }
                    break;
                // at 100% draw an extra OK-icon
                case 100:
                    iconController.addIcon(node, progressIcons[4], 0);
                    iconController.addIcon(node, OKIcon, 0);
                    break;
                default:
                    break;
            }
        } else // progress is decreased
        {
            switch(iActiveIcon) {
                case 25:
                    iconController.addIcon(node, progressIcons[0], 0);
                    break;
                case 50:
                    iconController.addIcon(node, progressIcons[1], 0);
                    break;
                case 75:
                    iconController.addIcon(node, progressIcons[2], 0);
                    break;
                case 100:
                    iconController.addIcon(node, progressIcons[3], 0);
                    break;
                case 0:
                default:
                    break;
            }
        }
    }
}
Also used : MIconController(org.freeplane.features.icon.mindmapmode.MIconController) MindIcon(org.freeplane.features.icon.MindIcon)

Aggregations

MindIcon (org.freeplane.features.icon.MindIcon)24 ArrayList (java.util.ArrayList)8 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)5 NodeModel (org.freeplane.features.map.NodeModel)5 ModeController (org.freeplane.features.mode.ModeController)4 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)3 IconController (org.freeplane.features.icon.IconController)3 Controller (org.freeplane.features.mode.Controller)3 ViewController (org.freeplane.features.ui.ViewController)3 Point (java.awt.Point)2 LinkedHashSet (java.util.LinkedHashSet)2 Action (javax.swing.Action)2 JMenu (javax.swing.JMenu)2 ResourceController (org.freeplane.core.resources.ResourceController)2 IconSelectionPopupDialog (org.freeplane.core.ui.components.IconSelectionPopupDialog)2 MultipleImage (org.freeplane.core.ui.components.MultipleImage)2 FormatController (org.freeplane.features.format.FormatController)2 ScannerController (org.freeplane.features.format.ScannerController)2 UIIcon (org.freeplane.features.icon.UIIcon)2 LinkController (org.freeplane.features.link.LinkController)2