tree construction improvement

This commit is contained in:
Branislav Stojkovic
2019-02-24 13:15:30 +01:00
parent c0dac1a1db
commit 0d007e5737
8 changed files with 234 additions and 137 deletions
@@ -30,6 +30,11 @@ public class Tree {
private TreeConnectionType connectionType;
private TreeLeaf leaf;
public Tree(TreeConnectionType connectionType) {
this.children = new ArrayList<Tree>();
this.connectionType = connectionType;
}
public Tree(TreeLeaf leaf) {
this.leaf = leaf;
}
@@ -43,9 +48,13 @@ public class Tree {
return children;
}
public void trimChildren(int count) {
public void trimChildrenLeft(int count) {
children = children.subList(count, children.size());
}
public void trimChildrenRight(int count) {
children = children.subList(0, children.size() - count);
}
public TreeConnectionType getConnectionType() {
return connectionType;
@@ -92,7 +92,10 @@ public class TreeLeaf implements ITree {
@Override
public String toString() {
return component.getName() + "." + component.getInternalLinkName(pointIndex1, pointIndex2);
String linkName = component.getInternalLinkName(pointIndex1, pointIndex2);
if (component.getName().equals(linkName))
return linkName;
return component.getName() + "." + linkName;
}
public String toHTML() {