Search in sources :

Example 76 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class DefaultMouseWheelListener method mouseWheelMoved.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.modes.ModeController.MouseWheelEventHandler#handleMouseWheelEvent
	 * (java.awt.event.MouseWheelEvent)
	 */
public void mouseWheelMoved(final MouseWheelEvent e) {
    final MapView mapView = (MapView) e.getSource();
    final ModeController mController = mapView.getModeController();
    if (mController.isBlocked()) {
        return;
    }
    final Set<IMouseWheelEventHandler> registeredMouseWheelEventHandler = mController.getUserInputListenerFactory().getMouseWheelEventHandlers();
    for (final IMouseWheelEventHandler handler : registeredMouseWheelEventHandler) {
        final boolean result = handler.handleMouseWheelEvent(e);
        if (result) {
            return;
        }
    }
    if ((e.getModifiers() & DefaultMouseWheelListener.ZOOM_MASK) != 0) {
        float newZoomFactor = 1f + Math.abs((float) e.getWheelRotation()) / 10f;
        if (e.getWheelRotation() < 0) {
            newZoomFactor = 1 / newZoomFactor;
        }
        final float oldZoom = ((MapView) e.getComponent()).getZoom();
        float newZoom = oldZoom / newZoomFactor;
        newZoom = (float) Math.rint(newZoom * 1000f) / 1000f;
        newZoom = Math.max(1f / 32f, newZoom);
        newZoom = Math.min(32f, newZoom);
        if (newZoom != oldZoom) {
            Controller.getCurrentController().getMapViewManager().setZoom(newZoom);
        }
    } else if ((e.getModifiers() & DefaultMouseWheelListener.HORIZONTAL_SCROLL_MASK) != 0) {
        ((MapView) e.getComponent()).scrollBy(DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation(), 0);
    } else {
        ((MapView) e.getComponent()).scrollBy(0, DefaultMouseWheelListener.SCROLL_SKIPS * e.getWheelRotation());
    }
}
Also used : IMouseWheelEventHandler(org.freeplane.core.ui.IMouseWheelEventHandler) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController)

Example 77 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class UserInputListenerFactory method updateModeMenu.

private void updateModeMenu() {
    if (!useRibbonMenu()) {
        getMenuBuilder(MenuBuilder.class).removeChildElements(FreeplaneMenuBar.MODES_MENU);
        Controller controller = Controller.getCurrentController();
        for (final String key : new LinkedList<String>(controller.getModes())) {
            final AFreeplaneAction modesMenuActionListener = new ModesMenuActionListener(key, controller);
            final ModeController modeController = controller.getModeController();
            final boolean isSelected;
            if (modeController != null) {
                isSelected = modeController.getModeName().equals(key);
            } else {
                isSelected = false;
            }
            getMenuBuilder(MenuBuilder.class).addRadioItem(FreeplaneMenuBar.MODES_MENU, modesMenuActionListener, isSelected);
            ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MenuBuilder(org.freeplane.core.ui.MenuBuilder) LinkedList(java.util.LinkedList)

Example 78 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MMapMouseListener method mouseClicked.

@Override
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2 && Compat.isCtrlEvent(e)) {
        final MapView mapView = (MapView) e.getComponent();
        final Object object = mapView.detectCollision(new Point(originX, originY));
        if (object != null)
            return;
        final ModeController modeController = Controller.getCurrentModeController();
        final IExtension freeNode = modeController.getExtension(FreeNode.class);
        if (freeNode != null && modeController instanceof MModeController) {
            final JComponent rootContent = mapView.getRoot().getMainView();
            final Point contentPt = new Point();
            UITools.convertPointToAncestor(rootContent, contentPt, mapView);
            final float zoom = mapView.getZoom();
            final Point eventPoint = e.getPoint();
            int x = (int) ((eventPoint.x - contentPt.x) / zoom);
            final int y = (int) ((eventPoint.y - contentPt.y) / zoom);
            final int rootContentNormalWidth = (int) (rootContent.getWidth() / zoom);
            final boolean newNodeIsLeft = x < rootContentNormalWidth / 2;
            if (newNodeIsLeft) {
                x = rootContentNormalWidth - x;
            }
            final Point pt = new Point(x, y);
            ((MMapController) modeController.getMapController()).addFreeNode(pt, newNodeIsLeft);
        }
    } else
        super.mouseClicked(e);
}
Also used : IExtension(org.freeplane.core.extension.IExtension) MMapController(org.freeplane.features.map.mindmapmode.MMapController) JComponent(javax.swing.JComponent) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) Point(java.awt.Point) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 79 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
@Override
public void start(final BundleContext context) throws Exception {
    final Hashtable<String, String[]> props = new Hashtable<String, String[]>();
    props.put("mode", new String[] { MModeController.MODENAME /*TODO: other modes too?*/
    });
    context.registerService(IModeControllerExtensionProvider.class.getName(), new IModeControllerExtensionProvider() {

        @Override
        public void installExtension(ModeController modeController) {
            final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
            final $$$$Action action = new $$$$Action();
            modeController.addAction(action);
            modeController.addMenuContributor(new IMenuContributor() {

                @Override
                public void updateMenus(ModeController modeController, MenuBuilder builder) {
                    menuBuilder.addAction("/menu_bar/file", action, MenuBuilder.AS_CHILD);
                }
            });
        }
    }, props);
}
Also used : IMenuContributor(org.freeplane.core.ui.IMenuContributor) Hashtable(java.util.Hashtable) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) IModeControllerExtensionProvider(org.freeplane.main.osgi.IModeControllerExtensionProvider) MenuBuilder(org.freeplane.core.ui.MenuBuilder)

Example 80 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MNodeMotionListener method adjustNodeIndices.

private void adjustNodeIndices(final NodeView nodeV) {
    NodeModel[] selectedsBackup = null;
    final NodeModel node = nodeV.getModel();
    if (FreeNode.isFreeNode(node)) {
        selectedsBackup = adjustNodeIndexBackupSelection(nodeV, selectedsBackup);
    } else {
        final MapView map = nodeV.getMap();
        final NodeModel[] siblingNodes = node.getParentNode().getChildren().toArray(new NodeModel[] {});
        for (NodeModel sibling : siblingNodes) {
            if (FreeNode.isFreeNode(sibling)) {
                final NodeView siblingV = map.getNodeView(sibling);
                selectedsBackup = adjustNodeIndexBackupSelection(siblingV, selectedsBackup);
            }
        }
    }
    if (selectedsBackup != null) {
        final ModeController modeController = nodeV.getMap().getModeController();
        final Controller controller = modeController.getController();
        controller.getSelection().replaceSelection(selectedsBackup);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) MTextController(org.freeplane.features.text.mindmapmode.MTextController) ResourceController(org.freeplane.core.resources.ResourceController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)222 NodeModel (org.freeplane.features.map.NodeModel)90 Controller (org.freeplane.features.mode.Controller)56 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)48 MapModel (org.freeplane.features.map.MapModel)37 IActor (org.freeplane.core.undo.IActor)31 MapController (org.freeplane.features.map.MapController)30 ResourceController (org.freeplane.core.resources.ResourceController)29 MMapController (org.freeplane.features.map.mindmapmode.MMapController)20 File (java.io.File)17 TextController (org.freeplane.features.text.TextController)17 Color (java.awt.Color)16 Point (java.awt.Point)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MapView (org.freeplane.view.swing.map.MapView)13 NodeView (org.freeplane.view.swing.map.NodeView)13 Component (java.awt.Component)12 URL (java.net.URL)12 LinkController (org.freeplane.features.link.LinkController)12 MenuBuilder (org.freeplane.core.ui.MenuBuilder)11