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