Search in sources :

Example 1 with FreeNode

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

the class ChangeNodeLevelController method moveDownwards.

private void moveDownwards(final NodeModel selectedNode) {
    if (!checkSelection()) {
        return;
    }
    final NodeModel selectedParent = selectedNode.getParentNode();
    final List<NodeModel> selectedNodes = Controller.getCurrentController().getSelection().getSortedSelection(true);
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final int ownPosition = selectedParent.getIndex(selectedNode);
    NodeModel directSibling = null;
    for (int i = ownPosition - 1; i >= 0; --i) {
        final NodeModel targetCandidate = (NodeModel) selectedParent.getChildAt(i);
        if (canMoveTo(selectedNode, selectedNodes, targetCandidate)) {
            directSibling = targetCandidate;
            break;
        }
    }
    if (directSibling == null) {
        for (int i = ownPosition + 1; i < selectedParent.getChildCount(); ++i) {
            final NodeModel targetCandidate = (NodeModel) selectedParent.getChildAt(i);
            if (canMoveTo(selectedNode, selectedNodes, targetCandidate)) {
                directSibling = targetCandidate;
                break;
            }
        }
    }
    if (directSibling != null) {
        for (final NodeModel node : selectedNodes) {
            ((FreeNode) Controller.getCurrentModeController().getExtension(FreeNode.class)).undoableDeactivateHook(node);
        }
        mapController.moveNodes(selectedNodes, directSibling, directSibling.getChildCount());
        Controller.getCurrentModeController().getMapController().selectMultipleNodes(selectedNode, selectedNodes);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) FreeNode(org.freeplane.features.map.FreeNode)

Example 2 with FreeNode

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

the class NodeProxy method moveTo.

// Node: R/W
public void moveTo(final Proxy.Node parentNodeProxy, final int position) {
    final NodeModel parentNode = ((NodeProxy) parentNodeProxy).getDelegate();
    final NodeModel movedNode = getDelegate();
    ((FreeNode) Controller.getCurrentModeController().getExtension(FreeNode.class)).undoableDeactivateHook(movedNode);
    boolean oldSide = movedNode.isLeft();
    boolean newSide = parentNode.isRoot() ? oldSide : parentNode.isLeft();
    getMapController().moveNodes(Arrays.asList(movedNode), parentNode, position, newSide, newSide != oldSide);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) FreeNode(org.freeplane.features.map.FreeNode)

Example 3 with FreeNode

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

the class NodeProxy method sortChildrenBy.

@Override
public void sortChildrenBy(Closure<Comparable<Object>> closure) {
    getScriptContext().accessNode(getDelegate());
    NodeModel node = getDelegate();
    final ArrayList<NodeModel> children = new ArrayList<NodeModel>(node.getChildren());
    Collections.sort(children, comparatorByClosureResult(closure));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    int i = 0;
    for (final NodeModel child : children) {
        ((FreeNode) Controller.getCurrentModeController().getExtension(FreeNode.class)).undoableDeactivateHook(child);
        mapController.moveNode(child, i++);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) ArrayList(java.util.ArrayList) FreeNode(org.freeplane.features.map.FreeNode)

Example 4 with FreeNode

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

the class MMapController method moveNodesAsChildren.

public void moveNodesAsChildren(final List<NodeModel> children, final NodeModel target, final boolean isLeft, final boolean changeSide) {
    FreeNode r = Controller.getCurrentModeController().getExtension(FreeNode.class);
    for (NodeModel node : children) {
        final IExtension extension = node.getExtension(FreeNode.class);
        if (extension != null) {
            r.undoableToggleHook(node, extension);
            if (MapStyleModel.FLOATING_STYLE.equals(LogicalStyleModel.getStyle(node)))
                ((MLogicalStyleController) MLogicalStyleController.getController(getMModeController())).setStyle(node, null);
        }
    }
    int position = target.getChildCount();
    moveNodes(children, target, position, isLeft, changeSide);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IExtension(org.freeplane.core.extension.IExtension) FreeNode(org.freeplane.features.map.FreeNode) Point(java.awt.Point)

Aggregations

FreeNode (org.freeplane.features.map.FreeNode)4 NodeModel (org.freeplane.features.map.NodeModel)4 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 IExtension (org.freeplane.core.extension.IExtension)1 MMapController (org.freeplane.features.map.mindmapmode.MMapController)1