Search in sources :

Example 6 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class UndoHandler method addActor.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.base.undo.UndoHandler#addActor(freeplane.base.undo.UndoableActor
	 * )
	 */
public void addActor(final IActor actor) {
    resetRedo();
    actorList.commitDelay = COMMIT_DELAY;
    final long currentTime = System.currentTimeMillis();
    if (deactivated) {
        if (!actionFrameStarted && currentTime - timeOfLastAdd > UndoHandler.TIME_TO_BEGIN_NEW_ACTION) {
            deactivated = false;
        } else {
            if (actorList.size() > 0) {
                actorList.clear();
                actorIterator = actorList.listIterator();
            }
            return;
        }
    }
    if ((actorList.size() > 0) && (actionFrameStarted || currentTime - timeOfLastAdd < UndoHandler.TIME_TO_BEGIN_NEW_ACTION)) {
        CompoundActor compoundActor = (CompoundActor) actorIterator.previous();
        compoundActor.add(actor);
        actorIterator.next();
    } else {
        CompoundActor compoundActor = new CompoundActor();
        final Controller controller = Controller.getCurrentController();
        if (map == controller.getMap()) {
            final IMapSelection selection = controller.getSelection();
            final SelectionActor selectionActor = SelectionActor.create(selection);
            compoundActor.add(selectionActor);
        }
        compoundActor.add(actor);
        actorIterator.add(compoundActor);
        final int maxEntries = UndoHandler.MAX_ENTRIES;
        while (actorList.size() > maxEntries) {
            actorList.removeFirst();
            actorIterator = actorList.listIterator(actorList.size());
        }
    }
    startActionFrame();
    timeOfLastAdd = currentTime;
    fireStateChanged();
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection) Controller(org.freeplane.features.mode.Controller) ViewController(org.freeplane.features.ui.ViewController)

Example 7 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class LastOpenedList method selectLastVisitedNode.

private boolean selectLastVisitedNode(RecentFile recentFile) {
    if (recentFile != null && recentFile.lastVisitedNodeId != null) {
        final MapModel map = Controller.getCurrentController().getMap();
        final NodeModel node = map.getNodeForID(recentFile.lastVisitedNodeId);
        if (node != null && node.hasVisibleContent()) {
            IMapSelection selection = Controller.getCurrentController().getSelection();
            // don't override node selection done by UriManager.loadURI()
            if (selection.isSelected(map.getRootNode()))
                selection.selectAsTheOnlyOneSelected(node);
            return true;
        }
    }
    return false;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 8 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class MNodeMouseWheelListener method mouseWheelMoved.

@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    if (!e.isAltDown()) {
        super.mouseWheelMoved(e);
        return;
    }
    final MainView view = (MainView) e.getComponent();
    final MapView map = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, view);
    if (map.usesLayoutSpecificMaxNodeWidth())
        return;
    final int wheelRotation = e.getWheelRotation();
    final NodeView nodeView = view.getNodeView();
    if (!nodeView.isSelected())
        map.selectAsTheOnlyOneSelected(nodeView);
    final double factor = e.isControlDown() ? 1 : 6 * LengthUnits.pt.factor();
    double newZoomedWidth = Math.max((view.getWidth() - wheelRotation * factor) / map.getZoom(), 0);
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    Quantity<LengthUnits> newZoomedWidthQuantity = LengthUnits.pixelsInPt(newZoomedWidth);
    final ModeController modeController = map.getModeController();
    final MNodeStyleController styleController = (MNodeStyleController) modeController.getExtension(NodeStyleController.class);
    selection.keepNodePosition(nodeView.getModel(), 0f, 0f);
    for (final NodeModel node : selection.getSelection()) {
        styleController.setMinNodeWidth(node, newZoomedWidthQuantity);
        styleController.setMaxNodeWidth(node, newZoomedWidthQuantity);
    }
}
Also used : LengthUnits(org.freeplane.core.ui.LengthUnits) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) IMapSelection(org.freeplane.features.map.IMapSelection) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView)

Example 9 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class CopyAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final IMapSelection selection = controller.getSelection();
    if (selection != null) {
        final ClipboardController clipboardController = (ClipboardController) modeController.getExtension(ClipboardController.class);
        final Transferable copy = clipboardController.copy(selection);
        if (copy != null) {
            clipboardController.setClipboardContents(copy);
        }
    }
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection) Transferable(java.awt.datatransfer.Transferable) ModeController(org.freeplane.features.mode.ModeController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 10 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class LinkController method addLinks.

private void addLinks(final JComponent arrowLinkPopup, final NodeModel source) {
    final IMapSelection selection = Controller.getCurrentModeController().getController().getSelection();
    if (!selection.isSelected(source)) {
        GotoLinkNodeAction gotoLinkNodeAction = new GotoLinkNodeAction(this, source);
        gotoLinkNodeAction.configureText("follow_graphical_link", source);
        addAction(arrowLinkPopup, gotoLinkNodeAction);
    }
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection)

Aggregations

IMapSelection (org.freeplane.features.map.IMapSelection)47 NodeModel (org.freeplane.features.map.NodeModel)33 Controller (org.freeplane.features.mode.Controller)12 ModeController (org.freeplane.features.mode.ModeController)12 ResourceController (org.freeplane.core.resources.ResourceController)7 MapController (org.freeplane.features.map.MapController)7 Component (java.awt.Component)6 MapModel (org.freeplane.features.map.MapModel)4 Container (java.awt.Container)3 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 MTextController (org.freeplane.features.text.mindmapmode.MTextController)3 NodeView (org.freeplane.view.swing.map.NodeView)3 Point (java.awt.Point)2 Window (java.awt.Window)2 WindowEvent (java.awt.event.WindowEvent)2 ArrayList (java.util.ArrayList)2 JComponent (javax.swing.JComponent)2 JPopupMenu (javax.swing.JPopupMenu)2 JRootPane (javax.swing.JRootPane)2