use of org.freeplane.features.map.Clones in project freeplane by freeplane.
the class NodeLinkModel method clones.
public Collection<NodeLinkModel> clones() {
final Clones sourceNodeClones = getSource().subtreeClones();
if (sourceNodeClones.size() == 1)
return Arrays.<NodeLinkModel>asList(this);
ArrayList<NodeLinkModel> clones = new ArrayList<NodeLinkModel>(sourceNodeClones.size());
for (NodeModel sourceClone : sourceNodeClones) {
final NodeLinkModel cloneForSource = cloneForSource(sourceClone);
if (cloneForSource != null)
clones.add(cloneForSource);
}
return clones;
}
use of org.freeplane.features.map.Clones in project freeplane by freeplane.
the class MMapController method getPathToNearestTargetClone.
private NodeRelativePath getPathToNearestTargetClone(final NodeModel source, final NodeModel target) {
if (source == target)
return new NodeRelativePath(source, target);
final Clones targetClones = target.subtreeClones();
final int pathNumber = targetClones.size();
if (pathNumber == 1)
return new NodeRelativePath(source, target);
Collection<NodeRelativePath> paths = new ArrayList<>(pathNumber);
for (NodeModel targetClone : targetClones) paths.add(new NodeRelativePath(source, targetClone));
final NodeRelativePath shortestPath = Collections.min(paths, new Comparator<NodeRelativePath>() {
@Override
public int compare(NodeRelativePath o1, NodeRelativePath o2) {
return o1.getPathLength() - o2.getPathLength();
}
});
return shortestPath;
}
Aggregations