determine depth of node at pos
197614
def depth(self, pos):
        """"""
        parent = self.parent_position(pos)
        if parent is None:
            return 0
        else:
            return self.depth(parent) + 1
622499
def calculateBoundingRect(self, nodes):
        
        out = QRectF()
        for node in nodes:
            rect = node.rect()
            pos = node.pos()
            
            bounding = QRectF(pos.x(), pos.y(), rect.width(), rect.height())
            out = out.united(bounding)
        
        return out
434767
def _posn(self, bounds, idx):
        """"""
        lo,hi = bounds[0],bounds[1]
        assert idx >= lo and idx <= hi, \
               f"Array index {idx} out of bounds: {bounds}\n"
   
        return idx-lo
643763
def depth(self):
        
        return len(self.path.rstrip(os.sep).split(os.sep))
1030638
def x_pos(self, xval):
        ""
        off = self.x_coord.get_canvas_pos(self.size[0], xval,
                                          self.x_range[0], self.x_range[1])
        return self.loc[0] + off
1032135
function(pos) {
            var layers = this.getChildren(),
                len = layers.length,
                end = len - 1,
                n, shape;

            for(n = end; n >= 0; n--) {
                shape = layers[n].getIntersection(pos);
                if (shape) {
                    return shape;
                }
            }

            return null;
        }
759213
static private int getPathDepth(INode inode) throws IOException {
    // calculate the depth of this inode from root
    int depth = 1;
    INode node; // node on the path to the root
    for (node = inode; node.parent != null; node = node.parent) {
      depth++;
    }

    // parent should be root
    if (node.isRoot()) {
      return depth;
    }
    
    // invalid inode
    throw new IOException("Invalid inode: " + inode.getLocalName());
  }
485694
public static void computePositions(Node node, int depth, double aoff, double awid, double radius, double radiusinc) {
    node.x = FastMath.sin(aoff) * radius;
    node.y = FastMath.cos(aoff) * radius;

    // Angular width per weight
    double cwid = awid / node.weight;
    // Avoid overly wide angles - shrink radius if necessary.
    double div = 1;
    if(node.weight > 1) {
      double s = FastMath.sin(awid * .5), c = FastMath.cos(awid * .5);
      double dx = s * (depth + 1), dy = c * (depth + 1) - depth;
      double d = FastMath.sqrt(dx * dx + dy * dy) / MathUtil.SQRT2;
      div = Math.max(div, d);
    }
    // Angular position of current child:
    double cang = aoff - awid * .5 / div;
    final double adjwid = cwid / div;
    for(Node c : node.children) {
      computePositions(c, depth + 1, cang + adjwid * c.weight * .5, adjwid * c.weight, radius + radiusinc, radiusinc);
      cang += adjwid * c.weight;
    }
  }
1129012
def push_pos(self, *args):
        
        self.proxy['_x'] = self.x / self.board.width
        self.proxy['_y'] = self.y / self.board.height
822712
function findDeepestNode(node) {
	while (node.children.length) {
		node = node.children[node.children.length - 1];
	}

	return node;
}
1345885
function(pos) {
                var
                    placement,
                    container = this.options.container,
                    clientWidth = container.innerWidth(),
                    clientHeight = container.innerHeight(),
                    scrollTop = container.scrollTop(),
                    scrollLeft = container.scrollLeft(),
                    pageX = Math.max(0, pos.left - scrollLeft),
                    pageY = Math.max(0, pos.top - scrollTop);
                //arrowSize = 20;

                //if placement equals auto，caculate the placement by element information;
                if (typeof(this.options.placement) === 'function') {
                    placement = this.options.placement.call(this, this.getTarget()[0], this.$element[0]);
                } else {
                    placement = this.$element.data('placement') || this.options.placement;
                }

                var isH = placement === 'horizontal';
                var isV = placement === 'vertical';
                var detect = placement === 'auto' || isH || isV;

                if (detect) {
                    if (pageX < clientWidth / 3) {
                        if (pageY < clientHeight / 3) {
                            placement = isH ? 'right-bottom' : 'bottom-right';
                        } else if (pageY < clientHeight * 2 / 3) {
                            if (isV) {
                                placement = pageY <= clientHeight / 2 ? 'bottom-right' : 'top-right';
                            } else {
                                placement = 'right';
                            }
                        } else {
                            placement = isH ? 'right-top' : 'top-right';
                        }
                        //placement= pageY>targetHeight+arrowSize?'top-right':'bottom-right';
                    } else if (pageX < clientWidth * 2 / 3) {
                        if (pageY < clientHeight / 3) {
                            if (isH) {
                                placement = pageX <= clientWidth / 2 ? 'right-bottom' : 'left-bottom';
                            } else {
                                placement = 'bottom';
                            }
                        } else if (pageY < clientHeight * 2 / 3) {
                            if (isH) {
                                placement = pageX <= clientWidth / 2 ? 'right' : 'left';
                            } else {
                                placement = pageY <= clientHeight / 2 ? 'bottom' : 'top';
                            }
                        } else {
                            if (isH) {
                                placement = pageX <= clientWidth / 2 ? 'right-top' : 'left-top';
                            } else {
                                placement = 'top';
                            }
                        }
                    } else {
                        //placement = pageY>targetHeight+arrowSize?'top-left':'bottom-left';
                        if (pageY < clientHeight / 3) {
                            placement = isH ? 'left-bottom' : 'bottom-left';
                        } else if (pageY < clientHeight * 2 / 3) {
                            if (isV) {
                                placement = pageY <= clientHeight / 2 ? 'bottom-left' : 'top-left';
                            } else {
                                placement = 'left';
                            }
                        } else {
                            placement = isH ? 'left-top' : 'top-left';
                        }
                    }
                } else if (placement === 'auto-top') {
                    if (pageX < clientWidth / 3) {
                        placement = 'top-right';
                    } else if (pageX < clientWidth * 2 / 3) {
                        placement = 'top';
                    } else {
                        placement = 'top-left';
                    }
                } else if (placement === 'auto-bottom') {
                    if (pageX < clientWidth / 3) {
                        placement = 'bottom-right';
                    } else if (pageX < clientWidth * 2 / 3) {
                        placement = 'bottom';
                    } else {
                        placement = 'bottom-left';
                    }
                } else if (placement === 'auto-left') {
                    if (pageY < clientHeight / 3) {
                        placement = 'left-top';
                    } else if (pageY < clientHeight * 2 / 3) {
                        placement = 'left';
                    } else {
                        placement = 'left-bottom';
                    }
                } else if (placement === 'auto-right') {
                    if (pageY < clientHeight / 3) {
                        placement = 'right-bottom';
                    } else if (pageY < clientHeight * 2 / 3) {
                        placement = 'right';
                    } else {
                        placement = 'right-top';
                    }
                }
                return placement;
            }
217048
private int depth() {
        int i = 0;
        for (TreeString p = this; p != null; p = p.parent) {
            i++;
        }
        return i;
    }
519087
function findNodeBeforePos(pos) {
    const lut = this.ends;
    assert(is.finitenumber(pos) && pos >= 0);

    let left = 0;
    let right = lut.length - 1;
    while (left < right) {
        const mid = Math.ceil((left + right) / 2);
        assert(mid >= 0 && mid < lut.length);
        if (pos < lut[mid].range[1]) {
            right = mid - 1;
        }
        else {
            left = mid;
        }
    }
    if (left > right) {
        assert(lut[0].range[1] > pos);
        return null;
    }

    const found = left;
    const foundPos = lut[found].range[1];
    if(foundPos > pos) {
        return null;
    }
    if (found <= lut.length - 2) {
        const nextPos = lut[found + 1].range[1];
        assert(nextPos > pos);
    }

    return lut[found];
}
815019
def _get_pos(self):
        
        if self._h >= len(self._options):
            return 0
        else:
            return self._start_line / (len(self._options) - self._h)
683802
protected int maxDepth(Layout.Node node) {
    int depth = 0;
    for(int i = 0; i < node.numChildren(); i++) {
      depth = Math.max(depth, maxDepth(node.getChild(i)));
    }
    return depth + 1;
  }
58465
function (node){
		// getBoundingClientRect returns t
		var o = node.getBoundingClientRect();
		if (!o.width || !o.height) {
			return {
				left: o.left,
				right: o.right,
				top: o.top,
				bottom: o.bottom,
				width: o.right - o.left,
				height: o.bottom - o.top
			};
		}
		return o;
	}
947714
def table_r_node(self, node):
        """"""
        start = len(self.f.getvalue())
        try:
            self.default(node)
        except GenericASTTraversalPruningException:
            final = len(self.f.getvalue())
            self.set_pos_info(node, start, final)
            self.set_pos_info(node[-1], start, final)
            raise GenericASTTraversalPruningException