Search in sources :

Example 41 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class GlassPaneNodeSelector method findMapComponent.

// A basic implementation of redispatching events.
private Component findMapComponent(MouseEvent e) {
    final Component glassPane = e.getComponent();
    final Point glassPanePoint = e.getPoint();
    final Container container = SwingUtilities.getRootPane(glassPane).getContentPane();
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, container);
    Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
    if (component instanceof MainView || component instanceof MapView || component instanceof JScrollBar) {
        return component;
    }
    return SwingUtilities.getAncestorOfClass(MapView.class, component);
}
Also used : Container(java.awt.Container) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point) Component(java.awt.Component) JScrollBar(javax.swing.JScrollBar)

Example 42 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class DefaultMapMouseListener method handlePopup.

protected void handlePopup(final MouseEvent e) {
    if (e.isPopupTrigger()) {
        Component popup = null;
        final Component popupForModel;
        final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
        final ModeController modeController = Controller.getCurrentController().getModeController();
        if (mapView != null) {
            final java.lang.Object obj = mapView.detectCollision(e.getPoint());
            popupForModel = LinkController.getController(modeController).getPopupForModel(obj);
        } else {
            popupForModel = null;
        }
        if (popupForModel != null) {
            final ControllerPopupMenuListener popupListener = new ControllerPopupMenuListener();
            popupForModel.addHierarchyListener(popupListener);
            popup = popupForModel;
        } else {
            popup = modeController.getUserInputListenerFactory().getMapPopup();
        }
        Component component = e.getComponent();
        if (popup instanceof JPopupMenu) {
            ((JPopupMenu) popup).show(component, e.getX(), e.getY());
        } else {
            Point locationOnScreen = component.getLocationOnScreen();
            final Component window;
            if (popup instanceof Window) {
                window = popup;
            } else {
                final Frame frame = UITools.getFrame();
                final JDialog d = new JDialog(frame, popup.getName());
                d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                d.setModal(false);
                d.add(popup);
                d.pack();
                d.addWindowFocusListener(new WindowFocusListener() {

                    public void windowLostFocus(WindowEvent e) {
                    }

                    public void windowGainedFocus(WindowEvent e) {
                        frame.addWindowFocusListener(new WindowFocusListener() {

                            public void windowLostFocus(WindowEvent e) {
                            }

                            public void windowGainedFocus(WindowEvent e) {
                                d.setVisible(false);
                                frame.removeWindowFocusListener(this);
                            }
                        });
                        d.removeWindowFocusListener(this);
                    }
                });
                window = d;
            }
            window.setLocation(locationOnScreen.x + e.getX(), locationOnScreen.y + e.getY());
            window.setVisible(true);
        }
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) ModeController(org.freeplane.features.mode.ModeController) Point(java.awt.Point) JPopupMenu(javax.swing.JPopupMenu) ControllerPopupMenuListener(org.freeplane.core.ui.ControllerPopupMenuListener) WindowEvent(java.awt.event.WindowEvent) MapView(org.freeplane.view.swing.map.MapView) JComponent(javax.swing.JComponent) Component(java.awt.Component) JDialog(javax.swing.JDialog) WindowFocusListener(java.awt.event.WindowFocusListener)

Example 43 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class DefaultMapMouseListener method mouseReleased.

public void mouseReleased(final MouseEvent e) {
    final MapView mapView = MapView.getMapView(e.getComponent());
    if (mapView != null)
        mapView.setMoveCursor(false);
    originX = -1;
    originY = -1;
    handlePopup(e);
    e.consume();
}
Also used : MapView(org.freeplane.view.swing.map.MapView)

Example 44 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class DefaultNodeKeyListener method keyPressed.

public void keyPressed(final KeyEvent e) {
    final boolean checkForScrollMap = e.isShiftDown() && e.isControlDown() && e.isAltDown();
    final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    if (mapView == null || SwingUtilities.isDescendingFrom(mapView, e.getComponent()))
        return;
    if (checkForScrollMap) {
        switch(e.getKeyCode()) {
            case KeyEvent.VK_UP:
                mapView.scrollBy(0, -10);
                e.consume();
                return;
            case KeyEvent.VK_DOWN:
                mapView.scrollBy(0, 10);
                e.consume();
                return;
            case KeyEvent.VK_LEFT:
                mapView.scrollBy(-10, 0);
                e.consume();
                return;
            case KeyEvent.VK_RIGHT:
                mapView.scrollBy(10, 0);
                e.consume();
        }
        return;
    }
    if ((e.isAltDown() || e.isControlDown() || e.isMetaDown())) {
        return;
    }
    switch(e.getKeyCode()) {
        case KeyEvent.VK_ENTER:
        case KeyEvent.VK_ESCAPE:
        case KeyEvent.VK_SHIFT:
        case KeyEvent.VK_DELETE:
        case KeyEvent.VK_SPACE:
        case KeyEvent.VK_INSERT:
        case KeyEvent.VK_TAB:
            return;
    }
    final boolean continious = e.isShiftDown();
    switch(e.getKeyCode()) {
        case KeyEvent.VK_UP:
            if (mapView.selectUp(continious))
                e.consume();
            return;
        case KeyEvent.VK_DOWN:
            if (mapView.selectDown(continious))
                e.consume();
            return;
        case KeyEvent.VK_LEFT:
            if (mapView.selectLeft(continious))
                e.consume();
            return;
        case KeyEvent.VK_RIGHT:
            if (mapView.selectRight(continious))
                e.consume();
            return;
        case KeyEvent.VK_PAGE_UP:
            if (mapView.selectPageUp(continious))
                e.consume();
            return;
        case KeyEvent.VK_PAGE_DOWN:
            if (mapView.selectPageDown(continious))
                e.consume();
            return;
        case KeyEvent.VK_HOME:
        case KeyEvent.VK_END:
        case KeyEvent.VK_BACK_SPACE:
            if (editHandler != null) {
                editHandler.edit(e, FirstAction.EDIT_CURRENT, false);
            }
            return;
        case KeyEvent.VK_CONTEXT_MENU:
            final ModeController modeController = Controller.getCurrentModeController();
            final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
            final NodeView nodeView = mapView.getNodeView(node);
            final JPopupMenu popupmenu = modeController.getUserInputListenerFactory().getNodePopupMenu();
            if (popupmenu != null) {
                popupmenu.addHierarchyListener(new ControllerPopupMenuListener());
                final MainView mainView = nodeView.getMainView();
                popupmenu.show(mainView, mainView.getX(), mainView.getY());
            }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ControllerPopupMenuListener(org.freeplane.core.ui.ControllerPopupMenuListener) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) JPopupMenu(javax.swing.JPopupMenu)

Example 45 with MapView

use of org.freeplane.view.swing.map.MapView in project freeplane by freeplane.

the class EvaluateAllAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MapModel map = Controller.getCurrentController().getMap();
    org.freeplane.plugin.script.FormulaUtils.clearCache(map);
    MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    mapView.getRoot().updateAll();
}
Also used : MapView(org.freeplane.view.swing.map.MapView) MapModel(org.freeplane.features.map.MapModel)

Aggregations

MapView (org.freeplane.view.swing.map.MapView)55 NodeView (org.freeplane.view.swing.map.NodeView)20 ModeController (org.freeplane.features.mode.ModeController)19 Point (java.awt.Point)15 NodeModel (org.freeplane.features.map.NodeModel)13 Controller (org.freeplane.features.mode.Controller)11 Component (java.awt.Component)9 MainView (org.freeplane.view.swing.map.MainView)9 Dimension (java.awt.Dimension)8 JComponent (javax.swing.JComponent)8 MMapController (org.freeplane.features.map.mindmapmode.MMapController)7 ResourceController (org.freeplane.core.resources.ResourceController)6 MapController (org.freeplane.features.map.MapController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)5 IMapViewManager (org.freeplane.features.ui.IMapViewManager)5 Color (java.awt.Color)4 Rectangle (java.awt.Rectangle)4 LocationController (org.freeplane.features.nodelocation.LocationController)4 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4