Пример #1
0
 private int distanceToLeaf(Node n) {
   if (graph.getSuccessors(n).isEmpty()) return 0;
   int result = 0;
   for (Object x : graph.getSuccessors(n)) {
     int tmp = distanceToLeaf((Node) x);
     if (tmp > result) result = tmp;
   }
   return 1 + result;
 }
Пример #2
0
 public Point2D getAnchorPosition(DerivationViewer.AnchorType type) {
   switch (type) {
     case ANCHOR_ROOT:
       return transform(root);
     case ANCHOR_LEFTMOST_LEAF:
       Node n = root;
       while (graph.getSuccessorCount(n) != 0) n = (Node) graph.getSuccessors(n).toArray()[0];
       return transform(n);
     default:
       return new Point2D.Double(0, 0);
   }
 }