use of org.freeplane.features.map.NodeRelativePath in project freeplane by freeplane.
the class NodeLinkModel method cloneForSource.
public NodeLinkModel cloneForSource(NodeModel sourceClone) {
final NodeModel source = getSource();
if (sourceClone == source)
return this;
String targetID = getTargetID();
final NodeModel target = getTarget();
if (target != null && target.getParentNode() != null && source.getParentNode() != null) {
final NodeRelativePath nodeRelativePath = new NodeRelativePath(source, target);
final NodeModel commonAncestor = nodeRelativePath.commonAncestor();
final NodeModel ancestorClone = nodeRelativePath.ancestorForBegin(sourceClone);
if (commonAncestor.isCloneOf(ancestorClone)) {
final NodeRelativePath pathAncestorToSource = new NodeRelativePath(commonAncestor, source);
final NodeRelativePath clonePath = new NodeRelativePath(ancestorClone, sourceClone);
if (pathAncestorToSource.equalPathsTo(clonePath)) {
final NodeModel targetClone = nodeRelativePath.pathEnd(ancestorClone);
targetID = targetClone.createID();
}
}
}
return cloneForSource(sourceClone, targetID);
}
Aggregations