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);
}
}
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);
}
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++);
}
}
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);
}
Aggregations