use of org.freeplane.features.icon.mindmapmode.MIconController in project freeplane by freeplane.
the class ProgressIcons method updateExtendedProgressIcons.
/**
* This method updates the progress icons dependent of the added external object (svg file)
* The file has a distinct naming scheme from which the progress and the icons to be painted
* are derived.
*
* @param node : the node to update the icons
* @param sFile : the name of the added file.
*/
public static void updateExtendedProgressIcons(final NodeModel node, final String sFile) {
if (sFile.matches(EXTENDED_PROGRESS_ICON_IDENTIFIER)) {
final MIconController iconController = (MIconController) IconController.getController();
ProgressIcons.removeProgressIcons(node);
// add the right progress icon
if (sFile.matches(".*_quarter_.*")) {
final int fileNum = Integer.parseInt(sFile.substring(sFile.lastIndexOf("_") + 1, sFile.lastIndexOf("_") + 3));
switch(fileNum) {
case 0:
iconController.addIcon(node, progressIcons[0], 0);
break;
case 1:
iconController.addIcon(node, progressIcons[1], 0);
break;
case 2:
iconController.addIcon(node, progressIcons[2], 0);
break;
case 3:
iconController.addIcon(node, progressIcons[3], 0);
break;
case 4:
iconController.addIcon(node, progressIcons[4], 0);
iconController.addIcon(node, OKIcon, 0);
break;
default:
iconController.addIcon(node, progressIcons[0], 0);
break;
}
} else if (sFile.matches(".*_tenth_.*")) {
final int fileNum = Integer.parseInt(sFile.substring(sFile.lastIndexOf("_") + 1, sFile.lastIndexOf("_") + 3));
switch(fileNum) {
case 0:
case 1:
iconController.addIcon(node, progressIcons[0], 0);
break;
case 2:
case 3:
iconController.addIcon(node, progressIcons[1], 0);
break;
case 4:
case 5:
case 6:
iconController.addIcon(node, progressIcons[2], 0);
break;
case 7:
case 8:
case 9:
iconController.addIcon(node, progressIcons[3], 0);
break;
case 10:
iconController.addIcon(node, progressIcons[4], 0);
iconController.addIcon(node, OKIcon, 0);
break;
default:
iconController.addIcon(node, progressIcons[0], 0);
break;
}
}
}
}
use of org.freeplane.features.icon.mindmapmode.MIconController 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;
}
}
}
}
use of org.freeplane.features.icon.mindmapmode.MIconController 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.mindmapmode.MIconController in project freeplane by freeplane.
the class HeadlessMModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
modeController.setUserInputListenerFactory(new UserInputListenerFactory(modeController));
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
new MIconController(modeController).install(modeController);
new ProgressFactory().installActions(modeController);
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
new MTextController(modeController).install(modeController);
LinkController.install(new MLinkController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
new RevisionPlugin();
FoldingController.install(new FoldingController());
}
use of org.freeplane.features.icon.mindmapmode.MIconController in project freeplane by freeplane.
the class MModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
final IMouseListener nodeMouseMotionListener = new MNodeMotionListener();
userInputListenerFactory.setNodeMouseMotionListener(nodeMouseMotionListener);
userInputListenerFactory.setNodeMouseWheelListener(new MNodeMouseWheelListener(userInputListenerFactory.getMapMouseWheelListener()));
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
new MIconController(modeController).install(modeController);
new ProgressFactory().installActions(modeController);
final MapController mapController = modeController.getMapController();
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final MTextController textController = new MTextController(modeController);
textController.install(modeController);
LinkController.install(new MLinkController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
userInputListenerFactory.setNodeDragListener(new MNodeDragListener());
userInputListenerFactory.setNodeDropTargetListener(new MNodeDropListener());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
userInputListenerFactory.setNodeKeyListener(new DefaultNodeKeyListener(new IEditHandler() {
public void edit(final KeyEvent e, final FirstAction action, final boolean editLong) {
((MTextController) MTextController.getController(modeController)).getEventQueue().activate(e);
textController.edit(action, editLong);
}
}));
userInputListenerFactory.setNodeMotionListener(new MNodeMotionListener());
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
final FreeplaneToolBar toolbar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
final FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolbar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolbar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, frameController.getStatusBar());
final JTabbedPane formattingPanel = new JTabbedPane();
Box resisableTabs = new CollapseableBoxBuilder(frameController).setPropertyNameBase("styleScrollPaneVisible").createBox(formattingPanel, Direction.RIGHT);
userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, resisableTabs);
final JRootPane rootPane = ((RootPaneContainer) frameController.getMenuComponent()).getRootPane();
final FButtonBar fButtonToolBar = new FButtonBar(rootPane);
UIComponentVisibilityDispatcher.install(frameController, fButtonToolBar, "fbarVisible");
fButtonToolBar.setVisible(ResourceController.getResourceController().getBooleanProperty("fbarVisible"));
userInputListenerFactory.addToolBar("/fbuttons", ViewController.TOP, fButtonToolBar);
userInputListenerFactory.setKeyEventProcessor(new IKeyStrokeProcessor() {
@Override
public boolean processKeyBinding(KeyStroke ks, KeyEvent e) {
return ResourceController.getResourceController().getAcceleratorManager().processKeyBinding(ks, e) || fButtonToolBar.processKeyBinding(ks, e);
}
});
controller.addAction(new ToggleToolbarAction("ToggleFBarAction", "/fbuttons"));
SModeControllerFactory.install();
modeController.addAction(new SetAcceleratorOnNextClickAction());
modeController.addAction(new ShowNotesInMapAction());
// userInputListenerFactory.getMenuBuilder().setAcceleratorChangeListener(fButtonToolBar);
ResourceController.getResourceController().getAcceleratorManager().addAcceleratorChangeListener(modeController, fButtonToolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
new RevisionPlugin();
FoldingController.install(new FoldingController());
uiFactory = new MUIFactory();
mapController.addNodeChangeListener(uiFactory);
mapController.addNodeSelectionListener(uiFactory);
mapController.addMapChangeListener(uiFactory);
controller.getMapViewManager().addMapSelectionListener(uiFactory);
modeController.addExtension(MUIFactory.class, uiFactory);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_name", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
final Container fontBox = uiFactory.createFontBox();
return fontBox;
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_size", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createSizeBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_style", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createStyleBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.UI, "main_toolbar_zoom", new JToolbarComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return controller.getMapViewManager().createZoomBox();
}
}));
// IconController.getController(modeController).addStateIconProvider(new IStateIconProvider() {
// public UIIcon getStateIcon(NodeModel node) {
// final URI link = NodeLinks.getLink(node);
// return wrapIcon(LinkController.getLinkIcon(link, node));
// }
//
// private UIIcon wrapIcon(final Icon linkIcon) {
// UIIcon icon = null;
// if(linkIcon != null) {
// if(linkIcon instanceof UIIcon) {
// icon = (UIIcon) linkIcon;
// }
// else {
// icon = new UIIcon("ownIcon", null) {
// public Icon getIcon() {
// return linkIcon;
// }
// };
// }
// }
// return icon;
// }
// });
}
Aggregations