TreePath tp3 = SearchTree.this.tree.getSelectionPath();
if(tp3 == null) return(false);
TreePath tp2 = tp3.getParentPath();
if(tp2 == null) return(false);
TreePath tp1 = tp2.getParentPath();
GraphNode node3 = SearchTree.this.currNode.getNode(tp3);
GraphNode node2 = SearchTree.this.currNode.getNode(tp2);
GraphNode node1 = SearchTree.this.currNode.getNode(tp1);
boolean workDone = false;
for(int i = 0; i < node2.getChildCount(); i++) {
GraphNode buf = (GraphNode)node2.getChildAt(i);
if(buf == node3) {
if(i < node2.getChildCount() - 1) {
buf = (GraphNode)node2.getChildAt(i+1);
Object[] newPath = new Object[tp2.getPathCount() + 1];
System.arraycopy(tp2.getPath(), 0, newPath, 0, tp2.getPathCount());
newPath[tp2.getPathCount()] = buf;
TreePath newTP = new TreePath(newPath);
SearchTree.this.tree.setSelectionPath(newTP);
workDone = true;
}
break;
}
}
if(!workDone && node1 != null) {
for(int i = 0; i < node1.getChildCount() - 1; i++) {
GraphNode buf = (GraphNode)node1.getChildAt(i);
if(buf == node2) {
for(int j = i+1; j < node1.getChildCount(); j++) {
buf = (GraphNode)node1.getChildAt(j);
if(!buf.isLeaf()) {
GraphNode bufInner = (GraphNode)buf.getChildAt(0);
Object[] newPath = new Object[tp1.getPathCount() + 2];
System.arraycopy(tp1.getPath(), 0, newPath, 0, tp1.getPathCount());
newPath[tp1.getPathCount()] = buf;
newPath[tp1.getPathCount() + 1] = bufInner;
TreePath newTP = new TreePath(newPath);
SearchTree.this.tree.setSelectionPath(newTP);
break;
}
}
break;
}
}
}
}
}
return(true);
} else if(e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_UP) {
synchronized (SearchTree.this.theMutexObject) {
if(SearchTree.this.currNode != null) {
TreePath tp3 = SearchTree.this.tree.getSelectionPath();
if(tp3 == null) return(false);
TreePath tp2 = tp3.getParentPath();
if(tp2 == null) return(false);
TreePath tp1 = tp2.getParentPath();
GraphNode node3 = SearchTree.this.currNode.getNode(tp3);
GraphNode node2 = SearchTree.this.currNode.getNode(tp2);
GraphNode node1 = SearchTree.this.currNode.getNode(tp1);
boolean workDone = false;
for(int i = 0; i < node2.getChildCount(); i++) {
GraphNode buf = (GraphNode)node2.getChildAt(i);
if(buf == node3) {
if(i > 0) {
buf = (GraphNode)node2.getChildAt(i-1);
Object[] newPath = new Object[tp2.getPathCount() + 1];
System.arraycopy(tp2.getPath(), 0, newPath, 0, tp2.getPathCount());
newPath[tp2.getPathCount()] = buf;
TreePath newTP = new TreePath(newPath);
SearchTree.this.tree.setSelectionPath(newTP);
workDone = true;
}
break;
}
}
if(!workDone && node1 != null) {
for(int i = 1; i < node1.getChildCount(); i++) {
GraphNode buf = (GraphNode)node1.getChildAt(i);
if(buf == node2) {
for(int j = i-1; j >= 0; j--) {
buf = (GraphNode)node1.getChildAt(j);
if(!buf.isLeaf()) {
GraphNode bufInner = (GraphNode)buf.getChildAt(buf.getChildCount() - 1);
Object[] newPath = new Object[tp1.getPathCount() + 2];
System.arraycopy(tp1.getPath(), 0, newPath, 0, tp1.getPathCount());
newPath[tp1.getPathCount()] = buf;
newPath[tp1.getPathCount() + 1] = bufInner;
TreePath newTP = new TreePath(newPath);