Search in sources :

Example 11 with IMapSelection

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

the class AddLocalLinkAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final List<NodeModel> selecteds = selection.getOrderedSelection();
    final int size = selecteds.size();
    if (size < 2) {
        Controller.getCurrentController();
        UITools.errorMessage(TextUtils.getText("less_than_two_selected_nodes"));
        return;
    }
    final NodeModel target = selecteds.get(size - 1);
    final String targetId = (target).createID();
    for (NodeModel source : selecteds) {
        if (source != target)
            ((MLinkController) LinkController.getController()).setLink(source, ("#" + targetId), LinkController.LINK_ABSOLUTE);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 12 with IMapSelection

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

the class Filter method applyFilter.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.controller.filter.Filter#applyFilter(freeplane.modes.MindMap)
	 */
public void applyFilter(Object source, final MapModel map, final boolean force) {
    if (map == null) {
        return;
    }
    try {
        displayFilterStatus();
        Controller.getCurrentController().getViewController().setWaitingCursor(true);
        final Filter oldFilter = map.getFilter();
        map.setFilter(this);
        if (force || !isConditionStronger(oldFilter)) {
            final NodeModel root = map.getRootNode();
            resetFilter(root);
            if (filterChildren(root, checkNode(root), false)) {
                addFilterResult(root, FilterInfo.FILTER_SHOW_ANCESTOR);
            }
        }
        final IMapSelection selection = Controller.getCurrentController().getSelection();
        final NodeModel selected = selection.getSelected();
        final NodeModel selectedVisible = selected.getVisibleAncestorOrSelf();
        selection.keepNodePosition(selectedVisible, 0.5f, 0.5f);
        refreshMap(source, map);
        selectVisibleNode();
    } finally {
        Controller.getCurrentController().getViewController().setWaitingCursor(false);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 13 with IMapSelection

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

the class MMapController method moveNodesInGivenDirection.

public void moveNodesInGivenDirection(NodeModel selected, Collection<NodeModel> movedNodes, final int direction) {
    final List<NodeModel> mySelecteds = new ArrayList<NodeModel>(movedNodes);
    final Comparator<Object> comparator = (direction == -1) ? null : new Comparator<Object>() {

        public int compare(final Object o1, final Object o2) {
            final int i1 = ((Integer) o1).intValue();
            final int i2 = ((Integer) o2).intValue();
            return i2 - i1;
        }
    };
    if (mySelecteds.size() == 0)
        return;
    Collection<NodeModel> selectedNodes = new ArrayList<NodeModel>(getSelectedNodes());
    final NodeModel parent = mySelecteds.get(0).getParentNode();
    if (parent != null) {
        final Vector<NodeModel> sortedChildren = getSortedSiblings(parent);
        final TreeSet<Integer> range = new TreeSet<Integer>(comparator);
        for (final NodeModel node : mySelecteds) {
            if (node.getParentNode() != parent) {
                LogUtils.warn("Not all selected nodes have the same parent.");
                return;
            }
            range.add(new Integer(sortedChildren.indexOf(node)));
        }
        Integer last = range.iterator().next();
        for (final Integer newInt : range) {
            if (Math.abs(newInt.intValue() - last.intValue()) > 1) {
                LogUtils.warn("Not adjacent nodes. Skipped. ");
                return;
            }
            last = newInt;
        }
        for (final Integer position : range) {
            final NodeModel node = sortedChildren.get(position.intValue());
            moveSingleNodeInGivenDirection(node, direction);
        }
        final IMapSelection selection = Controller.getCurrentController().getSelection();
        selection.selectAsTheOnlyOneSelected(selected);
        for (NodeModel selectedNode : selectedNodes) {
            selection.makeTheSelected(selectedNode);
        }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) TreeSet(java.util.TreeSet) IMapSelection(org.freeplane.features.map.IMapSelection) ArrayList(java.util.ArrayList)

Example 14 with IMapSelection

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

the class CenterSelectedNodeAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final Component mapView = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    final JRootPane rootPane = SwingUtilities.getRootPane(mapView);
    if (!rootPane.isValid()) {
        rootPane.revalidate();
    }
    selection.centerNode(selection.getSelected());
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection) JRootPane(javax.swing.JRootPane) Component(java.awt.Component)

Example 15 with IMapSelection

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

the class DefaultMapMouseListener method mouseClicked.

public void mouseClicked(final MouseEvent e) {
    final Object source = e.getSource();
    if (!(source instanceof MapView))
        return;
    final MapView map = (MapView) source;
    final Controller controller = map.getModeController().getController();
    final IMapSelection selection = controller.getSelection();
    if (selection != null) {
        final NodeModel selected = selection.getSelected();
        if (selected != null)
            controller.getMapViewManager().getComponent(selected).requestFocusInWindow();
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MapView(org.freeplane.view.swing.map.MapView) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LinkController(org.freeplane.features.link.LinkController)

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